Created
November 12, 2016 17:06
-
-
Save mietek/354412e479af35356913d08178d4c72e to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE ScopedTypeVariables #-} | |
data Zero | |
data Suc n | |
type One = Suc Zero | |
type Two = Suc One | |
type Three = Suc Two | |
class Nat n where | |
fromNat :: Num a => n -> a | |
instance Nat Zero where | |
fromNat _ = 0 | |
instance Nat n => Nat (Suc n) where | |
fromNat _ = fromNat (undefined :: n) + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment