Spurious [-Woverlapping-patterns] -- [cont] ghc should be able to deduce correct use of partial functions
Anthony Clayden <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <CABU_mxjtmF67s2S0fHrjwP9XjOo-8BWfoW1303HX-J1FE60N2g@mail.gmail.com> |
I think this is a similar 'failure to deduce' partiality as last week's
thread; but the other way round (and with ViewPatterns) -- at GHC 8.10.7:
GHCi> :set -XViewPatterns
GHCi> :set -Wincomplete-patterns -- also warns overlapping
GHCi> (\x -> case x of {((\(Just j) -> j) -> j2) -> j2; Nothing -> 'N'})
Nothing
===> <interactive>: warning: [-Woverlapping-patterns]
Pattern match is redundant
In a case alternative: Nothing -> ...
*** Exception: <interactive>:16:21-34: Non-exhaustive patterns in lambda
(Same Warning then same Exception if I compile the code.)
So GHC isn't smart enough, despite the explicit `(\(Just j) -> ...)`, to
see that ViewPattern usage is incomplete?
I thought ViewPatterns got desugarred into clunky chains of nested `case`s,
so that the pattern coverage checker could see what's going on? I was
testing this because if anything I expected it to report coverage was
incomplete.
To get both a claim "Pattern match is redundant" and "Non-exhaustive" seems
particularly unhelpful.
AntC
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.