From a blog post I read
-- | 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 ()
What is thas deriving newtype
syntax?
Which extension is it and what does it do?
Please provide a link to its documentation in the anwser.
DerivingVia
as a "GeneralizedGeneralizedNewtypeDeriving
":deriving newtype (F, A, M)
can be replaced withderiving (F, A, M) via m
. I do not recommend it in practice (always usederiving newtype
when you are deriving via the underlying representation of anewtype
) but nevertheless good to understand it as a special case of another feature. – Loralorain