mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
22 lines
524 B
Plaintext
22 lines
524 B
Plaintext
data Nat : Type where
|
|
Z : Nat
|
|
S : Nat -> Nat
|
|
|
|
plus : Nat -> Nat -> Nat
|
|
plus Z $y = y
|
|
plus (S $k) $y = S (plus k y)
|
|
|
|
data Parity : Nat -> Type where
|
|
Even : (n : Nat) -> Parity (plus n n)
|
|
Odd : (n : Nat) -> Parity (S (plus n n))
|
|
|
|
half : (n : Nat) -> Parity n -> Nat
|
|
half (plus $n $n) (Even $n) = n
|
|
half (S (plus $n $n)) (Odd $n) = n
|
|
|
|
data Baz : Nat -> Type where
|
|
AddThings : (x : Nat) -> (y : Nat) -> Baz (plus x y)
|
|
|
|
addBaz : (x : Nat) -> Baz x -> Nat
|
|
addBaz (plus $x $y) (AddThings $x $y) = plus x y
|