[GHC] #14045: Data family instances must list all patterns of family, despite documentation's claims to the contrary

GHC ghc-devs at haskell.org
Sat Jul 29 15:32:14 UTC 2017


#14045: Data family instances must list all patterns of family, despite
documentation's claims to the contrary
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.3
  checker)                           |
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #12369            |  Differential Rev(s):  Phab:D3804
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Richard Eisenberg <rae@…>):

 In [changeset:"d1ef223cfebd23c25489a4b0c67fbaa2f91c1ec6/ghc"
 d1ef223c/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="d1ef223cfebd23c25489a4b0c67fbaa2f91c1ec6"
 Fix #14045 by omitting an unnecessary check

 Previously, we checked the number of patterns in a data instances
 for all data families whose kind did not end in a kind variable.
 But, of course, undersaturating instances can happen even without
 the kind ending in a kind variable. So I've omitted the arity check.
 Data families aren't as particular about their arity as type families
 are (because data families can be undersaturated). Still, this change
 degrades error messages when instances don't have the right arity;
 now, instead of reporting a simple mismatch in the number of patterns,
 GHC reports kind errors. The new errors are fully accurate, but perhaps
 not as easy to work with. Still, with the new flexibility of allowing
 data family instances with varying numbers of patterns, I don't see
 a better way.

 This commit also improves source fidelity in some error messages,
 requiring more changes than really are necessary. But without these
 changes, error messages around mismatched associated instance heads
 were poor.

 test cases: indexed-types/should_compile/T14045,
             indexed-types/should_fail/T14045a
 }}}

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


More information about the ghc-tickets mailing list