Skip to content

Instantly share code, notes, and snippets.

@nkaretnikov
Created October 3, 2015 15:48
Show Gist options
  • Save nkaretnikov/b5a626d529c871318935 to your computer and use it in GitHub Desktop.
Save nkaretnikov/b5a626d529c871318935 to your computer and use it in GitHub Desktop.
intToNat
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