<div dir="ltr"><div class="gmail_extra">On Mon, Aug 26, 2013 at 4:46 AM, Niklas Hambüchen <span dir="ltr">&lt;<a href="mailto:mail@nh2.me" target="_blank">mail@nh2.me</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

On #haskell we recently had a discussion about the following:<br>
<br>
   import System.Random<br>
<br>
   list &lt;- replicateM 1000000 randomIO :: IO [Int]<br>
<br>
I would think that this gives us a list of a million random Ints. In<br>
fact, this is what happens in ghci. But with ghc we get:<br>
<br>
   Stack space overflow: current size 8388608 bytes.<br>
   Use `+RTS -Ksize -RTS&#39; to increase it.<br>
<br></blockquote><div><br></div><div>You can use ContT to force the function to use heap instead of stack space, e.g. runContT (replicateM 1000000 (lift randomIO)) return</div></div></div></div>