#2203: TFs in class instances heads
-------------------------------------+--------------------------------------
 Reporter:  chak                     |          Owner:  chak       
     Type:  bug                      |         Status:  new        
 Priority:  normal                   |      Milestone:  6.10 branch
Component:  Compiler (Type checker)  |        Version:  6.9        
 Severity:  normal                   |     Resolution:             
 Keywords:                           |     Difficulty:  Unknown    
 Testcase:  T2203a                   |   Architecture:  Multiple   
       Os:  Multiple                 |  
-------------------------------------+--------------------------------------
Comment (by claus):

 Replying to [comment:3 chak]:
 > I fixed the first half of ticket (ie, disallow family synonym
 applications in instance heads).

 This is an interesting case, considering this type family application
 desugaring:
 {{{
 type family F a
 forall a . .. F a .. === forall a . F a ~ b => .. fa ..
 }}}

 At first glance, your fix seems to deny this equivalence (right hand side
 valid, left hand side invalid) but on further consideration, that isn't
 actually the case.
 The missing piece is the location of the constraint resulting from the
 desugaring.
 {{{
 type family F a
 instance Context => Class a (F a) -- 1
 }}}
 should desugar to
 {{{
 type family F a
 instance Context => Class a (F a~fa => fa) -- 2
 }}}
 but there is no valid place to put that constraint in the instance head,
 so ruling out the sugared form (1) makes sense. Moreover,
 {{{
 type family F a
 instance (Context,F a~fa) => Class a fa -- 3
 }}}
 is not a desugaring of (1): (1), if it were valid, would restrict instance
 selection (other instance heads might match), whereas (3) restricts
 instance validity (this instance head always matches, but its context
 might not be satisfiable).

 (just a note to self, and other interested parties who might find this
 ticket resolution confusing at first)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2203#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