mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 16:25:54 +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.
50 lines
1.8 KiB
Plaintext
50 lines
1.8 KiB
Plaintext
Kind.reduce.op2
|
|
: ∀(opr: Kind.Oper) ∀(fst: Kind.Term) ∀(snd: Kind.Term)
|
|
Kind.Term
|
|
= λopr λfst λsnd
|
|
use P = ∀(snd: Kind.Term) Kind.Term
|
|
use Y = λfst_val λsnd
|
|
use P = ∀(fst_val: #U60) Kind.Term
|
|
use Y = λsnd_val λfst_val
|
|
use P = λx ∀(fst_val: #U60) ∀(snd_val: #U60) Kind.Term
|
|
use add = λfst_val λsnd_val (Kind.num #(+ fst_val snd_val))
|
|
use mul = λfst_val λsnd_val (Kind.num #(* fst_val snd_val))
|
|
use sub = λfst_val λsnd_val (Kind.num #(- fst_val snd_val))
|
|
use div = λfst_val λsnd_val (Kind.num #(/ fst_val snd_val))
|
|
use mod = λfst_val λsnd_val (Kind.num #(% fst_val snd_val))
|
|
use eq = λfst_val λsnd_val (Kind.num #(== fst_val snd_val))
|
|
use ne = λfst_val λsnd_val (Kind.num #(!= fst_val snd_val))
|
|
use lt = λfst_val λsnd_val (Kind.num #(< fst_val snd_val))
|
|
use gt = λfst_val λsnd_val (Kind.num #(> fst_val snd_val))
|
|
use lte = λfst_val λsnd_val (Kind.num #(<= fst_val snd_val))
|
|
use gte = λfst_val λsnd_val (Kind.num #(>= fst_val snd_val))
|
|
use and = λfst_val λsnd_val (Kind.num #(& fst_val snd_val))
|
|
use or = λfst_val λsnd_val (Kind.num #(| fst_val snd_val))
|
|
use xor = λfst_val λsnd_val (Kind.num #(^ fst_val snd_val))
|
|
use lsh = λfst_val λsnd_val (Kind.num #(<< fst_val snd_val))
|
|
use rsh = λfst_val λsnd_val (Kind.num #(>> fst_val snd_val))
|
|
(~opr
|
|
P
|
|
add
|
|
mul
|
|
sub
|
|
div
|
|
mod
|
|
eq
|
|
ne
|
|
lt
|
|
gt
|
|
lte
|
|
gte
|
|
and
|
|
or
|
|
xor
|
|
lsh
|
|
rsh
|
|
fst_val
|
|
snd_val
|
|
)
|
|
use N = λsnd λfst_val (Kind.op2 opr (Kind.num fst_val) snd)
|
|
(Kind.if.num snd P Y N fst_val)
|
|
use N = λfst λsnd (Kind.op2 opr fst snd)
|
|
(Kind.if.num fst P Y N snd) |