`-Wincomplete-patterns` on patterns with general types
Summary
say I have a pattern
pattern Foo :: a
pattern Foo <- _unused
where Foo = undefined
{-# complete Foo #-}
now, everywhere I import the module this pattern is defined in, this results in -Wincomplete-patterns
to propose to match on this pattern. This is problematic, because this even gets proposed if the pattern itself is not imported and it basically ruins the warning.
It would be nice if GHC would not propose patterns if they don't belong to the type, which seems to be a very general notion, but I think there's a nice heuristic that would make this possible, namely, checking whether the outermost type is a type variable, e.g.
pattern A :: Maybe a
pattern B :: f a
where A
would be proposed for a pattern of type Maybe Int
, B
, however, wouldn't.
What do you think about this?