in-other-words-0.2.1.1: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Embed

Synopsis

Effects

newtype Embed b (m :: Type -> Type) a where Source #

An effect for embedding actions of a base monad into the current one.

Constructors

Embed 

Fields

Actions

embed :: Eff (Embed b) m => b a -> m a Source #

Interpreters

runM :: Monad m => RunMC m a -> m a Source #

Extract the final monad m from a computation of which no effects remain to be handled except for Embed m.

runEmbed :: Carrier m => EmbedC m a -> m a Source #

Run an Embed m effect, where the embedded monad m is the current monad.

Not to be confused with runM. This is simply an interpreter for Embed m; it doesn't extract the final monad.

Derivs (EmbedC m) = Embed m ': Derivs m
Prims  (EmbedC m) = Prims m

Since: 0.1.1.0

embedToEmbed :: forall b b' m a. Eff (Embed b') m => (forall x. b x -> b' x) -> InterpretReifiedC (Embed b) m a -> m a Source #

Transform an Embed effect into another Embed effect by providing a natural transformation to convert monadic values of one monad to the other.

This has a higher-rank type, as it makes use of InterpretReifiedC. This makes embedToEmbed very difficult to use partially applied. In particular, it can't be composed using ..

If performance is secondary, consider using the slower embedToEmbedSimple, which doesn't have a higher-rank type.

embedToMonadBase :: (MonadBase b m, Carrier m) => EmbedToMonadBaseC b m a -> m a Source #

Run an Embed b effect if b is the base of the current monad m.

embedToMonadIO :: (MonadIO m, Carrier m) => EmbedToMonadIOC m a -> m a Source #

Run an Embed IO effect if the current monad m is a MonadIO.

Simple variants

embedToEmbedSimple :: forall b b' m a p. (Eff (Embed b') m, Threaders '[ReaderThreads] m p) => (forall x. b x -> b' x) -> InterpretSimpleC (Embed b) m a -> m a Source #

Transform an Embed effect into another Embed effect by providing a natural transformation to convert monadic values of one monad to the other.

This is a less performant version of embedToEmbed that doesn't have a higher-rank type, making it much easier to use partially applied.

Carriers

newtype RunMC m a Source #

The carrier for runM, which carries no effects but Embed m.

Constructors

RunMC (m a) 

Instances

