[GHC] #13964: Pattern-match warnings for datatypes with COMPLETE sets break abstraction

GHC ghc-devs at haskell.org
Thu Jul 13 10:02:15 UTC 2017


#13964: Pattern-match warnings for datatypes with COMPLETE sets break abstraction
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1-rc2
      Resolution:                    |             Keywords:
                                     |  PatternSynonyms,
                                     |  PatternMatchWarnings
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by mpickering):

 This is nothing unique to `COMPLETE` pragmas, the exhaustiveness checker
 already breaks abstraction in this way.

 For example:

 {{{
 module T (D(A)) where

 data D = A | B
 }}}

 {{{
 module M where

 import T

 foo A = ()
 }}}

 warns with

 {{{
 M.hs:5:1: warning: [-Wincomplete-patterns]
     Pattern match(es) are non-exhaustive
     In an equation for ‘foo’: Patterns not matched: T.B
   |
 5 | foo A = ()
   |
 }}}

 and after all, to retain safety it has to. A function exported by `T`
 could mention `B` and then be used in `M`.

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


More information about the ghc-tickets mailing list