有了量化的约束,我可以Eq (A f)很好地推导出来吗?但是,当我尝试推导 Ord (A f) 时,它失败了。当约束类具有超类时,我不明白如何使用量化约束。我如何派生Ord (A f)和其他具有超类的类?
> newtype A f = A (f Int)
> deriving instance (forall a. Eq a => Eq (f a)) => Eq (A f)
> deriving instance (forall a. Ord a => Ord (f a)) => Ord (A f)
<interactive>:3:1: error:
• Could not deduce (Ord a)
arising from the superclasses of an instance declaration
from the context: forall a. Ord a => Ord (f a)
bound by …Run Code Online (Sandbox Code Playgroud)