Idris2-boot/tests/ttimp/basic004/AsPat.yaff
Edwin Brady ea0de3d499 Initial implementation of 'case' blocks
It's not quite there yet, though, because the treatment of 'as' patterns
isn't quite right and the slightly hacky approach we're taking might not
be the best. Rethinking now...
2019-05-17 13:52:09 +01:00

23 lines
386 B
Plaintext

data Nat : Type where
Z : Nat
S : Nat -> Nat
simpleAs : Nat -> Nat
simpleAs z@(_) = z
as : Nat -> Nat
as Z = Z
as p@(S $k) = p
plus : Nat -> Nat -> Nat
plus Z $y = y
plus (S $k) $y = S (plus k y)
data PairNat : Type where
MkPair : Nat -> Nat -> PairNat
pairPred : Nat -> PairNat
pairPred Z = MkPair Z Z
pairPred (S Z) = MkPair Z Z
pairPred (S p@(S $k)) = MkPair p k