
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 vs
and someOtherAction seems not to be run. However, to be sure, I'll confirm with code akin to what you suggest above.
I suspect that `applyAction x' produces a large thunk for several x in sas, and those blow the stack. You could try forcing evaluation earlier, mapM' :: (a -> IO [b]) -> [a] -> IO [b] mapM' act (m:ms) = do xs <- act m yss <- length xs `seq` mapM' act ms return (xs ++ yss) mapM' _ [] = return [] perhaps even forcing the values of xs (deepseq, if b is an NFData instance). Depending on what your actual problem is, that could help or make it worse.