mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-01 06:12:57 +03:00
6c7f13d128
Like Idris 1, these are implicitly added on encountering a repeated name or a non-constructor application. Unlike Idris 1 (and Blodwen) they are checking by unification rather than matching (which means in particular that function argument names can't be bound in dot patterns) which is slightly less expressive, but better overall because matching is potentially more error prone.
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
|