mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
19 lines
348 B
Idris
19 lines
348 B
Idris
data IsS : Nat -> Type where
|
|
S : (n : Nat) -> IsS (S n)
|
|
|
|
isS : (n : Nat) -> Maybe (IsS n)
|
|
isS (S n) = Just (S n)
|
|
isS _ = Nothing
|
|
|
|
failing "Pattern variable n unifies with: S ?m"
|
|
|
|
pred : Nat -> Nat
|
|
pred n with (isS n)
|
|
_ | Nothing = Z
|
|
_ | Just (S m) = m
|
|
|
|
pred : {n : Nat} -> Nat
|
|
pred with (isS n)
|
|
_ | Nothing = Z
|
|
_ | Just (S m) = m
|