27 Nov 2012 11:59
Proposal: Add Eq instance for Control.Exception.ErrorCall
Simon Hengel <sol <at> typeful.net>
2012-11-27 10:59:05 GMT
2012-11-27 10:59:05 GMT
Hi, 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") But I think it can be useful in other situations and it is consistent with the fact that other common exception types have an Eq instance (e.g. ArithException, IOException, ExitCode). Discussion period: 3 Weeks Cheers, Simon [1] http://hspec.github.com/
Having said that you might assist the users of hspec by
providing variants of shouldThrow, say shouldCallError, that matches error
messages. Additionally I would add a DEPRECATE pragma to shouldCallError
with a message that tells the programmer that he should think twice.
RSS Feed