typetetris
typetetris

Reputation: 4867

What is this `deriving newtype` syntax?

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.

Upvotes: 6

Views: 632

Answers (1)

snak
snak

Reputation: 6703

It lets GHC use GeneralizedNewtypeDeriving strategy to derive instances. You need to enable DerivingStrategies extension.

Upvotes: 8

Related Questions