Ticket #6102 (closed feature request: invalid)
Subclass Specialization in Rewrite Rules
Description
Rewrite rules can define a specialized version of a method for some specific datatype, but they cannot currently define a specialized version of a method for some specific superclass.
class ClassOne a where
classOneOp :: a -> a
class ClassOne a => ClassTwo a where
classTwoOp :: a -> a
data ClassInstance = ...
instance ClassOne ClassInstance where
classOneOp = ...
specialFunc :: ClassInstance -> ClassInstance
specialFunc = ...
{-# RULES
"willcompile" forall i. classOneOp i = specialFunc
"wontcompile" forall i. classOneOp i = classTwoOp i
#-}
Although we can specialize classOneOp for ClassInstance?, we can't do so for those instances of ClassOne? that are also instances of ClassTwo?.
Change History
Note: See
TracTickets for help on using
tickets.
