← Graph

Literal

tool 13 connections

Open-source Ruby gem by Joel Drapper. Treats any object responding to `===` as a type and provides a library of composable type constructors: _Array, _Hash, _Tuple, _Set, _Union, _Intersection, _Constraint, _Interface (duck typing), _Deferred (recursive types like _JSONData), _Nilable (intentionally ugly so nilable types stand out). Also ships LiteralStruct/LiteralData (mutable/immutable typed value objects built with `prop name, Type`), Literal::Properties (mixable prop macro), Literal::Enum (constant enumerations inheriting from a value type, with value/predicate/coerce/`&status` support and always-frozen instances), and Literal::Value/Decorator (single-value wrappers like UserID with selective method delegation). Uses code generation so initializers are equivalent to hand-written ones; types do essentially zero runtime allocations (inline-cache may allocate once); primitive unions compile to set-based O(1) membership; nested unions auto-flatten; types are allocated at boot and copy-on-write-shared across processes via eager loading. Supports keyword/positional/splat/block prop arguments, readers/writers with public/private/protected/false, coercion blocks, default values (must be frozen or wrapped in a Proc to avoid shared-mutable-default bugs). Roadmap: typed collection objects (array partially done, then tuple/hash/set) that can't be corrupted after initialization, type-to-type subtype comparison for variance shortcuts (concat-basket-of-apples-into-basket-of-fruit in O(1)), cross-property validation via named-parameter blocks, a result monad integrated with the type system, and LLM-schema generation/validation. Deployed at Clear Scope where it reduced production error rates. Design philosophy: Goldilocks between full static typing and pure dynamism; incremental 'accordion of complexity'; types as first-class Ruby objects; errors are careful (tells you which item in an array failed and what was expected).

author
Joel Drapper
license
open-source
category
library
language
Ruby
about
Literal tool
The talk introduces and demonstrates Literal's types, struct/data, properties, enums, values, and decorators.
Takeaway centers on what Literal provides.
Raising is Literal's default and was kept on in production at Clear Scope.
about
Literal tool
Recommendation applies specifically to Literal's composable type constructors.
about
Literal tool
Compares Literal's design.
Asks about Literal::Data production behavior.
Asks whether Literal can power a validation library.
about
Literal tool
Talk explains that Yippee components extend Literal::Properties.
tool Literal
uses
Literal treats any object responding to === as a type.
tool Literal
uses
Ruby tool
Built as a Ruby gem leveraging Ruby's existing case-equality, pattern matching, and code-generation capabilities.
tool Phlex
uses
Literal tool
Phlex components can extend Literal::Properties to get typed props like union-typed size/variant.
project Yippee
uses
Literal tool
Every Yippee component/view extends Literal::Properties, aligning Yippee with Joel Drapper's runtime-typing gem.
person Joel Drapper
works_on
Literal tool
Creator and maintainer of the Literal gem, the centerpiece of the talk.
role: creator

Provenance

Read by
4 extractions