
On Tue, Nov 27, 2012 at 1:12 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Tue, 27 Nov 2012, Simon Hengel wrote:
I propose to add an Eq instance for ErrorCall. The main motivation is
to make it more convenient to construct predicates that select specific exceptions.
My current use case is testing for expected exceptions. In Hspec[1] we use predicates for that, e.g.:
evaluate (head []) `shouldThrow` (== ErrorCall "Prelude.head: empty list")
If this is an actual use case, then there is something very wrong. Handling non-empty lists can be done cleanly using various non-empty list types. Or you avoid 'head' by using 'case' or 'viewL'. If instead you plan to catch something then you should use Either, ExceptionalT, ErrorT or IO exceptions. I am afraid that an Eq instance for ErrorCall promotes the abuse of 'error'.
+1 on the proposal. Even if I'm opposed to partial functions, I'm in favor of making it easier to test them reliably. Michael