Created
February 9, 2016 10:21
-
-
Save nulldatamap/575cd5c04ef4024f5a14 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 Free f a = Free (f (Free f a)) | Pure a | |
| deriving Functor | |
| liftF :: Functor f => f a -> Free f a | |
| liftF action = Free (fmap Pure action) | |
| data Ex x = Ex x (Maybe x) | |
| deriving Functor | |
| ex x y = liftF (Ex x y) | |
| {- Error: | |
| Occurs check: cannot construct the infinite type: a ~ Free Ex a | |
| Expected type: Maybe a | |
| Actual type: Maybe (Free Ex a) | |
| Relevant bindings include | |
| xs :: [a] (bound at src/Free.hs:17:12) | |
| x :: a (bound at src/Free.hs:17:10) | |
| problem :: [a] -> Free Ex a (bound at src/Free.hs:16:1) | |
| In the second argument of ‘($)’, namely ‘Just $ problem xs’ | |
| In the expression: ex x $ Just $ problem xs | |
| In an equation for ‘problem’: | |
| problem (x : xs) = ex x $ Just $ problem xs | |
| -} | |
| problem (x:[]) = ex x Nothing | |
| problem (x:xs) = ex x $ Just $ problem xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment