Skip to content

Allow manually specifying description of contramapped Predicate #17

@brandonchinn178

Description

@brandonchinn178

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 says in a property: ...
  • with says property 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions