I'm refactoring some old code, which is in a polymorphic, but type-class constrained, monad:
class ( MonadIO m
, MonadLogger m
, MonadLoggerIO m
, MonadThrow m
, MonadCatch m
, MonadMask m
, MonadBaseControl IO m
, MonadUnliftIO) => HasLogging m where
In the older code the application's main monad was...
type AppM = ReaderT Env IO
...which will now change to...
newtype AppM (features :: [FeatureFlag]) a = AppM (ReaderT Env IO a)
deriving (Functor, Applicative, Monad, MonadReader Env, MonadIO)
Given this context, is it safe to derive the following, automatically:
- MonadThrow
- MonadCatch
- MonadMask
- MonadBaseControl
- MonadUliftIO
Without getting into GHC internals, what's the best way to develop intuition about what's actually happening when the compiler derives things automagically?
DerivingVia
:newtype AppM features a = AppM (Env -> IO a) deriving (Functor, Applicative, Monad, MonadReader Env, MonadIO) via ReaderT Env IO
– Humid