GHC doesn't detect trivial complete pattern with the combination of ExistentialQuantification and ViewPatterns
This program exhibits the behaviour:
{-# LANGUAGE ViewPatterns, ExistentialQuantification #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
data Moo = Moo (Char -> Int)
spqr (Moo _) = undefined -- Exhaustive pattern
foo (id -> Moo _) = undefined -- Exhaustive pattern
data Exists = forall a. Exists (a -> Int)
bar (Exists _) = undefined -- Exhaustive pattern
baz (id -> Exists _) = undefined -- "Warning: Pattern match(es) are non-exhaustive"
GHCs output is puzzling:
$ ghc -c Exhaustive.hs
Exhaustive.hs:11:0:
Warning: Pattern match(es) are non-exhaustive
In the definition of `baz': Patterns not matched: _
It can detect exhaustivity if you use either existentials OR view patterns by themselves, but not with the combination of the two together. Weird!
Trac metadata
Trac field | Value |
---|---|
Version | 6.12.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |