[GHC] #13092: family instance consistency checks are too pessimistic

GHC ghc-devs at haskell.org
Tue Jan 10 10:44:35 UTC 2017


#13092: family instance consistency checks are too pessimistic
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                Owner:  rwbarton
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Actually there is ''some'' justification for the status quo.  Here it is:

 * If A imports B, and A has `type instance F Int = Bool` and B has `type
 instance F Int = Char`, then any attempt to use `F Int`, in A or in any
 module A imports, will get a "overlapping instance" error on lookup.  I
 think.  So the conflict would be reported, but lazily.

 * In contrast, if A imports B and C, and B and C have those instance
 declarations, then compiling A might never need to reduce `F Int`, so we
 must eagerly check for consistency.

 I'm intrigued about how you managed to write `unsafeCoerce`.

 But regardless, I think it'd be better and more consistent to eagerly
 check consistency of all the new family instances in A with all those in
 modules it imports.  Then instance lookup should never find more than one
 match.

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


More information about the ghc-tickets mailing list