从一篇博客文章中,我读到了
-- | 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中提供其文档的链接。
它允许GHC使用GeneralizedNewtypeDeriving
策略来派生实例。您需要启用DerivingStrategies
扩展。