
This is bizarre: the definition of evaluate in Exception is exactly the one you gave above, yet they behave differently. You may have uncovered a compiler bug, I'll look into it.
I might ask which is correct: according to the rules for seq, "evaluate' undefined" should be bottom, but we want "Expression.evaluate undefined" to be a failing IO action.
I think the compiler is correct but the definition given in the documentation is wrong.
Well, given the compiler is compiling the definition from the documentation and giving the wrong semantics, I'd say the compiler is definitely wrong :-) But the question of whether Exception.evaluate should have a different semantics is interesting. So to be clear about this, there are three possible definitions of evaluate: evaluate a = return a -- not strict enough evaluate a = a `seq` return a -- too strict (?) evaluate a = IO $ \s -> a `seq` (# s, a #) -- just right :) I had to write out the third one in full, because we don't have any combinators that provide this functionality elsewhere (at least, I can't think of any). I must admit I can't think of any compelling reasons for the change, other than the fact that this is functionality that we don't have at the moment, and therefore might be useful. Opinions? Cheers, Simon
participants (1)
-
Simon Marlow