Instances details
MonadBase b m => MonadBase b (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

liftBase :: b α -> RunMC m α #

MonadBaseControl b m => MonadBaseControl b (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type StM (RunMC m) a #

Methods

liftBaseWith :: (RunInBase (RunMC m) b -> b a) -> RunMC m a #

restoreM :: StM (RunMC m) a -> RunMC m a #

MonadTrans (RunMC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

lift :: Monad m => m a -> RunMC m a #

MonadTransControl (RunMC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type StT RunMC a #

Methods

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

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

Monad m => Monad (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

(>>=) :: RunMC m a -> (a -> RunMC m b) -> RunMC m b #

(>>) :: RunMC m a -> RunMC m b -> RunMC m b #

return :: a -> RunMC m a #

Functor m => Functor (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

fmap :: (a -> b) -> RunMC m a -> RunMC m b #

(<$) :: a -> RunMC m b -> RunMC m a #

MonadFix m => MonadFix (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

mfix :: (a -> RunMC m a) -> RunMC m a #

MonadFail m => MonadFail (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

fail :: String -> RunMC m a #

Applicative m => Applicative (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

pure :: a -> RunMC m a #

(<*>) :: RunMC m (a -> b) -> RunMC m a -> RunMC m b #

liftA2 :: (a -> b -> c) -> RunMC m a -> RunMC m b -> RunMC m c #

(*>) :: RunMC m a -> RunMC m b -> RunMC m b #

(<*) :: RunMC m a -> RunMC m b -> RunMC m a #

MonadIO m => MonadIO (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

liftIO :: IO a -> RunMC m a #

Alternative m => Alternative (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

empty :: RunMC m a #

(<|>) :: RunMC m a -> RunMC m a -> RunMC m a #

some :: RunMC m a -> RunMC m [a] #

many :: RunMC m a -> RunMC m [a] #

MonadPlus m => MonadPlus (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

mzero :: RunMC m a #

mplus :: RunMC m a -> RunMC m a -> RunMC m a #

MonadThrow m => MonadThrow (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

throwM :: Exception e => e -> RunMC m a #

MonadCatch m => MonadCatch (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

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

MonadMask m => MonadMask (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

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

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

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

Monad m => Carrier (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type Derivs (RunMC m) :: [Effect] Source #

type Prims (RunMC m) :: [Effect] Source #

type StT (RunMC :: (Type -> Type) -> Type -> Type) a Source # 
Instance details

Defined in Control.Effect.Embed

type StT (RunMC :: (Type -> Type) -> Type -> Type) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

type Derivs (RunMC m) = '[Embed m]
type Prims (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

type Prims (RunMC m) = '[] :: [Effect]
type StM (RunMC m) a Source # 
Instance details

Defined in Control.Effect.Embed

type StM (RunMC m) a = StM m a

newtype EmbedC m a Source #

Constructors

EmbedC (m a) 

Instances

Instances details
MonadBase b m => MonadBase b (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

liftBase :: b α -> EmbedC m α #

MonadBaseControl b m => MonadBaseControl b (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type StM (EmbedC m) a #

Methods

liftBaseWith :: (RunInBase (EmbedC m) b -> b a) -> EmbedC m a #

restoreM :: StM (EmbedC m) a -> EmbedC m a #

MonadTrans (EmbedC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

lift :: Monad m => m a -> EmbedC m a #

MonadTransControl (EmbedC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type StT EmbedC a #

Methods

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

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

Monad m => Monad (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

(>>=) :: EmbedC m a -> (a -> EmbedC m b) -> EmbedC m b #

(>>) :: EmbedC m a -> EmbedC m b -> EmbedC m b #

return :: a -> EmbedC m a #

Functor m => Functor (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

fmap :: (a -> b) -> EmbedC m a -> EmbedC m b #

(<$) :: a -> EmbedC m b -> EmbedC m a #

MonadFix m => MonadFix (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

mfix :: (a -> EmbedC m a) -> EmbedC m a #

MonadFail m => MonadFail (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

fail :: String -> EmbedC m a #

Applicative m => Applicative (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

pure :: a -> EmbedC m a #

(<*>) :: EmbedC m (a -> b) -> EmbedC m a -> EmbedC m b #

liftA2 :: (a -> b -> c) -> EmbedC m a -> EmbedC m b -> EmbedC m c #

(*>) :: EmbedC m a -> EmbedC m b -> EmbedC m b #

(<*) :: EmbedC m a -> EmbedC m b -> EmbedC m a #

MonadIO m => MonadIO (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

liftIO :: IO a -> EmbedC m a #

Alternative m => Alternative (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

empty :: EmbedC m a #

(<|>) :: EmbedC m a -> EmbedC m a -> EmbedC m a #

some :: EmbedC m a -> EmbedC m [a] #

many :: EmbedC m a -> EmbedC m [a] #

MonadPlus m => MonadPlus (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

mzero :: EmbedC m a #

mplus :: EmbedC m a -> EmbedC m a -> EmbedC m a #

MonadThrow m => MonadThrow (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

throwM :: Exception e => e -> EmbedC m a #

MonadCatch m => MonadCatch (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

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

MonadMask m => MonadMask (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Methods

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

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

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

Carrier m => Carrier (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type Derivs (EmbedC m) :: [Effect] Source #

type Prims (EmbedC m) :: [Effect] Source #

type StT (EmbedC :: (Type -> Type) -> Type -> Type) a Source # 
Instance details

Defined in Control.Effect.Embed

type StT (EmbedC :: (Type -> Type) -> Type -> Type) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

type Derivs (EmbedC m) = Embed m ': Derivs m
type Prims (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

type Prims (EmbedC m) = Prims m
type StM (EmbedC m) a Source # 
Instance details

Defined in Control.Effect.Embed

type StM (EmbedC m) a = StM m a

type EmbedToMonadBaseC b = InterpretC EmbedToMonadBaseH (Embed b) Source #

type EmbedToMonadIOC = InterpretC EmbedToMonadIOH (Embed IO) Source #