New flag to disable warning on incomplete pattern matches in lambdas
The distinction between -fwarn-simple-patterns and -fwarn-incomplete-patterns was eliminated in September 2010 (http://darcs.haskell.org/cgi-bin/darcsweb.cgi?r=ghc;a=darcs_commitdiff;h=20100922133934-1287e-6ae16bafe86ad0941286982f3bf593377f081384.gz).
I really like -fwarn-incomplete-patterns: it is a great bug finding tool. However, I find that whenever I decompose a value using a lambda-bound pattern I never want a warning. After all, lambdas-patterns cannot choose between several different possibilities, so by using the lambda syntax I'm fairly explicitly signalling that I only expect to get that one possibility at runtime.
One situation where this gets really annoying is when decomposing a value into some holes and a way to rebuild the value around new values for those holes. Consider:
decompose :: Term -> ([Term], [Term] -> Term)
decompose e = case e of
Var x -> ([], \[] -> Var x)
Value (Lambda x e) -> ([e], \[e'] -> Value (Lambda x e')))
...
I "know" that the lambda should never fail to match, but with -fwarn-incomplete-patterns I now get tons of spurious warnings about the apparently incomplete patterns. This noise is drowning out genuine situations where I may have unintentionally missed a possibility, such as in "case" expressions.
In short, I would really like a flag to turn off incomplete pattern match warnings for lambdas (and probably pattern bindings as well, though I don't use those so often). If this flag is on, anywhere where I (the programmer) have used pattern matching syntax that cannot dispatch over multiple possibilities should ""not"" elicit incomplete pattern match warnings.
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |