in-other-words-0.1.0.0: A higher-order effect system where the sky's the limit

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Carrier.Internal.Compose

Synopsis

Documentation

newtype ComposeT t (u :: (* -> *) -> * -> *) m a Source #

Composition of monad/carrier transformers.

Constructors

ComposeT 

Fields

Instances
MonadBase b (t (u m)) => MonadBase b (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

liftBase :: b α -> ComposeT t u m α #

MonadBaseControl b (t (u m)) => MonadBaseControl b (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type StM (ComposeT t u m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ComposeT t u m) b -> b a) -> ComposeT t u m a #

restoreM :: StM (ComposeT t u m) a -> ComposeT t u m a #

(MonadTrans t, MonadTrans u, forall (m :: Type -> Type). Monad m => Monad (u m)) => MonadTrans (ComposeT t u) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

lift :: Monad m => m a -> ComposeT t u m a #

(MonadTransControl t, MonadTransControl u, forall (m :: Type -> Type). Monad m => Monad (u m)) => MonadTransControl (ComposeT t u) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type StT (ComposeT t u) a :: Type #

Methods

liftWith :: Monad m => (Run (ComposeT t u) -> m a) -> ComposeT t u m a #

restoreT :: Monad m => m (StT (ComposeT t u) a) -> ComposeT t u m a #

Monad (t (u m)) => Monad (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

(>>=) :: ComposeT t u m a -> (a -> ComposeT t u m b) -> ComposeT t u m b #

(>>) :: ComposeT t u m a -> ComposeT t u m b -> ComposeT t u m b #

return :: a -> ComposeT t u m a #

fail :: String -> ComposeT t u m a #

Functor (t (u m)) => Functor (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

fmap :: (a -> b) -> ComposeT t u m a -> ComposeT t u m b #

(<$) :: a -> ComposeT t u m b -> ComposeT t u m a #

MonadFix (t (u m)) => MonadFix (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mfix :: (a -> ComposeT t u m a) -> ComposeT t u m a #

MonadFail (t (u m)) => MonadFail (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

fail :: String -> ComposeT t u m a #

Applicative (t (u m)) => Applicative (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

pure :: a -> ComposeT t u m a #

(<*>) :: ComposeT t u m (a -> b) -> ComposeT t u m a -> ComposeT t u m b #

liftA2 :: (a -> b -> c) -> ComposeT t u m a -> ComposeT t u m b -> ComposeT t u m c #

(*>) :: ComposeT t u m a -> ComposeT t u m b -> ComposeT t u m b #

(<*) :: ComposeT t u m a -> ComposeT t u m b -> ComposeT t u m a #

MonadIO (t (u m)) => MonadIO (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

liftIO :: IO a -> ComposeT t u m a #

Alternative (t (u m)) => Alternative (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

empty :: ComposeT t u m a #

(<|>) :: ComposeT t u m a -> ComposeT t u m a -> ComposeT t u m a #

some :: ComposeT t u m a -> ComposeT t u m [a] #

many :: ComposeT t u m a -> ComposeT t u m [a] #

MonadPlus (t (u m)) => MonadPlus (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mzero :: ComposeT t u m a #

mplus :: ComposeT t u m a -> ComposeT t u m a -> ComposeT t u m a #

MonadThrow (t (u m)) => MonadThrow (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

throwM :: Exception e => e -> ComposeT t u m a #

MonadCatch (t (u m)) => MonadCatch (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

catch :: Exception e => ComposeT t u m a -> (e -> ComposeT t u m a) -> ComposeT t u m a #

MonadMask (t (u m)) => MonadMask (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mask :: ((forall a. ComposeT t u m a -> ComposeT t u m a) -> ComposeT t u m b) -> ComposeT t u m b #

uninterruptibleMask :: ((forall a. ComposeT t u m a -> ComposeT t u m a) -> ComposeT t u m b) -> ComposeT t u m b #

generalBracket :: ComposeT t u m a -> (a -> ExitCase b -> ComposeT t u m c) -> (a -> ComposeT t u m b) -> ComposeT t u m (b, c) #

Carrier (t (u m)) => Carrier (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type Derivs (ComposeT t u m) :: [Effect] Source #

type Prims (ComposeT t u m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ComposeT t u m)) (ComposeT t u m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ComposeT t u m)) (Prims (ComposeT t u m)) (ComposeT t u m) z a Source #

algDerivs :: Algebra' (Derivs (ComposeT t u m)) (ComposeT t u m) a Source #

type StT (ComposeT t u) a Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type StT (ComposeT t u) a = StT u (StT t a)
type Derivs (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type Derivs (ComposeT t u m) = Derivs (t (u m))
type Prims (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type Prims (ComposeT t u m) = Prims (t (u m))
type StM (ComposeT t u m) a Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type StM (ComposeT t u m) a = StM (t (u m)) a

newtype CompositionC ts m a Source #

Composition of a list of carrier transformers.

This is useful when you have multiple interpretations whose carriers you'd like to treat as one larger object, such that lift lifts past all those carriers.

For example:

data Counter m a where
  Probe :: Counter m Int

type CounterC = CompositionC
  '[ ReinterpretSimpleC Counter '[State Int]
   , StateC Int
   ]

runCounter :: (Carrier m, Threaders '[StateThreads] m p)
           => CounterC m a
           -> m a
runCounter =
   runState 0
 . reinterpretSimple (case
     Probe -> state' (s -> (s+1,s))
   )
 . runComposition

Then you have lift :: Monad m => m a -> CounterC m a

Constructors

CompositionC 
Instances
(Monad b, MonadBase b (CompositionBaseT ts m)) => MonadBase b (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

liftBase :: b α -> CompositionC ts m α #

MonadBaseControl b (CompositionBaseT ts m) => MonadBaseControl b (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type StM (CompositionC ts m) a :: Type #

Methods

liftBaseWith :: (RunInBase (CompositionC ts m) b -> b a) -> CompositionC ts m a #

restoreM :: StM (CompositionC ts m) a -> CompositionC ts m a #

MonadTrans (CompositionBaseT ts) => MonadTrans (CompositionC ts) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

lift :: Monad m => m a -> CompositionC ts m a #

MonadTransControl (CompositionBaseT ts) => MonadTransControl (CompositionC ts) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type StT (CompositionC ts) a :: Type #

Methods

liftWith :: Monad m => (Run (CompositionC ts) -> m a) -> CompositionC ts m a #

restoreT :: Monad m => m (StT (CompositionC ts) a) -> CompositionC ts m a #

Monad (CompositionBaseT ts m) => Monad (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

(>>=) :: CompositionC ts m a -> (a -> CompositionC ts m b) -> CompositionC ts m b #

(>>) :: CompositionC ts m a -> CompositionC ts m b -> CompositionC ts m b #

return :: a -> CompositionC ts m a #

fail :: String -> CompositionC ts m a #

Functor (CompositionBaseT ts m) => Functor (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

fmap :: (a -> b) -> CompositionC ts m a -> CompositionC ts m b #

(<$) :: a -> CompositionC ts m b -> CompositionC ts m a #

MonadFix (CompositionBaseT ts m) => MonadFix (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mfix :: (a -> CompositionC ts m a) -> CompositionC ts m a #

MonadFail (CompositionBaseT ts m) => MonadFail (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

fail :: String -> CompositionC ts m a #

Applicative (CompositionBaseT ts m) => Applicative (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

pure :: a -> CompositionC ts m a #

(<*>) :: CompositionC ts m (a -> b) -> CompositionC ts m a -> CompositionC ts m b #

liftA2 :: (a -> b -> c) -> CompositionC ts m a -> CompositionC ts m b -> CompositionC ts m c #

(*>) :: CompositionC ts m a -> CompositionC ts m b -> CompositionC ts m b #

(<*) :: CompositionC ts m a -> CompositionC ts m b -> CompositionC ts m a #

MonadIO (CompositionBaseT ts m) => MonadIO (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

liftIO :: IO a -> CompositionC ts m a #

Alternative (CompositionBaseT ts m) => Alternative (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

empty :: CompositionC ts m a #

(<|>) :: CompositionC ts m a -> CompositionC ts m a -> CompositionC ts m a #

some :: CompositionC ts m a -> CompositionC ts m [a] #

many :: CompositionC ts m a -> CompositionC ts m [a] #

MonadPlus (CompositionBaseT ts m) => MonadPlus (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mzero :: CompositionC ts m a #

mplus :: CompositionC ts m a -> CompositionC ts m a -> CompositionC ts m a #

MonadThrow (CompositionBaseT ts m) => MonadThrow (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

throwM :: Exception e => e -> CompositionC ts m a #

MonadCatch (CompositionBaseT ts m) => MonadCatch (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

catch :: Exception e => CompositionC ts m a -> (e -> CompositionC ts m a) -> CompositionC ts m a #

MonadMask (CompositionBaseT ts m) => MonadMask (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Methods

mask :: ((forall a. CompositionC ts m a -> CompositionC ts m a) -> CompositionC ts m b) -> CompositionC ts m b #

uninterruptibleMask :: ((forall a. CompositionC ts m a -> CompositionC ts m a) -> CompositionC ts m b) -> CompositionC ts m b #

generalBracket :: CompositionC ts m a -> (a -> ExitCase b -> CompositionC ts m c) -> (a -> CompositionC ts m b) -> CompositionC ts m (b, c) #

Carrier (CompositionBaseT ts m) => Carrier (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type Derivs (CompositionC ts m) :: [Effect] Source #

type Prims (CompositionC ts m) :: [Effect] Source #

type StT (CompositionC ts) a Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type StT (CompositionC ts) a = StT (CompositionBaseT' (IdentityT :: (Type -> Type) -> Type -> Type) ts) a
type Derivs (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type Derivs (CompositionC ts m) = Derivs (CompositionBaseT' (IdentityT :: (Type -> Type) -> Type -> Type) ts m)
type Prims (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type Prims (CompositionC ts m) = Prims (CompositionBaseT' (IdentityT :: (Type -> Type) -> Type -> Type) ts m)
type StM (CompositionC ts m) a Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

type StM (CompositionC ts m) a = StM (CompositionBaseT' (IdentityT :: (Type -> Type) -> Type -> Type) ts m) a

type family CompositionBaseT' acc ts :: (* -> *) -> * -> * where ... Source #

Equations

CompositionBaseT' acc '[] = acc 
CompositionBaseT' acc (t ': ts) = CompositionBaseT' (ComposeT acc t) ts 

type family CompositionBaseM (ts :: [(* -> *) -> * -> *]) (m :: * -> *) where ... Source #

Equations

CompositionBaseM '[] m = m 
CompositionBaseM (t ': ts) m = t (CompositionBaseM ts m) 

runComposition :: CompositionC ts m a -> CompositionBaseM ts m a Source #

Transform CompositionC [t1, t2, ..., tn] m a to t1 (t2 (... (tn m) ...)) a