Created
May 23, 2017 14:30
-
-
Save vlopezj/53a3ee6cc1889d6ef8d7b9b95f08c912 to your computer and use it in GitHub Desktop.
This file contains 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 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