mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 17:56:48 +03:00
Now, there are two local binders: let x = ... use x = ... The 'let' binder will create a local definition, type-check it, and assign a name to it. When compiled, it will create 'dup' nodes. The 'use' binder is just an alias. It will not bind a new variable, and, when compiled, will create inline copies. Also, for type-checking, it allows creating aliases that are definitionaly equal for the checker.
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
BBT.got
|
|
: ∀(K: *)
|
|
∀(V: *)
|
|
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
|
|
∀(key: K)
|
|
∀(map: (BBT K V))
|
|
(Pair (Maybe V) (BBT K V))
|
|
= λK λV λcmp λkey λmap
|
|
use P = λx (Pair (Maybe V) (BBT K V))
|
|
use bin = λsize λnext.key λnext.val λnext.lft λnext.rgt
|
|
use P = λx
|
|
∀(cmp: ∀(a: K) ∀(b: K) Cmp) ∀(key: K)
|
|
(Pair (Maybe V) (BBT K V))
|
|
use ltn = λcmp λkey
|
|
use new_pair = (BBT.got K V cmp key next.lft)
|
|
use P = λx (Pair (Maybe V) (BBT K V))
|
|
use new = λval λlft
|
|
use map = (BBT.bin K V size next.key next.val lft next.rgt)
|
|
(Pair.new (Maybe V) (BBT K V) val map)
|
|
(~new_pair P new)
|
|
use eql = λcmp λkey
|
|
use map = (BBT.bin K V size next.key next.val next.lft next.rgt)
|
|
(Pair.new
|
|
(Maybe V)
|
|
(BBT K V)
|
|
(Maybe.some V next.val)
|
|
map
|
|
)
|
|
use gtn = λcmp λkey
|
|
use new_pair = (BBT.got K V cmp key next.rgt)
|
|
use P = λx (Pair (Maybe V) (BBT K V))
|
|
use new = λval λrgt
|
|
use map = (BBT.bin K V size next.key next.val next.lft rgt)
|
|
(Pair.new (Maybe V) (BBT K V) val map)
|
|
(~new_pair P new)
|
|
(~(cmp key next.key) P ltn eql gtn cmp key)
|
|
use tip = (Pair.new
|
|
(Maybe V)
|
|
(BBT K V)
|
|
(Maybe.none V)
|
|
(BBT.tip K V)
|
|
)
|
|
(~map P bin tip) |