On 21 September 2011 17:32, Felipe Almeida Lessa wrote:
> On Wed, Sep 21, 2011 at 6:04 AM, Ketil Malde wrote:
>> Tim Docker 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
On Wed, Sep 21, 2011 at 6:04 AM, Ketil Malde wrote:
> Tim Docker 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 heap. Maybe this would do
Tim Docker 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' = do { x <- m; xs <
On Wed, Sep 21, 2011 at 3:39 AM, Heinrich Apfelmus
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 returning the
> list of resul
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
> c
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:
-
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]
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_ applyAc