Closed jonathanknowles closed 1 year ago
This might actually be a problem with the Monus
instance for Maybe
, rather than being specific to Maybe (Sum Natural)
.
I can also reproduce the issue when testing with values of Maybe ()
:
> a = Just ()
> b = Just ()
> (<\>) a b == flip stripPrefixOverlap a b
False
> (<\>) a b == flip stripSuffixOverlap a b
False
> (<\>) a b
Just ()
> flip stripPrefixOverlap a b
Nothing
> flip stripSuffixOverlap a b
Nothing
I believe I've found a fix for this issue here https://github.com/blamario/monoid-subclasses/pull/39.
Fixed by @jonathanknowles
Hi @blamario
I think I've discovered a counterexample to the
Monus
laws forMaybe
.I tested against the latest version of
monoid-subclasses
in this repository: 9255072c640f590c92c9ebc9ddc153555501dad7Counterexample
First some imports:
Then define the counterexample arguments:
The laws stated in the documentation are as follows (source):
(<\>) = flip stripPrefixOverlap
(<\>) = flip stripSuffixOverlap
When we test these laws with the example arguments, it seems that the laws are not satisfied:
If we evaluate just the LHS, we get:
If we evaluate just the RHS, we get:
Perhaps I've interpreted the laws incorrectly?
Many thanks!
Jonathan