Allow manually specifying description of contramapped Predicate
brandonchinn178 opened this issue · comments
Currently, contramap
, with
, and qWith
are all ways to preprocess the value before passing the value to the next Predicate. But they all update the description with a hardcoded method:
contramap
saysin a property: ...
with
saysproperty at Foo.hs:1:1: ...
qWith
says<funcname>: ...
This might be fine in most cases, but it can get pretty weird with things like contains
:
ghci> explain (contains $ $(qWith [| abs |]) (gt 5)) [2 :: Int]
"all elements abs: ≤ 5"
it'd be nice to do something like
>>> explain (contains $ withAs "after absolute value " abs (gt 5)) [2 :: Int]
"all elements after absolute value ≤ 5"
Also, related, there's no way to contramap without changing the explanation. (IMO, contramap
shouldn't change the message at all, but maybe that's a separate discussion). This could be useful for things like unwrapping newtypes.