#6102: Subclass Specialization in Rewrite Rules
---------------------------------+------------------------------------------
    Reporter:  SamAnklesaria     |       Owner:  SamAnklesaria   
        Type:  feature request   |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.4.1           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown


Comment:

 Correct, and I see no way to avoid this.  Consider
 {{{
 foo :: ClassOne a => a -> a
 foo x = classOneOp (classOneOp a)
 }}}
 Imagine firing rule "wontcompile" on the source code.  You'd get:
 {{{
 foo :: ClassOne a => a -> a
 foo x = classTwoOp (classTwoOp a)
 }}}
 But that's ill-typed!  `classTwoOp` needs `(ClassTwo a)` and that simply
 isn't available in `foo`.

 However THIS should work:
 {{{
 "wontcompile"      forall i. classOneOp i = classTwoOp i :: ClassInstance
 }}}
 Note the signature, so that the rule fires only when specialised to
 `ClassInstance`.

 But it still doesn't:
 {{{
 T6102.hs:19:45:
     Could not deduce (ClassTwo ClassInstance)
       arising from a use of `classTwoOp'
     from the context (ClassOne ClassInstance)
       bound by the RULE "wontcompile" at T6102.hs:19:1-73
     Possible fix:
       add an instance declaration for (ClassTwo ClassInstance)
     In the expression: classTwoOp i :: ClassInstance
     When checking the transformation rule "wontcompile"
 }}}
 That's a bug. I'll look at it.

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