Pattern match exhaustivity warnings for overloaded lists are weirdly redundant
Consider the following program:
{-# OPTIONS_GHC -Wincomplete-patterns #-}
{-# LANGUAGE OverloadedLists #-}
module Weird where
import Data.Sequence
f :: Seq Int -> ()
f [0] = ()
This elicits the following warnings:
Tmp.hs:9:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘f’:
Patterns not matched:
_
_
_
|
9 | f [0] = ()
| ^^^^^^^^^^
This is really unhelpful. I imagine the same applies to view patterns and guards, since they all share the translation to the same PmGrd
construct. I'd rather expect it to generate a warnings like
Tmp.hs:9:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘f’:
Patterns not matched:
[]
[p] where p is not one of {0}
(_:_:_)
|
9 | f [0] = ()
| ^^^^^^^^^^
... but this is of course all implicitly under the toList
view pattern. We don't have the problem for overloaded strings, because we represent them as actual literals. We can't do the same for overloaded lists, because they actually might contain nested matches.
Whatever the solution is here, it could also be applied to overloaded literals and overloaded strings instead of the current mechanism which represents them as a special kind of literal.
This came from the warnings from T11822
which seems to suffer from this in a very dreadful way.