sequence causing stack overflow on pretty small lists
bos at serpentine.com
Mon Aug 26 21:05:14 CEST 2013
On Mon, Aug 26, 2013 at 1:46 AM, Niklas Hambüchen <mail at nh2.me> wrote:
> This is because sequence is implemented as
> sequence (m:ms) = do x <- m
> xs <- sequence ms
> return (x:xs)
> and uses stack space when used on some [IO a].
This problem is not due to sequence, which doesn't need to add any
strictness here. It occurs because the functions in System.Random are
excessively lazy. In particular, randomIO returns an unevaluated thunk.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries