{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module OTel.API.Baggage.Internal
(
BaggageT(..)
, mapBaggageT
, BaggageBackend(..)
, defaultBaggageBackend
) where
import Control.Applicative (Alternative)
import Control.Exception.Safe (MonadCatch, MonadMask, MonadThrow)
import Control.Monad (MonadPlus)
import Control.Monad.Base (MonadBase)
import Control.Monad.Cont (MonadCont)
import Control.Monad.Except (MonadError)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.IO.Unlift (MonadUnliftIO)
import Control.Monad.Logger (MonadLogger)
import Control.Monad.RWS.Class (MonadRWS)
import Control.Monad.Reader (MonadReader(ask, local, reader))
import Control.Monad.State (MonadState)
import Control.Monad.Trans.Class (MonadTrans(lift))
import Control.Monad.Trans.Control (MonadTransControl(..), MonadBaseControl)
import Control.Monad.Trans.Reader (ReaderT(..))
import Control.Monad.Trans.Resource (MonadResource)
import Control.Monad.Writer.Class (MonadWriter)
import Data.Kind (Type)
import Data.Monoid (Ap(..))
import OTel.API.Baggage.Core (MonadBaggage(..), Baggage, contextBackendBaggage)
import OTel.API.Context (ContextT(..), ContextBackend, attachContextValue, getAttachedContextValue)
import OTel.API.Trace.Core (MonadTracing, MonadTracingIO)
import Prelude
#if MIN_VERSION_mtl(2,3,0)
import Control.Monad.Accum (MonadAccum)
import Control.Monad.Select (MonadSelect)
#endif
type BaggageT :: (Type -> Type) -> Type -> Type
newtype BaggageT m a = BaggageT
{ forall (m :: * -> *) a. BaggageT m a -> BaggageBackend -> m a
runBaggageT :: BaggageBackend -> m a
} deriving
( Functor (BaggageT m)
Functor (BaggageT m) =>
(forall a. a -> BaggageT m a)
-> (forall a b.
BaggageT m (a -> b) -> BaggageT m a -> BaggageT m b)
-> (forall a b c.
(a -> b -> c) -> BaggageT m a -> BaggageT m b -> BaggageT m c)
-> (forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b)
-> (forall a b. BaggageT m a -> BaggageT m b -> BaggageT m a)
-> Applicative (BaggageT m)
forall a. a -> BaggageT m a
forall a b. BaggageT m a -> BaggageT m b -> BaggageT m a
forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b
forall a b. BaggageT m (a -> b) -> BaggageT m a -> BaggageT m b
forall a b c.
(a -> b -> c) -> BaggageT m a -> BaggageT m b -> BaggageT m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (BaggageT m)
forall (m :: * -> *) a. Applicative m => a -> BaggageT m a
forall (m :: * -> *) a b.
Applicative m =>
BaggageT m a -> BaggageT m b -> BaggageT m a
forall (m :: * -> *) a b.
Applicative m =>
BaggageT m a -> BaggageT m b -> BaggageT m b
forall (m :: * -> *) a b.
Applicative m =>
BaggageT m (a -> b) -> BaggageT m a -> BaggageT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> BaggageT m a -> BaggageT m b -> BaggageT m c
$cpure :: forall (m :: * -> *) a. Applicative m => a -> BaggageT m a
pure :: forall a. a -> BaggageT m a
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
BaggageT m (a -> b) -> BaggageT m a -> BaggageT m b
<*> :: forall a b. BaggageT m (a -> b) -> BaggageT m a -> BaggageT m b
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> BaggageT m a -> BaggageT m b -> BaggageT m c
liftA2 :: forall a b c.
(a -> b -> c) -> BaggageT m a -> BaggageT m b -> BaggageT m c
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
BaggageT m a -> BaggageT m b -> BaggageT m b
*> :: forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
BaggageT m a -> BaggageT m b -> BaggageT m a
<* :: forall a b. BaggageT m a -> BaggageT m b -> BaggageT m a
Applicative, (forall a b. (a -> b) -> BaggageT m a -> BaggageT m b)
-> (forall a b. a -> BaggageT m b -> BaggageT m a)
-> Functor (BaggageT m)
forall a b. a -> BaggageT m b -> BaggageT m a
forall a b. (a -> b) -> BaggageT m a -> BaggageT m b
forall (m :: * -> *) a b.
Functor m =>
a -> BaggageT m b -> BaggageT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> BaggageT m a -> BaggageT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> BaggageT m a -> BaggageT m b
fmap :: forall a b. (a -> b) -> BaggageT m a -> BaggageT m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> BaggageT m b -> BaggageT m a
<$ :: forall a b. a -> BaggageT m b -> BaggageT m a
Functor, Applicative (BaggageT m)
Applicative (BaggageT m) =>
(forall a b. BaggageT m a -> (a -> BaggageT m b) -> BaggageT m b)
-> (forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b)
-> (forall a. a -> BaggageT m a)
-> Monad (BaggageT m)
forall a. a -> BaggageT m a
forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b
forall a b. BaggageT m a -> (a -> BaggageT m b) -> BaggageT m b
forall (m :: * -> *). Monad m => Applicative (BaggageT m)
forall (m :: * -> *) a. Monad m => a -> BaggageT m a
forall (m :: * -> *) a b.
Monad m =>
BaggageT m a -> BaggageT m b -> BaggageT m b
forall (m :: * -> *) a b.
Monad m =>
BaggageT m a -> (a -> BaggageT m b) -> BaggageT m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
BaggageT m a -> (a -> BaggageT m b) -> BaggageT m b
>>= :: forall a b. BaggageT m a -> (a -> BaggageT m b) -> BaggageT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
BaggageT m a -> BaggageT m b -> BaggageT m b
>> :: forall a b. BaggageT m a -> BaggageT m b -> BaggageT m b
$creturn :: forall (m :: * -> *) a. Monad m => a -> BaggageT m a
return :: forall a. a -> BaggageT m a
Monad, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall a. String -> BaggageT m a) -> MonadFail (BaggageT m)
forall a. String -> BaggageT m a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
forall (m :: * -> *). MonadFail m => Monad (BaggageT m)
forall (m :: * -> *) a. MonadFail m => String -> BaggageT m a
$cfail :: forall (m :: * -> *) a. MonadFail m => String -> BaggageT m a
fail :: forall a. String -> BaggageT m a
MonadFail, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall a. IO a -> BaggageT m a) -> MonadIO (BaggageT m)
forall a. IO a -> BaggageT m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (BaggageT m)
forall (m :: * -> *) a. MonadIO m => IO a -> BaggageT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> BaggageT m a
liftIO :: forall a. IO a -> BaggageT m a
MonadIO
, Applicative (BaggageT m)
Applicative (BaggageT m) =>
(forall a. BaggageT m a)
-> (forall a. BaggageT m a -> BaggageT m a -> BaggageT m a)
-> (forall a. BaggageT m a -> BaggageT m [a])
-> (forall a. BaggageT m a -> BaggageT m [a])
-> Alternative (BaggageT m)
forall a. BaggageT m a
forall a. BaggageT m a -> BaggageT m [a]
forall a. BaggageT m a -> BaggageT m a -> BaggageT m a
forall (f :: * -> *).
Applicative f =>
(forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall (m :: * -> *). Alternative m => Applicative (BaggageT m)
forall (m :: * -> *) a. Alternative m => BaggageT m a
forall (m :: * -> *) a.
Alternative m =>
BaggageT m a -> BaggageT m [a]
forall (m :: * -> *) a.
Alternative m =>
BaggageT m a -> BaggageT m a -> BaggageT m a
$cempty :: forall (m :: * -> *) a. Alternative m => BaggageT m a
empty :: forall a. BaggageT m a
$c<|> :: forall (m :: * -> *) a.
Alternative m =>
BaggageT m a -> BaggageT m a -> BaggageT m a
<|> :: forall a. BaggageT m a -> BaggageT m a -> BaggageT m a
$csome :: forall (m :: * -> *) a.
Alternative m =>
BaggageT m a -> BaggageT m [a]
some :: forall a. BaggageT m a -> BaggageT m [a]
$cmany :: forall (m :: * -> *) a.
Alternative m =>
BaggageT m a -> BaggageT m [a]
many :: forall a. BaggageT m a -> BaggageT m [a]
Alternative, Monad (BaggageT m)
Alternative (BaggageT m)
(Alternative (BaggageT m), Monad (BaggageT m)) =>
(forall a. BaggageT m a)
-> (forall a. BaggageT m a -> BaggageT m a -> BaggageT m a)
-> MonadPlus (BaggageT m)
forall a. BaggageT m a
forall a. BaggageT m a -> BaggageT m a -> BaggageT m a
forall (m :: * -> *).
(Alternative m, Monad m) =>
(forall a. m a) -> (forall a. m a -> m a -> m a) -> MonadPlus m
forall (m :: * -> *). MonadPlus m => Monad (BaggageT m)
forall (m :: * -> *). MonadPlus m => Alternative (BaggageT m)
forall (m :: * -> *) a. MonadPlus m => BaggageT m a
forall (m :: * -> *) a.
MonadPlus m =>
BaggageT m a -> BaggageT m a -> BaggageT m a
$cmzero :: forall (m :: * -> *) a. MonadPlus m => BaggageT m a
mzero :: forall a. BaggageT m a
$cmplus :: forall (m :: * -> *) a.
MonadPlus m =>
BaggageT m a -> BaggageT m a -> BaggageT m a
mplus :: forall a. BaggageT m a -> BaggageT m a -> BaggageT m a
MonadPlus
, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall a b. ((a -> BaggageT m b) -> BaggageT m a) -> BaggageT m a)
-> MonadCont (BaggageT m)
forall a b. ((a -> BaggageT m b) -> BaggageT m a) -> BaggageT m a
forall (m :: * -> *).
Monad m =>
(forall a b. ((a -> m b) -> m a) -> m a) -> MonadCont m
forall (m :: * -> *). MonadCont m => Monad (BaggageT m)
forall (m :: * -> *) a b.
MonadCont m =>
((a -> BaggageT m b) -> BaggageT m a) -> BaggageT m a
$ccallCC :: forall (m :: * -> *) a b.
MonadCont m =>
((a -> BaggageT m b) -> BaggageT m a) -> BaggageT m a
callCC :: forall a b. ((a -> BaggageT m b) -> BaggageT m a) -> BaggageT m a
MonadCont, MonadError e, MonadState s, MonadWriter w
#if MIN_VERSION_mtl(2,3,0)
, MonadAccum w, MonadSelect r
#endif
, MonadThrow (BaggageT m)
MonadThrow (BaggageT m) =>
(forall e a.
(HasCallStack, Exception e) =>
BaggageT m a -> (e -> BaggageT m a) -> BaggageT m a)
-> MonadCatch (BaggageT m)
forall e a.
(HasCallStack, Exception e) =>
BaggageT m a -> (e -> BaggageT m a) -> BaggageT m a
forall (m :: * -> *).
MonadThrow m =>
(forall e a.
(HasCallStack, Exception e) =>
m a -> (e -> m a) -> m a)
-> MonadCatch m
forall (m :: * -> *). MonadCatch m => MonadThrow (BaggageT m)
forall (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
BaggageT m a -> (e -> BaggageT m a) -> BaggageT m a
$ccatch :: forall (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
BaggageT m a -> (e -> BaggageT m a) -> BaggageT m a
catch :: forall e a.
(HasCallStack, Exception e) =>
BaggageT m a -> (e -> BaggageT m a) -> BaggageT m a
MonadCatch, MonadCatch (BaggageT m)
MonadCatch (BaggageT m) =>
(forall b.
HasCallStack =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b)
-> (forall b.
HasCallStack =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b)
-> (forall a b c.
HasCallStack =>
BaggageT m a
-> (a -> ExitCase b -> BaggageT m c)
-> (a -> BaggageT m b)
-> BaggageT m (b, c))
-> MonadMask (BaggageT m)
forall b.
HasCallStack =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
forall a b c.
HasCallStack =>
BaggageT m a
-> (a -> ExitCase b -> BaggageT m c)
-> (a -> BaggageT m b)
-> BaggageT m (b, c)
forall (m :: * -> *). MonadMask m => MonadCatch (BaggageT m)
forall (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
forall (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
BaggageT m a
-> (a -> ExitCase b -> BaggageT m c)
-> (a -> BaggageT m b)
-> BaggageT m (b, c)
forall (m :: * -> *).
MonadCatch m =>
(forall b. HasCallStack => ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b.
HasCallStack =>
((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
HasCallStack =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
$cmask :: forall (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
mask :: forall b.
HasCallStack =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
$cuninterruptibleMask :: forall (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
uninterruptibleMask :: forall b.
HasCallStack =>
((forall a. BaggageT m a -> BaggageT m a) -> BaggageT m b)
-> BaggageT m b
$cgeneralBracket :: forall (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
BaggageT m a
-> (a -> ExitCase b -> BaggageT m c)
-> (a -> BaggageT m b)
-> BaggageT m (b, c)
generalBracket :: forall a b c.
HasCallStack =>
BaggageT m a
-> (a -> ExitCase b -> BaggageT m c)
-> (a -> BaggageT m b)
-> BaggageT m (b, c)
MonadMask, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall e a. (HasCallStack, Exception e) => e -> BaggageT m a)
-> MonadThrow (BaggageT m)
forall e a. (HasCallStack, Exception e) => e -> BaggageT m a
forall (m :: * -> *).
Monad m =>
(forall e a. (HasCallStack, Exception e) => e -> m a)
-> MonadThrow m
forall (m :: * -> *). MonadThrow m => Monad (BaggageT m)
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> BaggageT m a
$cthrowM :: forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> BaggageT m a
throwM :: forall e a. (HasCallStack, Exception e) => e -> BaggageT m a
MonadThrow
, MonadIO (BaggageT m)
MonadIO (BaggageT m) =>
(forall b.
((forall a. BaggageT m a -> IO a) -> IO b) -> BaggageT m b)
-> MonadUnliftIO (BaggageT m)
forall b.
((forall a. BaggageT m a -> IO a) -> IO b) -> BaggageT m b
forall (m :: * -> *).
MonadIO m =>
(forall b. ((forall a. m a -> IO a) -> IO b) -> m b)
-> MonadUnliftIO m
forall (m :: * -> *). MonadUnliftIO m => MonadIO (BaggageT m)
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. BaggageT m a -> IO a) -> IO b) -> BaggageT m b
$cwithRunInIO :: forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. BaggageT m a -> IO a) -> IO b) -> BaggageT m b
withRunInIO :: forall b.
((forall a. BaggageT m a -> IO a) -> IO b) -> BaggageT m b
MonadUnliftIO
, MonadBase b
, MonadBaseControl b
, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> BaggageT m ())
-> MonadLogger (BaggageT m)
forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> BaggageT m ()
forall (m :: * -> *).
Monad m =>
(forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> m ())
-> MonadLogger m
forall (m :: * -> *). MonadLogger m => Monad (BaggageT m)
forall (m :: * -> *) msg.
(MonadLogger m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> BaggageT m ()
$cmonadLoggerLog :: forall (m :: * -> *) msg.
(MonadLogger m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> BaggageT m ()
monadLoggerLog :: forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> BaggageT m ()
MonadLogger
, MonadIO (BaggageT m)
MonadIO (BaggageT m) =>
(forall a. ResourceT IO a -> BaggageT m a)
-> MonadResource (BaggageT m)
forall a. ResourceT IO a -> BaggageT m a
forall (m :: * -> *).
MonadIO m =>
(forall a. ResourceT IO a -> m a) -> MonadResource m
forall (m :: * -> *). MonadResource m => MonadIO (BaggageT m)
forall (m :: * -> *) a.
MonadResource m =>
ResourceT IO a -> BaggageT m a
$cliftResourceT :: forall (m :: * -> *) a.
MonadResource m =>
ResourceT IO a -> BaggageT m a
liftResourceT :: forall a. ResourceT IO a -> BaggageT m a
MonadResource
, Monad (BaggageT m)
Monad (BaggageT m) =>
(forall a.
CallStack
-> SpanSpec -> (MutableSpan -> BaggageT m a) -> BaggageT m a)
-> (MutableSpan -> BaggageT m SpanContext)
-> (MutableSpan -> UpdateSpanSpec -> BaggageT m ())
-> MonadTracing (BaggageT m)
MutableSpan -> BaggageT m SpanContext
MutableSpan -> UpdateSpanSpec -> BaggageT m ()
forall a.
CallStack
-> SpanSpec -> (MutableSpan -> BaggageT m a) -> BaggageT m a
forall (m :: * -> *).
Monad m =>
(forall a. CallStack -> SpanSpec -> (MutableSpan -> m a) -> m a)
-> (MutableSpan -> m SpanContext)
-> (MutableSpan -> UpdateSpanSpec -> m ())
-> MonadTracing m
forall (m :: * -> *). MonadTracing m => Monad (BaggageT m)
forall (m :: * -> *).
MonadTracing m =>
MutableSpan -> BaggageT m SpanContext
forall (m :: * -> *).
MonadTracing m =>
MutableSpan -> UpdateSpanSpec -> BaggageT m ()
forall (m :: * -> *) a.
MonadTracing m =>
CallStack
-> SpanSpec -> (MutableSpan -> BaggageT m a) -> BaggageT m a
$ctraceCS :: forall (m :: * -> *) a.
MonadTracing m =>
CallStack
-> SpanSpec -> (MutableSpan -> BaggageT m a) -> BaggageT m a
traceCS :: forall a.
CallStack
-> SpanSpec -> (MutableSpan -> BaggageT m a) -> BaggageT m a
$cgetSpanContext :: forall (m :: * -> *).
MonadTracing m =>
MutableSpan -> BaggageT m SpanContext
getSpanContext :: MutableSpan -> BaggageT m SpanContext
$cupdateSpan :: forall (m :: * -> *).
MonadTracing m =>
MutableSpan -> UpdateSpanSpec -> BaggageT m ()
updateSpan :: MutableSpan -> UpdateSpanSpec -> BaggageT m ()
MonadTracing, MonadIO (BaggageT m)
MonadTracing (BaggageT m)
BaggageT m Tracer
(MonadTracing (BaggageT m), MonadIO (BaggageT m)) =>
BaggageT m Tracer -> MonadTracingIO (BaggageT m)
forall (m :: * -> *). MonadTracingIO m => MonadIO (BaggageT m)
forall (m :: * -> *). MonadTracingIO m => MonadTracing (BaggageT m)
forall (m :: * -> *). MonadTracingIO m => BaggageT m Tracer
forall (m :: * -> *).
(MonadTracing m, MonadIO m) =>
m Tracer -> MonadTracingIO m
$caskTracerIO :: forall (m :: * -> *). MonadTracingIO m => BaggageT m Tracer
askTracerIO :: BaggageT m Tracer
MonadTracingIO
) via (ReaderT BaggageBackend m)
deriving
( MonadTrans BaggageT
MonadTrans BaggageT =>
(forall (m :: * -> *) a.
Monad m =>
(Run BaggageT -> m a) -> BaggageT m a)
-> (forall (m :: * -> *) a.
Monad m =>
m (StT BaggageT a) -> BaggageT m a)
-> MonadTransControl BaggageT
forall (m :: * -> *) a.
Monad m =>
m (StT BaggageT a) -> BaggageT m a
forall (m :: * -> *) a.
Monad m =>
(Run BaggageT -> m a) -> BaggageT m a
forall (t :: (* -> *) -> * -> *).
MonadTrans t =>
(forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
$cliftWith :: forall (m :: * -> *) a.
Monad m =>
(Run BaggageT -> m a) -> BaggageT m a
liftWith :: forall (m :: * -> *) a.
Monad m =>
(Run BaggageT -> m a) -> BaggageT m a
$crestoreT :: forall (m :: * -> *) a.
Monad m =>
m (StT BaggageT a) -> BaggageT m a
restoreT :: forall (m :: * -> *) a.
Monad m =>
m (StT BaggageT a) -> BaggageT m a
MonadTransControl
) via (ReaderT BaggageBackend)
deriving
( NonEmpty (BaggageT m a) -> BaggageT m a
BaggageT m a -> BaggageT m a -> BaggageT m a
(BaggageT m a -> BaggageT m a -> BaggageT m a)
-> (NonEmpty (BaggageT m a) -> BaggageT m a)
-> (forall b. Integral b => b -> BaggageT m a -> BaggageT m a)
-> Semigroup (BaggageT m a)
forall b. Integral b => b -> BaggageT m a -> BaggageT m a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall (m :: * -> *) a.
(Applicative m, Semigroup a) =>
NonEmpty (BaggageT m a) -> BaggageT m a
forall (m :: * -> *) a.
(Applicative m, Semigroup a) =>
BaggageT m a -> BaggageT m a -> BaggageT m a
forall (m :: * -> *) a b.
(Applicative m, Semigroup a, Integral b) =>
b -> BaggageT m a -> BaggageT m a
$c<> :: forall (m :: * -> *) a.
(Applicative m, Semigroup a) =>
BaggageT m a -> BaggageT m a -> BaggageT m a
<> :: BaggageT m a -> BaggageT m a -> BaggageT m a
$csconcat :: forall (m :: * -> *) a.
(Applicative m, Semigroup a) =>
NonEmpty (BaggageT m a) -> BaggageT m a
sconcat :: NonEmpty (BaggageT m a) -> BaggageT m a
$cstimes :: forall (m :: * -> *) a b.
(Applicative m, Semigroup a, Integral b) =>
b -> BaggageT m a -> BaggageT m a
stimes :: forall b. Integral b => b -> BaggageT m a -> BaggageT m a
Semigroup, Semigroup (BaggageT m a)
BaggageT m a
Semigroup (BaggageT m a) =>
BaggageT m a
-> (BaggageT m a -> BaggageT m a -> BaggageT m a)
-> ([BaggageT m a] -> BaggageT m a)
-> Monoid (BaggageT m a)
[BaggageT m a] -> BaggageT m a
BaggageT m a -> BaggageT m a -> BaggageT m a
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall (m :: * -> *) a.
(Applicative m, Monoid a) =>
Semigroup (BaggageT m a)
forall (m :: * -> *) a. (Applicative m, Monoid a) => BaggageT m a
forall (m :: * -> *) a.
(Applicative m, Monoid a) =>
[BaggageT m a] -> BaggageT m a
forall (m :: * -> *) a.
(Applicative m, Monoid a) =>
BaggageT m a -> BaggageT m a -> BaggageT m a
$cmempty :: forall (m :: * -> *) a. (Applicative m, Monoid a) => BaggageT m a
mempty :: BaggageT m a
$cmappend :: forall (m :: * -> *) a.
(Applicative m, Monoid a) =>
BaggageT m a -> BaggageT m a -> BaggageT m a
mappend :: BaggageT m a -> BaggageT m a -> BaggageT m a
$cmconcat :: forall (m :: * -> *) a.
(Applicative m, Monoid a) =>
[BaggageT m a] -> BaggageT m a
mconcat :: [BaggageT m a] -> BaggageT m a
Monoid
) via (Ap (ReaderT BaggageBackend m) a)
deriving via (ReaderT BaggageBackend) instance MonadTrans BaggageT
instance (MonadReader r m) => MonadReader r (BaggageT m) where
ask :: BaggageT m r
ask = m r -> BaggageT m r
forall (m :: * -> *) a. Monad m => m a -> BaggageT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
reader :: forall a. (r -> a) -> BaggageT m a
reader = m a -> BaggageT m a
forall (m :: * -> *) a. Monad m => m a -> BaggageT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> BaggageT m a)
-> ((r -> a) -> m a) -> (r -> a) -> BaggageT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> a) -> m a
forall a. (r -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
reader
local :: forall a. (r -> r) -> BaggageT m a -> BaggageT m a
local = (m a -> m a) -> BaggageT m a -> BaggageT m a
forall (m :: * -> *) (n :: * -> *) a b.
(m a -> n b) -> BaggageT m a -> BaggageT n b
mapBaggageT ((m a -> m a) -> BaggageT m a -> BaggageT m a)
-> ((r -> r) -> m a -> m a)
-> (r -> r)
-> BaggageT m a
-> BaggageT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> r) -> m a -> m a
forall a. (r -> r) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local
instance (MonadRWS r w s m) => MonadRWS r w s (BaggageT m)
instance (MonadIO m, MonadMask m) => MonadBaggage (BaggageT m) where
getBaggage :: BaggageT m Baggage
getBaggage =
(BaggageBackend -> m Baggage) -> BaggageT m Baggage
forall (m :: * -> *) a. (BaggageBackend -> m a) -> BaggageT m a
BaggageT \BaggageBackend
baggageBackend -> do
(ContextT Baggage m Baggage -> ContextBackend Baggage -> m Baggage)
-> ContextBackend Baggage
-> ContextT Baggage m Baggage
-> m Baggage
forall a b c. (a -> b -> c) -> b -> a -> c
flip ContextT Baggage m Baggage -> ContextBackend Baggage -> m Baggage
forall c (m :: * -> *) a. ContextT c m a -> ContextBackend c -> m a
runContextT (BaggageBackend -> ContextBackend Baggage
unBaggageBackend BaggageBackend
baggageBackend) do
ContextT Baggage m (Maybe Baggage)
forall (m :: * -> *) a.
(MonadIO m, MonadMask m) =>
ContextT a m (Maybe a)
getAttachedContextValue ContextT Baggage m (Maybe Baggage)
-> (Maybe Baggage -> ContextT Baggage m Baggage)
-> ContextT Baggage m Baggage
forall a b.
ContextT Baggage m a
-> (a -> ContextT Baggage m b) -> ContextT Baggage m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Maybe Baggage
Nothing -> ContextT Baggage m Baggage
forall a. Monoid a => a
mempty
Just Baggage
baggage -> Baggage -> ContextT Baggage m Baggage
forall a. a -> ContextT Baggage m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Baggage
baggage
setBaggage :: forall a. Baggage -> BaggageT m a -> BaggageT m a
setBaggage Baggage
baggage BaggageT m a
action =
(BaggageBackend -> m a) -> BaggageT m a
forall (m :: * -> *) a. (BaggageBackend -> m a) -> BaggageT m a
BaggageT \BaggageBackend
baggageBackend -> do
(ContextT Baggage m a -> ContextBackend Baggage -> m a)
-> ContextBackend Baggage -> ContextT Baggage m a -> m a
forall a b c. (a -> b -> c) -> b -> a -> c
flip ContextT Baggage m a -> ContextBackend Baggage -> m a
forall c (m :: * -> *) a. ContextT c m a -> ContextBackend c -> m a
runContextT (BaggageBackend -> ContextBackend Baggage
unBaggageBackend BaggageBackend
baggageBackend) do
Baggage -> ContextT Baggage m a -> ContextT Baggage m a
forall (m :: * -> *) a b.
(MonadIO m, MonadMask m) =>
a -> ContextT a m b -> ContextT a m b
attachContextValue Baggage
baggage do
m a -> ContextT Baggage m a
forall (m :: * -> *) a. Monad m => m a -> ContextT Baggage m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ContextT Baggage m a) -> m a -> ContextT Baggage m a
forall a b. (a -> b) -> a -> b
$ BaggageT m a -> BaggageBackend -> m a
forall (m :: * -> *) a. BaggageT m a -> BaggageBackend -> m a
runBaggageT BaggageT m a
action BaggageBackend
baggageBackend
mapBaggageT
:: forall m n a b
. (m a -> n b)
-> BaggageT m a
-> BaggageT n b
mapBaggageT :: forall (m :: * -> *) (n :: * -> *) a b.
(m a -> n b) -> BaggageT m a -> BaggageT n b
mapBaggageT m a -> n b
f BaggageT m a
action = (BaggageBackend -> n b) -> BaggageT n b
forall (m :: * -> *) a. (BaggageBackend -> m a) -> BaggageT m a
BaggageT ((BaggageBackend -> n b) -> BaggageT n b)
-> (BaggageBackend -> n b) -> BaggageT n b
forall a b. (a -> b) -> a -> b
$ m a -> n b
f (m a -> n b) -> (BaggageBackend -> m a) -> BaggageBackend -> n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BaggageT m a -> BaggageBackend -> m a
forall (m :: * -> *) a. BaggageT m a -> BaggageBackend -> m a
runBaggageT BaggageT m a
action
newtype BaggageBackend = BaggageBackend
{ BaggageBackend -> ContextBackend Baggage
unBaggageBackend :: ContextBackend Baggage
}
defaultBaggageBackend :: BaggageBackend
defaultBaggageBackend :: BaggageBackend
defaultBaggageBackend =
BaggageBackend
{ unBaggageBackend :: ContextBackend Baggage
unBaggageBackend = ContextBackend Baggage
contextBackendBaggage
}