Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Henning Thielemann
On Tue, 7 Apr 2009, Stephan Friedrichs wrote: Henning Thielemann wrote: is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Stephan Friedrichs
Henning Thielemann wrote: is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I wondered whether there is something inverse to

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Tom Schrijvers
Hello, is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I wondered whether there is something inverse to Writer, and Reader is

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Stephan Friedrichs
My solution is this transformer: newtype ConsumerT c m a = ConsumerT { runConsumerT :: [c] - m (a, [c]) } instance (Monad m) = Monad (ConsumerT c m) where return x = ConsumerT $ \cs - return (x, cs) m = f = ConsumerT $ \cs - do ~(x, cs') - runConsumerT m cs

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-07 Thread Henning Thielemann
On Tue, 7 Apr 2009, Stephan Friedrichs wrote: My solution is this transformer: newtype ConsumerT c m a = ConsumerT { runConsumerT :: [c] - m (a, [c]) } instance (Monad m) = Monad (ConsumerT c m) where return x = ConsumerT $ \cs - return (x, cs) m = f = ConsumerT $ \cs - do

[Haskell-cafe] Monad transformer to consume a list

2009-04-06 Thread Stephan Friedrichs
Hello, is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. //Stephan -- Früher hieß es ja: Ich denke, also bin ich. Heute weiß man: Es geht auch so. -

Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-06 Thread Henning Thielemann
On Mon, 6 Apr 2009, Stephan Friedrichs wrote: Hello, is there a monad transformer to consume an input list? I've got external events streaming into the monad that are consumed on demand and I'm not sure if there's something better than a StateT. I wondered that, too. I wondered whether