{-# OPTIONS_GHC -Wincomplete-uni-patterns #-}
foo :: [a] -> [a]
foo [] = []
foo xs = ys
where
(_, ys@(_:_)) = splitAt 0 xs
main :: IO ()
main = putStrLn $ foo $ "Hello, coverage checker!"
Instead of saying
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding: Patterns not matched: (_, [])
We now say
ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘([a], [a])’ not matched:
([], [])
((_:_), [])
E.g., newer versions do (one) case split on pattern variables that haven't even been scrutinised by the pattern match. That amounts to quantitatively more pattern suggestions and for each variable a list of constructors that could be matched on.
The motivation for the change is outlined in
https://gitlab.haskell.org/ghc/ghc/-/issues/20642#note_390110, but I could easily be swayed not to do the case split. Which arguably is less surprising, as Andreas Abel points out.
Considering the other examples from my post, which would you prefer?
Cheers,
Sebastian