[Haskell-cafe] stack overflow pain

Ketil Malde ketil at malde.org
Wed Sep 21 11:04:07 CEST 2011


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:

  import System.IO.Unsafe (unsafeInterleaveIO)

  :

  mapM' f = sequence' . map f
    where sequence' ms = foldr k (return []) ms
          k m m' = do { x <- m; xs <- unsafeInterleaveIO m'; return (x:xs) }

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list