Created
February 20, 2019 20:20
-
-
Save pigam/aeb8487ce0843086b49cfdf0c59daad7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| data TisAnInteger = TisAn Integer | |
| instance Eq TisAnInteger where | |
| TisAn i == TisAn i' = i == i' | |
| data TwoIntegers = Two Integer Integer | |
| instance Eq TwoIntegers where | |
| Two x y == Two x' y' = x == x' && y == y' | |
| data StringOrInt = TisAnInt Int | TisAString String | |
| instance Eq StringOrInt where | |
| TisAnInt i == TisAnInt i' = i == i' | |
| TisAString s == TisAString s' = s == s' | |
| _ == _ = False | |
| data Pair a = Pair a a deriving Show | |
| instance Eq a => Eq (Pair a) where | |
| Pair x y == Pair x' y' = x == x' && y == y' | |
| data Tuple a b = Tuple a b | |
| instance (Eq a, Eq b) => Eq (Tuple a b) where | |
| Tuple x y == Tuple x' y' = x == x' && y == y' | |
| data Which a = ThisOne a | ThatOne a | |
| instance Eq a => Eq (Which a) where | |
| ThisOne x == ThisOne y = x == y | |
| ThatOne x == ThatOne y = x == y | |
| _ == _ = False | |
| data EitherOr a b = Hello a | Goodbye b | |
| instance (Eq a, Eq b) => Eq (EitherOr a b) where | |
| Hello a == Hello a' = a == a' | |
| Goodbye a == Goodbye a' = a == a' | |
| _ == _ = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment