[GHC] #14547: Wrong warning by -Wincomplete-patterns

GHC ghc-devs at haskell.org
Wed Apr 25 00:29:24 UTC 2018


#14547: Wrong warning by -Wincomplete-patterns
-------------------------------------+-------------------------------------
        Reporter:  YoshikuniJujo     |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:  incomplete-
                                     |  patterns OverloadedLists,
                                     |  PatternMatchWarnings TypeFamilies
Operating System:  Linux             |         Architecture:  x86
 Type of failure:  Incorrect         |            Test Case:
  error/warning at compile-time      |  deSugar/should_compile/T14547
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4624
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by sighingnow):

 During the exhaustiveness checking, we already know the type of `[]`, we
 use `splitListTyConApp_maybe` to check whether it's type is `[a]` (list)
 or not and extract its element type.

 {{{#!hs
 splitListTyConApp_maybe :: Type -> Maybe Type
 splitListTyConApp_maybe ty = case splitTyConApp_maybe ty of
   Just (tc,[e]) | tc == listTyCon -> Just e
   _other                          -> Nothing
 }}}

 Indeed we don't need to know the `toList` of `[]` instance is identity
 function, we know the type of the pattern is `[]` then the `toList` is
 omitted and it is enough to know `[]` is the nil pattern.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14547#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list