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; plugin and Rigor-bundled overlay authors may build a body tree by hand using these node types. The string-grammar parser (HktBodyParser, Slice 2b, shipped) reads Definition#body (populated by Slice 1's HktDirectives.parse_define) into this node tree; body_tree is the evaluable form.

The nine node types cover JSON.parse, dry-monads, and the ADR-20 § D3 conditional / membership forms (shipped):

  • TypeLeaf — wraps a fully-built Rigor::Type (use for atoms like nil, Constant<true>, Nominal[Integer]).
  • Param — reference to a formal parameter declared in the enclosing Definition#params list (e.g. K in json::value[K]). 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[X], 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