[Haskell-cafe] Lifting an enumerator
michael at snoyman.com
Wed Aug 24 16:02:49 CEST 2011
Max asked earlier how to create a new instance of a class in
Persistent using a monad transformer. Without getting into the
specific details of persistent, I wanted to pose a question based on a
much more general question: how can we lift the inner monad of an
enumerator? We can easily do so for an Iteratee, but there is
nothing to allow it for an Enumerator.
At first glance, this problem looks very similar to the shortcomings
of MonadIO when dealing with callbacks. In that case, you cannot use
liftIO on a function that takes an `IO a` as a parameter. A solution
to this issue is monad-control, which can be used to allow
exception catching, memory allocation, etc.
So I'm wondering: can we come up with a similar solution to this issue
with enumerators? I have a working solution for the specific case of
the ErrorT monad, but it would be great to be able to generalize
it. Bonus points if we could express this in terms of the typeclasses
already provided by monad-control.
More information about the Haskell-Cafe