
Dan Weston wrote:
foldl (+) 0 [1..10000000] :: Integer *** Exception: stack overflow foldl' (+) 0 [1..10000000] :: Integer 50000005000000
I thought both of these were perfectly well defined in denotational semantics (and equal to 50000005000000). The first is merely a failure of one person's computer to implement the (perfectly well-defined) denotational semantics of the program.
Quite. It's slightly confusing that a stack overflow manifests in the same way as an exception that indicates _|_, such as error or divide by zero. It's exactly the same as if you'd pressed Control-C during the first evaluation. That doesn't cause the expression to have value _|_, but it does raise an exception. The type of the exception is some help: StackOverflow is a constructor in the AsyncException datatype, indicating that it was an asynchronous exception. Evaluating the expression again might yield a result. Cheers, Simon