[Haskell-cafe] stack overflow pain

Bas van Dijk v.dijk.bas at gmail.com
Wed Sep 21 17:58:55 CEST 2011


On 21 September 2011 17:32, Felipe Almeida Lessa <felipe.lessa at gmail.com> wrote:
> On Wed, Sep 21, 2011 at 6:04 AM, Ketil Malde <ketil at malde.org> wrote:
>> Tim Docker <tim at 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 heap.  Maybe this would do the trick:
>
> mapM' f = go []
>  where
>    go acc [] = return (reverse acc)
>    go acc (a:as) = do {x <- a; go (x:acc) as}
>
> HTH,
>
> --
> Felipe.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

I think that's indeed the problem. It reminds me of bug:
http://hackage.haskell.org/trac/ghc/ticket/5042
There the fix was also to accumulate results on the heap.

Bas



More information about the Haskell-Cafe mailing list