@@ -32,6 +32,8 @@ module Katip.Monadic
3232 , ContextualLogT'
3333 , ContextualLogT
3434 , runContextualLogT
35+ , BlankLogContextT
36+ , runBlankLogContextT
3537 ) where
3638
3739
@@ -202,6 +204,7 @@ newtype ContextualLogT' n m a = ContextualLogT {
202204 , MonadIO
203205 , MonadThrow
204206 , MonadCatch
207+ , MonadMask
205208 , MonadBase b
206209 , MonadState s
207210 , MonadWriter w
@@ -244,7 +247,6 @@ instance (ContextualLog m, Monad m) => ContextualLog (ContextualLogT' m m) where
244247 nsInner <- getNsInner
245248 return $ nsOuter <> nsInner
246249
247−
248250runContextualLogT
249251 :: (Functor m, LogContext a)
250252 => m a
@@ -253,3 +255,44 @@ runContextualLogT
253255 -> m b
254256runContextualLogT lgtr nsgtr m = runReaderT (unContextualLogT m) (liftPayload <$> lgtr, nsgtr)
255257
258+
259+-------------------------------------------------------------------------------
260+-- | Type analogous to IdentityT that provides an empty log
261+-- context. Use this if your root monad doesn't have a LogContext instance.
262+newtype BlankLogContextT m a = BlankLogContextT {
263+ runBlankLogContextT :: m a
264+ } deriving ( Functor
265+ , Applicative
266+ , Monad
267+ , MonadIO
268+ , MonadThrow
269+ , MonadCatch
270+ , MonadMask
271+ , MonadBase b
272+ , MonadReader r
273+ , MonadState s
274+ , MonadWriter w
275+ , MonadError e
276+ , MonadPlus
277+ , MonadFix
278+ , Katip
279+ )
280+
281+instance Monad m => ContextualLog (BlankLogContextT m) where
282+ getLogContexts = return mempty
283+ getNamespace = return mempty
284+
285+instance MonadTrans BlankLogContextT where
286+ lift = BlankLogContextT
287+
288+instance MonadTransControl BlankLogContextT where
289+ type StT BlankLogContextT a = a
290+ liftWith f = BlankLogContextT $ f runBlankLogContextT
291+ restoreT = BlankLogContextT
292+ {-# INLINABLE liftWith #-}
293+ {-# INLINABLE restoreT #-}
294+
295+instance (MonadBaseControl b m) => MonadBaseControl b (BlankLogContextT m) where
296+ type StM (BlankLogContextT m) a = ComposeSt BlankLogContextT m a
297+ liftBaseWith = defaultLiftBaseWith
298+ restoreM = defaultRestoreM