* Michael Snoyman <michael@snoyman.com> [2014-08-27 23:48:06+0300]
> > The problem is the following Sink, which counts how many even/odd Tokens
> > are
> > seen:
> >
> > type SinkState = (Integer, Integer)
> >
> > sink2 :: (Monad m) => SinkState -> Sink Token m SinkState
> > sink2 state@(!evenCount, !oddCount) = do
> > maybeToken <- await
> > case maybeToken of
> > Nothing -> return state
> > (Just Even) -> sink2 (evenCount + 1, oddCount )
> > (Just Odd ) -> sink2 (evenCount , oddCount + 1)
>
> Wow, talk about timing! What you've run into here is expensive monadicInteresting. From looking at sink2, it seems that it produces a good,
> bindings. As it turns out, this is exactly what my blog post from last
> week[1] covered. You have three options to fix this:
>
> 1. Just upgrade to conduit 1.2.0, which I released a few hours ago, and
> uses the codensity transform to avoid the problem. (I just tested your
> code; you get constant memory usage under conduit 1.2.0, seemingly without
> any code change necessary.)
right-associated bind tree. Am I missing something?
And what occupies the memory in this case?
Roman
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe