[GHC] #4905: New flag to disable warning on incomplete pattern matches in lambdas

GHC cvs-ghc at haskell.org
Wed Jan 19 23:27:26 CET 2011


#4905: New flag to disable warning on incomplete pattern matches in lambdas
---------------------------------+------------------------------------------
    Reporter:  batterseapower    |       Owner:              
        Type:  feature request   |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  7.0.1             |    Keywords:              
    Testcase:                    |   Blockedby:              
          Os:  Unknown/Multiple  |    Blocking:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4905>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list