fused-effects-0.5.0.1: A fast, flexible, fused effect system.
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Interpose

Description

This module provides an InterposeC carrier capable of "eavesdropping" on requests made to other carriers. This is a useful capability for dynamism in deeply-nested effect stacks, but can lead to complicated control flow. Be careful.

Synopsis

Documentation

newtype InterposeC eff m a Source #

Constructors

InterposeC 

Fields

Instances

Instances details
(HFunctor eff, Carrier sig m, Member eff sig) => Carrier sig (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

eff :: sig (InterposeC eff m) a -> InterposeC eff m a Source #

MonadTrans (InterposeC eff) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

lift :: Monad m => m a -> InterposeC eff m a #

Monad m => Monad (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

(>>=) :: InterposeC eff m a -> (a -> InterposeC eff m b) -> InterposeC eff m b #

(>>) :: InterposeC eff m a -> InterposeC eff m b -> InterposeC eff m b #

return :: a -> InterposeC eff m a #

Functor m => Functor (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

fmap :: (a -> b) -> InterposeC eff m a -> InterposeC eff m b #

(<$) :: a -> InterposeC eff m b -> InterposeC eff m a #

MonadFix m => MonadFix (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

mfix :: (a -> InterposeC eff m a) -> InterposeC eff m a #

MonadFail m => MonadFail (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

fail :: String -> InterposeC eff m a #

Applicative m => Applicative (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

pure :: a -> InterposeC eff m a #

(<*>) :: InterposeC eff m (a -> b) -> InterposeC eff m a -> InterposeC eff m b #

liftA2 :: (a -> b -> c) -> InterposeC eff m a -> InterposeC eff m b -> InterposeC eff m c #

(*>) :: InterposeC eff m a -> InterposeC eff m b -> InterposeC eff m b #

(<*) :: InterposeC eff m a -> InterposeC eff m b -> InterposeC eff m a #

MonadIO m => MonadIO (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

liftIO :: IO a -> InterposeC eff m a #

Alternative m => Alternative (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

empty :: InterposeC eff m a #

(<|>) :: InterposeC eff m a -> InterposeC eff m a -> InterposeC eff m a #

some :: InterposeC eff m a -> InterposeC eff m [a] #

many :: InterposeC eff m a -> InterposeC eff m [a] #

(Alternative m, Monad m) => MonadPlus (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

mzero :: InterposeC eff m a #

mplus :: InterposeC eff m a -> InterposeC eff m a -> InterposeC eff m a #

runInterpose :: (forall x. eff m x -> m x) -> InterposeC eff m a -> m a Source #

runInterpose takes a handler for a given effect (such as State or Reader) and runs that handler whenever an effect of that type is encountered. Within a handler you can use all the capabilities of the underlying monad stack, including the intercepted effect, and you can pass the effect on to the original handler using send.

run . evalState @Int a . runInterpose @(State Int) (\op -> modify @Int (+b) *> send op) $ modify @Int (+b) === a + b + b