Skip to content

Instantly share code, notes, and snippets.

@vlopezj
Created May 23, 2017 14:30
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 vlopezj/53a3ee6cc1889d6ef8d7b9b95f08c912 to your computer and use it in GitHub Desktop.
Save vlopezj/53a3ee6cc1889d6ef8d7b9b95f08c912 to your computer and use it in GitHub Desktop.
data EitherDup a = MyLeft a
| MyRight a
class HasEndo t where
-- | prop> endo . endo == id
endo :: t -> t
instance HasEndo (EitherDup a) where
endo (MyLeft a) = MyRight a
endo (MyRight a) = MyLeft a
data Exp = Lit Int
| Exp :+: Exp
| Exp :*: Exp
deriving HasEndo Exp as pattern a :+: a = MyLeft (a,a)
pattern a :*: a = MyRight (a,a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment