Created
October 3, 2015 15:48
-
-
Save nkaretnikov/b5a626d529c871318935 to your computer and use it in GitHub Desktop.
intToNat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Nat n where | |
NZero :: Nat Zero | |
NSucc :: forall n. Nat n -> Nat (Succ n) | |
intToNat :: Int -> forall n. Nat n | |
intToNat 0 = NZero | |
intToNat n = NSucc $ intToNat $ pred n | |
{- | |
Couldn't match type ‘n’ with ‘Succ n0’ | |
‘n’ is a rigid type variable bound by | |
the type signature for intToNat :: Int -> Nat n at Main.hs:58:1 | |
Expected type: Nat n | |
Actual type: Nat (Succ n0) | |
In the expression: NSucc $ intToNat $ pred n | |
In an equation for ‘intToNat’: | |
intToNat n = NSucc $ intToNat $ pred n | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment