(Data.Monoid) - Sum 和 Product 同时导出 Bounded 和 Num?

(Data.Monoid) - Sum and Product deriving Bounded and Num at the same time?

Data.Monoid 中:

newtype Sum a = Sum { getSum :: a }
    deriving ( Eq       -- ^ @since 2.01
             , Ord      -- ^ @since 2.01
             , Read     -- ^ @since 2.01
             , Show     -- ^ @since 2.01
             , Bounded  -- ^ @since 2.01
             , Generic  -- ^ @since 4.7.0.0
             , Generic1 -- ^ @since 4.7.0.0
             , Num      -- ^ @since 4.7.0.0
             )

我不明白你怎么能用 IntegerFloat 等在 Sum 上推导出 NumBounded...不是 BoundedProduct 包装器也是如此)。

谢谢!

我相当确定只要 aEq 的实例,这就会使 Sum a 成为(比如说)Eq 的实例。

instance (Eq a) => Eq (Sum a) where ...

其他所有 类。