Pattern exhaustion checker false-positives on Void branches
import Data.Void
type Alias = Either Void ()
f :: Alias -> IO ()
f i = case i of
Right () -> pure ()
main :: IO ()
main = f (Right ())
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3
$ ghc -Wall Test.hs
[1 of 1] Compiling Main ( Test.hs, Test.o )
Test.hs:6:7: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: (Left _)
|
6 | f i = case i of
| ^^^^^^^^^...
Linking Test ...
The workaround to add Left _ -> error "unreachable"
is not ideal, because later on during development I might want to replace Alias = Either Void ()
with Alias = Either RealThing ()
and then the workaround would hide any instances in the code that need to be updated, to handle RealThing
instead doing error
on Void
.