Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created May 27, 2017 16:48
Show Gist options
  • Save Icelandjack/e42495341f6029aad8c7e4e4a12c34ce to your computer and use it in GitHub Desktop.
Save Icelandjack/e42495341f6029aad8c7e4e4a12c34ce to your computer and use it in GitHub Desktop.
Define multiple instances simultaneously
@Icelandjack
Copy link
Author

We merge the contexts of methods from the same type class just as usual

class  EQ a where  eq :: a -> a -> Bool
class NEQ a where neq :: a -> a -> Bool

newtype C a = C a
  deriving (EQ, NEQ)

instance (EQ a, NEQ a) => Eq (C a) where
  (==) = eq
  (/=) = neq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment