#4981: inconsistent class requirements with TypeFamilies and FlexibleContexts
---------------------------------+------------------------------------------
    Reporter:  ganesh            |       Owner:                           
        Type:  bug               |      Status:  new                      
    Priority:  normal            |   Component:  Compiler (Type checker)  
     Version:  7.0.1             |    Keywords:                           
    Testcase:                    |   Blockedby:                           
          Os:  Unknown/Multiple  |    Blocking:                           
Architecture:  Unknown/Multiple  |     Failure:  GHC rejects valid program
---------------------------------+------------------------------------------
Changes (by dimitris):

  * component:  Compiler => Compiler (Type checker)


Comment:

 Right, I know what's going on. The problem we are solving is:
 {{{
   [Given] Conflict (OnPrim p),
      + its superclass: [Given] (PatchInspect (PrimOf (FL (OnPrim p))))
   [Given]  PrimOf (OnPrim p) ~ WithName (PrimOf p)
   [Wanted] Conflict (FL (OnPrim p))
 }}}
 Now, we apply the instance to get new work:
 {{{
   [Wanted] Conflict (OnPrim p)
   [Wanted] PatchInspect (PrimOf (FL (OnPrim p)))
 }}}
 The second guy is the "silent parameter" wanted. Now, the Conflict wanted
 can be
 readily discharged so let's not worry about him. However:
 {{{
   [Wanted] PatchInspect (PrimOf (FL (OnPrim p))) ~~>
                  [Wanted] PatchInspect (PrimOf (OnPrim p))
 }}}
 Now, this ''could'' be readily discharged by the given but instead what
 happens
 is that it gets rewritten with the given equality to:
 {{{
        [Wanted] PatchInspect (WithName (PrimOf p))
 }}}
 Then the instance triggers, and we get:
 {{{
        [Wanted] PatchInspect (PrimOf p)
 }}}
 which is the error we see.

 So indeed this program is in muddy territory where givens (superclasses of
 givens, actually!) overlap with top-level instances.

 I know why GHC is not picking the given up: it has to do with the fact
 that we have
 not saturated all possible equalities before we look for instances, but
 luckily this
 is something Simon and I are planning to fix pretty soon. The other thing
 that we should also do is remove these silent superclass parameters --
 they used to exist
 for reasons related to recursive dictionaries but they are not necessary
 any more
 the way we have dealt with recursive dictionaries at the end.

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