这种"派生newtype"语法是什么



从一篇博客文章中,我读到了

-- | 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扩展。

相关内容

最新更新