#5224: Improve consistency checking for family instances
---------------------------------+------------------------------------------
    Reporter:  simonpj           |        Owner:                              
        Type:  bug               |       Status:  new                         
    Priority:  highest           |    Milestone:  7.2.1                       
   Component:  Compiler          |      Version:  7.0.3                       
    Keywords:                    |     Testcase:                              
   Blockedby:                    |   Difficulty:                              
          Os:  Unknown/Multiple  |     Blocking:                              
Architecture:  Unknown/Multiple  |      Failure:  Compile-time performance bug
---------------------------------+------------------------------------------

Comment(by simonpj):

 The problem here is the the (necessary) eager check for type-function
 overlap.  This is causing interface files to be read (ones that contain
 type instance declarations) that would not previously have been read.

 I have two ideas.

 First, many type function instances have the form
 {{{
 module X where
 import M(F)
 data T a = ...
 type instance F (T a) = ...
 }}}
 Can another instance of F overlap with this?  Yes in principle:
 {{{
 type instance F a = ...
 }}}
 But '''suppose we don't allow type variables in (all) the index positions
 of a type function'''.  After all, such a type instance would make the
 family degenerate to a synonym, and you could never declare any other
 instances!

 With that restriction we know that you can only overlap the type instance
 if you import (transitively) M, so you have access to T. So for instances
 of this form we don't need to treat M as an orphan module.

 I think this is a wildly common case, and in particular hits the examples
 in the Prelude.

 Second idea: export a bit more info about the family instance modules,
 namely which type functions they have instances for.  No need to check for
 overlap between `M.hi` which defines instancs for F and `N.hi` which
 defines instances for G.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to