I'm getting a stack overflow exception in code like this:
-- applyAction :: A - IO [B]
vs - fmap concat $ mapM applyAction sas
return vs
I don't get it if I change the code to this:
-- applyAction :: A - IO [B]
mapM_
Tim Docker wrote:
I'm getting a stack overflow exception in code like this:
-- applyAction :: A - IO [B]
vs - fmap concat $ mapM applyAction sas
return vs
I don't get it if I change the code to this:
-- applyAction :: A - IO [B]
On 21/09/11 02:39, Heinrich Apfelmus wrote:
Tim Docker wrote:
I'm getting a stack overflow exception in code like this:
-- applyAction :: A - IO [B]
vs - fmap concat $ mapM applyAction sas
return vs
I don't get it if I change the code to this:
--
On Thursday 22 September 2011, 01:00:37, Tim Docker wrote:
I believe the error is happening in the concat because there are
subsequent IO actions that fail to execute. ie the code is equivalent
to:
vs - fmap concat $ mapM applyAction sas
someOtherAction
consume
On Wed, Sep 21, 2011 at 3:39 AM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:
Of course, a list of 1 million items is going to take a lot of memory,
unless you generate it lazily. Unfortunately mapM cannot generate its
result lazily because it has to execute all IO actions before
Tim Docker t...@dockerz.net writes:
mapM_ applyAction sas
Maybe you could try a lazy version of mapM? E.g., I think this would do
it:
import System.IO.Unsafe (unsafeInterleaveIO)
:
mapM' f = sequence' . map f
where sequence' ms = foldr k (return []) ms
k m m' =
On Wed, Sep 21, 2011 at 6:04 AM, Ketil Malde ke...@malde.org wrote:
Tim Docker t...@dockerz.net writes:
mapM_ applyAction sas
Maybe you could try a lazy version of mapM? E.g., I think this would do
it:
Another option is to use a version of mapM that accumulates the result
on the
On 21 September 2011 17:32, Felipe Almeida Lessa felipe.le...@gmail.com wrote:
On Wed, Sep 21, 2011 at 6:04 AM, Ketil Malde ke...@malde.org wrote:
Tim Docker t...@dockerz.net writes:
mapM_ applyAction sas
Maybe you could try a lazy version of mapM? E.g., I think this would do
it: