Created
June 14, 2019 22:33
-
-
Save robinhouston/86ae04ee1b3506a32003466ca091f998 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 T = Two (T, T) | One T deriving (Eq, Show) | |
type X = Either (Either T T) () | |
f :: Either X X -> Either (X, X) () | |
f (Left (Left (Left (Two (t1, t2))))) = Left (Left (Left t1), Left (Left t2)) | |
f (Right (Left (Left (Two (t1, t2))))) = Left (Left (Left t1), Left (Right t2)) | |
f (Left (Left (Right (Two (t1, t2))))) = Left (Left (Right t1), Left (Left t2)) | |
f (Right (Left (Right (Two (t1, t2))))) = Left (Left (Right t1), Left (Right t2)) | |
f (Left (Left (Left (One t)))) = Left (Left (Left t), Right ()) | |
f (Right (Left (Left (One t)))) = Left (Left (Right t), Right ()) | |
f (Left (Left (Right (One t)))) = Left (Right (), Left (Left t)) | |
f (Right (Left (Right (One t)))) = Left (Right (), Left (Right t)) | |
f (Left (Right ())) = Left (Right (), Right ()) | |
f (Right (Right ())) = Right () | |
g :: Either (X, X) () -> Either X X | |
g (Left (Left (Left t1), Left (Left t2))) = Left (Left (Left (Two (t1, t2)))) | |
g (Left (Left (Left t1), Left (Right t2))) = Right (Left (Left (Two (t1, t2)))) | |
g (Left (Left (Right t1), Left (Left t2))) = Left (Left (Right (Two (t1, t2)))) | |
g (Left (Left (Right t1), Left (Right t2))) = Right (Left (Right (Two (t1, t2)))) | |
g (Left (Left (Left t), Right ())) = Left (Left (Left (One t))) | |
g (Left (Left (Right t), Right ())) = Right (Left (Left (One t))) | |
g (Left (Right (), Left (Left t))) = Left (Left (Right (One t))) | |
g (Left (Right (), Left (Right t))) = Right (Left (Right (One t))) | |
g (Left (Right (), Right ())) = Left (Right ()) | |
g (Right ()) = Right (Right ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment