tricu/lib/base.tri

75 lines
1.2 KiB
Plaintext
Raw Normal View History

false = t
_ = t
true = t t
id = \a : a
const = \a b : a
pair = t
if = \cond then else : t (t else (t t then)) t cond
y = ((\mut wait fun : wait mut (\x : fun (wait mut x)))
(\x : x x)
(\a0 a1 a2 : t (t a0) (t t a2) a1))
compose = \f g x : f (g x)
triage = \leaf stem fork : t (t leaf stem) fork
test = triage "Leaf" (\_ : "Stem") (\_ _ : "Fork")
2025-01-20 19:20:29 -06:00
matchBool = (\ot of : triage
of
(\_ : ot)
2025-01-20 19:20:29 -06:00
(\_ _ : ot)
)
lAnd = (triage
(\_ : false)
(\_ x : x)
(\_ _ x : x))
lOr = (triage
(\x : x)
(\_ _ : true)
(\_ _ _ : true))
2025-01-20 19:20:29 -06:00
matchPair = \a : triage _ _ a
2025-01-20 19:20:29 -06:00
not? = matchBool false true
and? = matchBool id (\_ : false)
2025-01-20 19:20:29 -06:00
or? = (\x z :
matchBool
(matchBool true true z)
(matchBool true false z)
x)
xor? = (\x z :
matchBool
(matchBool false true z)
(matchBool true false z)
x)
equal? = y (\self : triage
(triage
true
(\_ : false)
(\_ _ : false))
(\ax :
triage
false
(self ax)
(\_ _ : false))
(\ax ay :
triage
false
(\_ : false)
(\bx by : lAnd (self ax bx) (self ay by))))
2025-01-20 19:20:29 -06:00
succ = y (\self :
triage
1
t
(triage
(t (t t))
(\_ tail : t t (self tail))
t))