accumulate description while matching
authorJoey Hess <joeyh@joeyh.name>
Tue, 25 Jul 2023 16:41:59 +0000 (12:41 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 25 Jul 2023 16:53:05 +0000 (12:53 -0400)
commit0f63374be35a4edac3339bcc24198140417b3535
tree1db80d757d8eec8d83fca67ae33d4c10752e82a0
parent7333104fd9624c607f4a1b50d14ece2e5ed54491
accumulate description while matching

This is to be used to explain why something did or didn't match.

Note that this reimplements match in terms of matchMrun.
Implementing match' as a Writer and matchMrun' as a MonadWriter
resulted in nearly identical implementations, which collapsed into the
same thing thanks to Writer being WriterT Identity.

MAnd and MOr implement short circuiting. So an expression
like "not (foo and bar)" will be explained as [MatchedNot, MatchOperation "foo"]
when foo does not match; whether bar matches is irrelevant. Similarly
"foo or bar" will be explained as [MatchedOperation "foo"] when foo
matches. It seems like that will keep the explanations more
understandable. But also, matchMrun already did short circuiting, and it
could be considerably more work to check if bar matches in these cases.

Note that the type signature of matchMrun changed, but it was
over-generic before.

Note that these changes are licensed under the AGPL. Changed module
license accordingly.

Sponsored-by: Dartmouth College's DANDI project
Utility/Matcher.hs