Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-06 Thread Niklas Hambüchen
Ah, that's enlightening, and a good addition to http://ghc.haskell.org/trac/ghc/ticket/8189 On Sat 07 Sep 2013 04:31:31 JST, Tom Ellis wrote: FYI, rwbarton on Reddit produced a nice answer: http://www.reddit.com/r/haskell/comments/1luan1/strange_io_sequence_behaviour/cc32ec4

Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-06 Thread Tom Ellis
On Wed, Sep 04, 2013 at 04:35:17PM +0100, Tom Ellis wrote: As an addendum to the recent discussion, can anyone explain why main crashes quickly with a stack overflow, whereas main' is happy to print Hi for ages (eventually crashing due to an out of memory condition)? bignum = 100 * 1000

[Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Tom Ellis
As an addendum to the recent discussion, can anyone explain why main crashes quickly with a stack overflow, whereas main' is happy to print Hi for ages (eventually crashing due to an out of memory condition)? bignum = 100 * 1000 * 1000 main = replicateM bignum (return ()) main' =

Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Joe Q
To give a very casual explanation, both mains are of the form do this a bunch of times and return the results. Your first is do nothing and return the ()s, but importantly, it has to execute all those nothings. Your second is print hello a bunch and return the ()s. The list it wants to eventually

Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Joe Q
Er, I seem to have misread and thought you were doing infinite replicateM, so that explanation doesn't completely address your question. That's what I get for reading on a phone! On Sep 4, 2013 4:11 PM, Joe Q headprogrammingc...@gmail.com wrote: To give a very casual explanation, both mains are