Nic*_*nin 2 haskell typeclass monoids deriving
in 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
)
Run Code Online (Sandbox Code Playgroud)
I don't understand how you could derive Num and Bounded on Sum with Integer, Float etc... which are naturally not Bounded (it's the same story for the Product wrapper).
Thanks!
我很确定Sum a,Eq只要a是的实例,它就成为(说)的实例Eq。
instance (Eq a) => Eq (Sum a) where ...
Run Code Online (Sandbox Code Playgroud)
对于其他所有类也是如此。
| 归档时间: |
|
| 查看次数: |
68 次 |
| 最近记录: |