Subclass Specialization in Rewrite Rules
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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |