# \[ANN\] explainable-predicates: Predicates that can explain themselves

**URL:** <https://discourse.haskell.org/t/ann-explainable-predicates-predicates-that-can-explain-themselves/3261>\
**Category:** Show and Tell\
**Created:** [September 19, 2021, 1:35am UTC](https://discourse.haskell.org/t/ann-explainable-predicates-predicates-that-can-explain-themselves/3261 "2021-09-19T01:35:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [September 19, 2021, 1:35am UTC](https://discourse.haskell.org/t/ann-explainable-predicates-predicates-that-can-explain-themselves/3261/1 "2021-09-19T01:35:05Z")

</div>

> **[explainable-predicates](https://hackage.haskell.org/package/explainable-predicates)**
>
> Predicates that can explain themselves.

The `explainable-predicates` package provides a `Predicate a` type, which is esssntially "`a -> Bool` that can explain itself." The package provides a quite comprehensive library of 52 combinators for building these explainable predicates, which can accept or reject values, describe themselves, and explain why a specific value does or doesn’t match the predicate. For example, if the predicate requires that a container has specific values in it, then the explanation will tell you which value was missing.

The intended use case is for unit testing, where explanations provide delightfully helpful messages when a test fails. For example, I very much hope that some day, HSpec or a successor library will contain a `shouldSatisfy` function to assert that a value matches a `Predicate` and explain why not. However, it would be very interesting to hear if someone finds other uses for the package, as well!

This was all previously available as part of my HMock library, but I’ve separated it out now so that it can be used separate from HMock.

---

<div class="post-metadata">

**Author:** ![Kleidukos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kleidukos/32/1213_2.png) [@Kleidukos](https://discourse.haskell.org/u/Kleidukos)\
**Post date:** [September 19, 2021, 6:19am UTC](https://discourse.haskell.org/t/ann-explainable-predicates-predicates-that-can-explain-themselves/3261/2 "2021-09-19T06:19:24Z")

</div>

This is looks fantastic, thank you very much 🙂
