mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 16:25:54 +03:00
ADTs can be defined with the syntax: data Vector T (len: Nat) | cons (len: Nat) (head: T) (tail: (Vector T len)) : (Vector T (Nat.succ len)) | nil : (Vector T Nat.zero) Which will convert to the equivalent inductive λ-encoding (via self). Pattern-matching has the syntax: match x = expr with (a: A) (b: B) ... { ctr0: ret0 ctr1: ret1 }: motive The 'with' syntax is used to explicitly move values down the cases, crating lambdas for them. This linearizes them (which avoids cloning) and specializes their type w.r.t. the matched value, for proving. We also allow a shorthand for top-level definitions, as: foo (a: A) (b: B) ... : R = body This will auto-add lambdas before 'body'. If 'body' is a pattern-match, the lambdas will be automatically moved down, so this has the effect of linearizing top-level args, without needing explicit 'with' annotations.
3 lines
42 B
Plaintext
3 lines
42 B
Plaintext
A.zero : A =
|
|
~λP λs λz (z λTλt(t))
|