mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-21 02:31:50 +03:00
a972778eab
They don't all pass yet, for minor reasons. Coming shortly... Unfortunately the startup overhead for chez is really noticeable here!
16 lines
351 B
Plaintext
16 lines
351 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 $m)) (Odd $n) = n
|