警告来自Monoid
实例的定义,该实例可能在代码的后面某个位置,您将其保留了一半。
您可能有类似的东西
instance Monoid Macros where
mempty = Macros [] [] []
但是,由于mappend
是Monoid
的成员,因此您应该写
instance Monoid Macros where
mempty = Macros [] [] []
mappend = (<>)
注意:由于base-4.11(GHC-8.2),mappend
可以省略,因为类型类中有默认定义
class Semigroup => Monoid m where
-- | Identity of 'mappend'
mempty :: a
-- | An associative operation
--
-- __NOTE__: This method is redundant and has the default
-- implementation @'mappend' = '(<>)'@ since /base-4.11.0.0/.
mappend :: a -> a -> a
mappend = (<>)
https://hackage.haskell.org/package/base-4.11.0.0/docs/src/GHC.Base.html#mappend
如果您需要支持多个GHC版本,则可以将mappend = (<>)
留在实例中。
本文链接:https://www.f2er.com/3169408.html