Skip to content

Instantly share code, notes, and snippets.

@gip
Last active August 29, 2015 14:07
Show Gist options
  • Save gip/82aee58d0eb76a61e077 to your computer and use it in GitHub Desktop.
Save gip/82aee58d0eb76a61e077 to your computer and use it in GitHub Desktop.
Haskell / Free Monad / How can I do something like this?
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
@mioalter
Copy link

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