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
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
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
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
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
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.
-
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