[Haskell-beginners] HUnit - testing for failed pattern match

Edward Z. Yang ezyang at MIT.EDU
Wed Feb 23 00:35:38 CET 2011


What you describe is one of the cases when a partial function is ok
(though it's probably better to do something like:

giveMeThree x
| x == 3 = True
| otherwise = error "giveMeThree: not three"

It's frequently not possible, but if you can arrange your types so that
the invalid values are not possible, even better.)

Cheers,
Edward



More information about the Beginners mailing list