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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Embed

Contents

Synopsis

Effects

newtype Embed b m 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.

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
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 :: Type #

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 :: Type #

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 #

fail :: String -> 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 -> Type) -> Type -> Type) ': ([] :: [(Type -> Type) -> Type -> Type])
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

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

type EmbedToMonadIOC = InterpretC EmbedToMonadIOH (Embed IO) Source #