[#912] Add or, and, or1, and1, not functions for overloaded booleans
Description
Problem: our overloaded booleans don't support some quality of life stuff.
Solution: turned out to be a little tricky.
TL;DR:
- Add negation to overloaded booleans
- Implement negation for TransferFailurePredicate
- Add
BooleanMonoid
type class definingtrue
andfalse
.
We need (1) to be able to define true
and false
in terms of each other in (3), so that downstream could only define one of those if they choose so. We have to do (2) as a direct consequence of (1).
That being said, if we can live with requiring both true
and false
to be defined, we could drop (1) and (2).
Alternative design:
Since conjunction is a monoid wrt True
and disjunction is a monoid wrt False
, instead of defining a single class BooleanMonoid
, we could define two, class BooleanTrue a where true :: a
and class BooleanFalse a where false :: a
. Thus, and
would only need BooleanTrue
constraint, and or
respectively BooleanFalse
.
This seemed more ad-hoc, and deriving instances for two classes instead of one is somewhat annoying, so I didn't go for it, but it's an option.
Related issue(s)
Resolves #912 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.