Last active
August 29, 2015 14:07
-
-
Save gip/82aee58d0eb76a61e077 to your computer and use it in GitHub Desktop.
Haskell / Free Monad / How can I do something like this?
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 A = A Text | |
data B = B Text A | |
data ActionC t next = InsertC t (t -> next) | |
instance Functor (ActionC t) where | |
fmap f (InsertC a b)= InsertC a (f . b) | |
insertC a = liftF (InsertC a id) | |
proC txt1 txt2 = do | |
a <- insertC $ A txt1 | |
b <- insertC $ B txt2 a | |
return b |
I think you want 'String' in place of 'Text' in your definitions of A and B.
Not in scope: type constructor or class `Text'
Don't know if it does what you want, but it compiles when I make that change.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get the error:
Couldn't match type
A' with
B'When using functional dependencies to combine
MonadFree (ActionC A) m0,
arising from a use of
insertC' at Transact.hs:96:8-14 MonadFree (ActionC B) m0, arising from a use of
insertC' at Transact.hs:97:8-14In the expression: insertC
In a stmt of a 'do' block: b <- insertC $ B txt2 a
How can I fix this so that it compiles?