[Haskell-cafe] Stateful iteratees

Gregory Collins greg at gregorycollins.net
Thu Apr 7 19:12:01 CEST 2011


On Thu, Apr 7, 2011 at 7:04 PM, Ertugrul Soeylemez <es at ertes.de> wrote:
> Hello fellow Haskellers,
>
> I'm trying to solve a very practical problem:  I need a stateful
> iteratee monad transformer.  Explicit state passing is very inconvenient
> and would destroy the elegance of my library.
>
> There are two approaches to this:
>
>  1. type MyT a m = Iteratee a (StateT MyConfig m)
>  2. type MyT a m = StateT MyConfig (Iteratee a m)
>
> Both work well except in two very specific corner cases:
>
>  - I need to convert the transformer to 'Iteratee a m', i.e. remove the
>    state layer.  This is obviously trivial with the second variant, but
>    seems very difficult with the first one, if it's possible at all.

Why can't you use #1 and do this when you call "run_"?

G
-- 
Gregory Collins <greg at gregorycollins.net>



More information about the Haskell-Cafe mailing list