documentation (and naming) of -Woverlapping-patterns
(low priority, but still ...)
https://downloads.haskell.org/ghc/latest/docs/html/users_guide/using-warnings.html#ghc-flag--Woverlapping-patterns uses the concept "set of patterns is overlapping" without defining it.
I thought the common meaning of "overlapping" is "not disjoint" (some two elements of the set have non-empty intersection), so
f True y = () ; f x True = ()
looks overlapping to me, because of the common instance f True True
. I tend to write disjoint
patterns, so I never noticed that GHC would not catch this.
Instead, GHC's warning is for "at least one pattern is completely contained in the union of some earlier ones". I'd call such a pattern "redundant", and the docs also do (later), and GHC does:
Prelude> f x y = () ; f x True = ()
<interactive>:11:19: warning: [-Woverlapping-patterns]
Pattern match is redundant
Note that the name of the warning is not the name of the error.
Perhaps replace the text in the docs with "GHC warns if a pattern is redundant/unreachable because all its instances are (covered by)/(contained in) earlier patterns". (And not mention "overlap".)
Or change "covered" to "completely overlapped", so that the option's name appears.
Exact wording is tricky. The Standard uses "funlhs" and "pat", and does not discuss overlaps.
(And, is there -Wnon-disjoint-patterns
? I guess I would want that as a default.)