Skip to content

Instantly share code, notes, and snippets.

@mjdominus
Created June 5, 2013 00:50
Show Gist options
  • Save mjdominus/5710839 to your computer and use it in GitHub Desktop.
Save mjdominus/5710839 to your computer and use it in GitHub Desktop.
mod-n intgers
data Zero
data Succ a
class Modulus a where
modulus :: a -> Int
instance Modulus Zero where
modulus = \a -> 0
instance (Modulus a) => Modulus (Succ a) where
modulus = \a -> 1 + modulus a
z = undefined :: Zero
a = undefined :: Succ (Succ Zero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment