Skip to content

Instantly share code, notes, and snippets.

@paluh
Last active April 20, 2018 20:34
Show Gist options
  • Save paluh/cef92915b6348b18149a5dc347b36e26 to your computer and use it in GitHub Desktop.
Save paluh/cef92915b6348b18149a5dc347b36e26 to your computer and use it in GitHub Desktop.
Fun with Functional Dependencies in Purescript
module Main where
data Proxy a = Proxy
data Zero
data Su n
type Three = Su (Su (Su Zero))
class Even n where
even :: Proxy n
class Odd n where
odd :: Proxy n
instance evenZero :: Even Zero where
even = Proxy
instance oddNumber :: (Even n) => Odd (Su n) where
odd = Proxy
instance evenNumber :: (Odd n) => Even (Su n) where
even = Proxy
-- | This is not even should fail
x :: Proxy (Su (Su (Su Zero)))
x = even
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment