Last active
April 20, 2018 20:34
-
-
Save paluh/cef92915b6348b18149a5dc347b36e26 to your computer and use it in GitHub Desktop.
Fun with Functional Dependencies in Purescript
This file contains 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
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