Matcher: `matchSimply` should call `matchWrapper`
I don't understand why it does its own thing. That it definitely does shows in lacking long-distance information for the coverage checker:
True = True
should not warn (or at least could), but it sure does:
test3.hs:8:1: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: False
|
8 | True = True
| ^^^^^^^^^^^
For a different example, consider this beauty:
data SBool (b :: Bool) where
STrue :: SBool True
SFalse :: SBool False
STrue = SFalse
warns with
test3.hs:14:1: warning: [-Woverlapping-patterns]
Pattern match has inaccessible right hand side
In a pattern binding: STrue = ...
|
14 | STrue = SFalse
| ^^^^^^^^^^^^^^
test3.hs:14:1: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: SFalse
|
14 | STrue = SFalse
| ^^^^^^^^^^^^^^
Both inaccessible RHS and incomplete. But the first warning should actually be redundant (Edit: Actually, no. It certainly forces the matched thing, so inaccessible)! Yet the coverage can't see that, as matchSimply
doesn't pass on the long-distance info for the RHS, so it's equivalent to seeing STrue = x
.
This refactoring would also allow us to get rid of PmCheck.checkSingle
, which is a curious function already. I believe it's only really doing something for PatBindRhs
anyway. Seems like an awfully special case for no obvious reason.