Module: Rigor::Inference::HktBody
- Defined in:
- lib/rigor/inference/hkt_body.rb
Overview
ADR-20 Slice 2a — node types for the parsed body of a type-function ‘Definition`. Each node represents one piece of a Rigor-side type expression that the reducer (HktReducer) walks against a concrete argument list.
Slice 2a ships a programmatic constructor surface only: plugin and Rigor-bundled overlay authors build a body tree by hand using these node types. The string-grammar parser that reads ‘Definition#body` (the raw String slot already populated by Slice 1’s ‘HktDirectives.parse_define`) into a tree is Slice 2b’s deliverable; until it ships, the ‘body` String stays opaque and `body_tree` is the evaluable form.
The five node types cover the JSON.parse and dry-monads use cases ADR-20 § Implementation slicing names as near-term adopters:
-
TypeLeaf — wraps a fully-built ‘Rigor::Type` (use for atoms like `nil`, `Constant<true>`, `Nominal`).
-
Param — reference to a formal parameter declared in the enclosing ‘Definition#params` list (e.g. `K` in `json::value`). The reducer substitutes from the application’s ‘args`.
-
AppRef — abstract HKT application; the reducer resolves it via the registry, or returns the ‘App` carrier as-is when the reference is self-recursive (lazy “tying-the-knot” handling that lets recursive sums like `json::value` reduce without infinite expansion).
-
Union — N-ary union of arms.
-
NominalApp — parameterised nominal class (‘Array`, `Hash[K, V]`) whose type args are themselves body nodes.
Every node is a frozen ‘Data.define` value; structural equality is by-field.
Defined Under Namespace
Classes: AppRef, Conditional, NominalApp, Param, TestEquality, TestMembership, TestSubtype, TypeLeaf, Union