[Haskell-cafe] Lazy patterns

Scott Turner 2haskell at pkturner.org
Sat Jun 13 11:49:10 UTC 2015


On 2015-06-10 10:00, Jon Schneider wrote:
> I am trying to understand the lazy patterns as explained at
>
> https://www.haskell.org/tutorial/patterns.html
>
> If I type in the example without putting a ~ round the pattern sure enough
> I do not get an answer as the text says. What I completely fail to
> understand is why there is no CPU usage, increasing memory usage, stack
> overflow or other runtime error before I use ^C to stop it. What is going
> on under the hood ?

If you compile the program to binary before executing, the output is
     progname: <<loop>>
See
http://stackoverflow.com/questions/21505192/haskell-program-outputs-loop
for an explanation of what the ghc runtime has detected. In your case
you're using ghci or runhaskell, which has "optimized" the CPU usage
rather than raise an exception.


More information about the Haskell-Cafe mailing list