Skip to content

Instantly share code, notes, and snippets.

@higherorderfunctor
Created August 24, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higherorderfunctor/4382803a7a71347c1c828a5f2be3761e to your computer and use it in GitHub Desktop.
Save higherorderfunctor/4382803a7a71347c1c828a5f2be3761e to your computer and use it in GitHub Desktop.
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 b) (Goodbye b') =
b == b'
(==) _ _ = False
λ> Hello "a" == Hello "a"
<interactive>:38:1: warning: [-Wtype-defaults]
• Defaulting the following constraint to type ‘()’
Eq b0 arising from a use of ‘==’
• In the expression: Hello "a" == Hello "a"
In an equation for ‘it’: it = Hello "a" == Hello "a"
<interactive>:38:1: warning: [-Wtype-defaults]
• Defaulting the following constraint to type ‘()’
Eq b0 arising from a use of ‘==’
• In the expression: Hello "a" == Hello "a"
In an equation for ‘it’: it = Hello "a" == Hello "a"
True
*TypeClasses1
λ> (Hello "a" :: EitherOr String ()) == (Hello "a" :: EitherOr String ())
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment