
Quoth Duncan Coutts
You must not do this. It breaks the semantics of the language.
Other people have given practical reasons why you should not but a theoretical reason is that you've defined a non-continuous function. That is impossible in the normal semantics of pure functional languages. So you're breaking a promise which we rely on.
Could you elaborate a little, in what sense are we (?) relying on it? I actually can't find any responses that make a case against it on a really practical level - I mean, it seems to be taken for granted that it will work as intended, and we're down to whether we ought to have such intentions, as a matter of principle. If you've identified a problem here with semantics that would break normal evaluation, from the perspective of the programmer's intention, then this would be the first practical reason? Donn
It is not "safe". It's almost as bad as a function isBottom, which is the canonical non-continuous function. It's defined by:
isBottom _|_ = True isBottom _ = False
Of course your tryArith only tests for certain kinds of _|_ value, but in principle the problem is the same.
It is not safe because it distinguishes values that are not supposed to be distinguishable. This invalidates many properties and transformations.
Duncan