BSD-3-Clause licensed and maintained by Chris Smith
This version can be pinned in stack with:explainable-predicates-,3784

Module documentation for

explainable-predicates - Predicates that can explain themselves

CI Hackage

Explainable predicates are essentially functions from types to Bool which can additionally describe themselves and explain why an argument does or doesn’t match. They are intended to be used during unit tests to provide better error messages when tests fail. For example, if a collection is missing an element, an explainable predicate can tell you which element is missing.


Here are a few tips for making the most of explainable-predicates.

Which GHC versions are supported?

explainable-predicates is tested with GHC versions from 8.6 through 9.4.


Revision history for explainable-predicates – 2021-09-18

  • Version bounds now allow GHC 9.4 – 2021-12-20

  • Better error messages for HUnit integration. – 2021-12-20

  • Builds with GHC 9.2.1 – 2021-09-25

  • HUnit and Hspec integration is now available in Test.Predicates.HUnit. – 2021-09-25

  • Predicate now has a Contravariant instance.
  • ==~ is an infix synonym for accept.
  • Cabal regex and containers flags (default true) enable regex and container predicates, respectively.
  • Cabal dev flag (default false) turns GHC warnings into errors.
  • The inBranch and qADT combinators are now available for more convenient matching of algebraic data types and fields.
  • QuickCheck integration is now available in Test.Predicates.QuickCheck. – 2021-09-18

  • First version. Released on an unsuspecting world.