Skip to content

Instantly share code, notes, and snippets.

@liamoc
Created June 22, 2012 10:56
Show Gist options
  • Save liamoc/2972077 to your computer and use it in GitHub Desktop.
Save liamoc/2972077 to your computer and use it in GitHub Desktop.
Implicit Parameters
data Eq a = Eq {
eq :: a -> a -> Bool,
neq :: a -> a -> Bool
}
(==) :: (?eq :: Eq a) => a -> a -> Bool
(==) = eq ?eq
(/=) :: (?eq :: Eq a) => a -> a -> Bool
(/=) = neq ?eq
boolEq :: Eq Bool
boolEq = Eq primBoolEq (\x y -> not (primBoolEq x y))
test :: Foo
test = let ?eq = boolEq in True == False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment