[Haskell-cafe] sequence causing stack overflow on pretty small lists

Patrick Palka patrick at parcs.ath.cx
Tue Aug 27 13:37:43 CEST 2013

On Mon, Aug 26, 2013 at 4:46 AM, Niklas Hambüchen <mail at nh2.me> wrote:

> On #haskell we recently had a discussion about the following:
>    import System.Random
>    list <- replicateM 1000000 randomIO :: IO [Int]
> I would think that this gives us a list of a million random Ints. In
> fact, this is what happens in ghci. But with ghc we get:
>    Stack space overflow: current size 8388608 bytes.
>    Use `+RTS -Ksize -RTS' to increase it.
You can use ContT to force the function to use heap instead of stack space,
e.g. runContT (replicateM 1000000 (lift randomIO)) return
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130827/16a60ed3/attachment.htm>

More information about the Haskell-Cafe mailing list