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.
21 lines
506 B
Plaintext
21 lines
506 B
Plaintext
IO.bind
|
|
: ∀(A: *)
|
|
∀(B: *)
|
|
∀(a: (IO A))
|
|
∀(b: ∀(x: A) (IO B))
|
|
(IO B)
|
|
= λA λB λa λb
|
|
use P = λx ∀(b: ∀(x: A) (IO B)) (IO B)
|
|
use print = λtext λthen λb
|
|
(IO.print B text λx (IO.bind A B (then x) b))
|
|
use load = λfile λthen λb
|
|
(IO.load B file λs (IO.bind A B (then s) b))
|
|
use save = λfile λdata λthen λb
|
|
(IO.save
|
|
B
|
|
file
|
|
data
|
|
λx (IO.bind A B (then Unit.one) b)
|
|
)
|
|
use done = λterm λb (b term)
|
|
(~a P print load save done b) |