
At 2002-05-14 03:57, Simon Marlow wrote:
It turns out that the compiler "bug" is really just the compiler being a bit loose with the IO monad - it freely translates the original definition of evaluate using 'seq' into the slightly less strict version by pushing the 'seq' through the state lambda of the IO monad (this only happens for the IO monad, and strictly speaking it's a deviation from the semantics but it has important performance benefits for IO code).
Under what circumstance would the compiler do this to my code? I really need to know about any deviation from the semantics.
so your catch can be defined in terms of the current catch like so:
catch' a h = a `seq` (catch a h)
Oh yeah.
what's the motivation for this change?
Well I think it's more intuitive. The documentation (sec. 5.12.3) says this: The simplest version is catch. It takes a single argument, runs it, and if an exception is raised the "handler" is executed passing the value of the exception. Otherwise, the result is returned as normal. ...leading to the question, how do you 'run' bottom? But since I can do what I want with your "catch'" function, it's not really that important. -- Ashley Yakeley, Seattle WA