update a couple of playground files

This commit is contained in:
2026-02-18 21:39:51 -08:00
parent 2b72521fd6
commit c1f959be38
2 changed files with 25 additions and 30 deletions

View File

@@ -1,24 +1,25 @@
module DSL
-- "A DSL for finite types and enumeration"
-- https://www.youtube.com/watch?v=sFyy9sssK50
data : U where
Z :
S :
data Nat : U where
Z : Nat
S : Nat Nat
infixl 7 _+_
infixl 8 _*_
_+_ :
_+_ : Nat Nat Nat
Z + m = m
(S k) + m = S (k + m)
_*_ :
_*_ : Nat Nat Nat
Z * m = Z
(S k) * m = m + k * m
infixr 4 _::_
data Vec : U U where
data Vec : U Nat U where
Nil : {a} Vec a Z
_::_ : {a k} a Vec a k Vec a (S k)
@@ -43,7 +44,7 @@ two = Add One One
four : E
four = Mul two two
card : E
card : E Nat
card Zero = Z
card One = S Z
card (Add x y) = card x + card y
@@ -53,7 +54,7 @@ data Empty : U where
data Unit : U where
-- unit accepted but case building thinks its a var
unit : Unit
MkUnit : Unit
data Either : U -> U -> U where
Left : {A B} A Either A B
@@ -73,10 +74,10 @@ Bool : U
Bool = typ two
false : Bool
false = Left unit
false = Left MkUnit
true : Bool
true = Right unit
true = Right MkUnit
BothBoolBool : U
BothBoolBool = typ four