从我读到的一篇博客文章中
-- | Newtype for disabling logging
newtype NoLoggingT m a
= NoLoggingT { runNoLoggingT :: m a }
deriving newtype (Functor, Applicative, Monad)
deriving (MonadTrans) via IdentityT
instance Monad m => MonadLog (NoLoggingT m) where logLn _ _ = pure ()什么是deriving newtype语法?它是哪个扩展,它是做什么的?请在anwser中提供其文档的链接。
发布于 2020-08-12 15:07:12
它允许GHC使用GeneralizedNewtypeDeriving策略来派生实例。您需要启用DerivingStrategies扩展。
https://stackoverflow.com/questions/63371148
复制相似问题