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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.BaseControl

Contents

Synopsis

Effects

data BaseControl b m a Source #

A helper primitive effect that allows for lowering computations to a base monad.

Helper primitive effects are effects that allow you to avoid interpreting one of your own effects as a primitive if the power needed from direct access to the underlying monad can instead be provided by the relevant helper primitive effect. The reason why you'd want to do this is that helper primitive effects already have ThreadsEff instances defined for them; so you don't have to define any for your own effect.

The helper primitive effects offered in this library are -- in order of ascending power -- Regional, Optional, BaseControl and Unlift.

BaseControl is typically used as a primitive effect. If you define a Carrier that relies on a novel non-trivial monad transformer t, then you need to make a a ThreadsEff t (BaseControl b) instance (if possible). threadBaseControlViaClass can help you with that.

The following threading constraints accept BaseControl:

Instances
Carrier m => PrimHandler BaseControlH (BaseControl m) m Source # 
Instance details

Defined in Control.Effect.Internal.BaseControl

ThreadsEff (ExceptT e) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (ExceptT e m) a -> ExceptT e m a Source #

Monoid w => ThreadsEff (WriterT w) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (WriterT w m) a -> WriterT w m a Source #

ThreadsEff (StateT s) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (StateT s m) a -> StateT s m a Source #

ThreadsEff (ReaderT i) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (ReaderT i m) a -> ReaderT i m a Source #

ThreadsEff (StateT s) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (StateT s m) a -> StateT s m a Source #

Monoid w => ThreadsEff (WriterT w) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (WriterT w m) a -> WriterT w m a Source #

Monoid w => ThreadsEff (WriterT w) (BaseControl b) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Methods

threadEff :: Monad m => (forall x. BaseControl b m x -> m x) -> BaseControl b (WriterT w m) a -> WriterT w m a Source #

Actions

withLowerToBase :: forall b m a. Eff (BaseControl b) m => (forall f. (forall x. m x -> b (f x)) -> b (f a)) -> m a Source #

Gain access to a function that allows for lowering m to the base monad b.

This is less versatile, but easier to use than gainBaseControl.

gainBaseControl :: forall b m a. Eff (BaseControl b) m => (forall z. (MonadBaseControl b z, Coercible z m) => GainBaseControlC b z m a) -> m a Source #

Locally gain access to a MonadBaseControl b instance within a region.

You'll need to use lift if you want to use the MonadBaseControl instance with computations outside of the region. This is common with effect handlers. For example:

import System.IO (FilePath, IOMode, Handle)
import qualified System.IO as SysIO

data WithFile m a where
  WithFile :: FilePath -> IOMode -> (Handle -> m a) -> WithFile m a

runWithFile :: Eff (BaseControl IO) m => SimpleInterpreterFor WithFile m
runWithFile = interpretSimple $ case
  WithFile fp mode c -> gainBaseControl $ control $ lower ->
    SysIO.withFile fp mode (hdl -> lower (lift (c hdl)))

Interpretations

runBaseControl :: Carrier m => BaseControlC m a -> m a Source #

Run a BaseControl m effect, where the base m is the current monad.

Derivs (BaseControlC m) = BaseControl m ': Derivs m
Prims  (BaseControlC m) = BaseControl m ': Prims m

baseControlToFinal :: (MonadBaseControl b m, Carrier m) => BaseControlToFinalC b m a -> m a Source #

Run a BaseControl b effect, where the base b is the final base monad.

Derivs (BaseControlToFinalC b m) = BaseControl b ': Derivs m
Prims  (BaseControlToFinalC b m) = BaseControl b ': Prims m

MonadBaseControl

class MonadBase b m => MonadBaseControl (b :: Type -> Type) (m :: Type -> Type) | m -> b where #

Writing instances

The usual way to write a MonadBaseControl instance for a transformer stack over a base monad B is to write an instance MonadBaseControl B B for the base monad, and MonadTransControl T instances for every transformer T. Instances for MonadBaseControl are then simply implemented using ComposeSt, defaultLiftBaseWith, defaultRestoreM.

Associated Types

type StM (m :: Type -> Type) a :: Type #

Monadic state that m adds to the base monad b.

For all base (non-transformed) monads, StM m a ~ a:

StM IO         a ~ a
StM Maybe      a ~ a
StM (Either e) a ~ a
StM []         a ~ a
StM ((->) r)   a ~ a
StM Identity   a ~ a
StM STM        a ~ a
StM (ST s)     a ~ a

If m is a transformed monad, m ~ t b, StM is the monadic state of the transformer t (given by its StT from MonadTransControl). For a transformer stack, StM is defined recursively:

StM (IdentityT  m) a ~ ComposeSt IdentityT m a ~ StM m a
StM (MaybeT     m) a ~ ComposeSt MaybeT    m a ~ StM m (Maybe a)
StM (ErrorT e   m) a ~ ComposeSt ErrorT    m a ~ Error e => StM m (Either e a)
StM (ExceptT e  m) a ~ ComposeSt ExceptT   m a ~ StM m (Either e a)
StM (ListT      m) a ~ ComposeSt ListT     m a ~ StM m [a]
StM (ReaderT r  m) a ~ ComposeSt ReaderT   m a ~ StM m a
StM (StateT s   m) a ~ ComposeSt StateT    m a ~ StM m (a, s)
StM (WriterT w  m) a ~ ComposeSt WriterT   m a ~ Monoid w => StM m (a, w)
StM (RWST r w s m) a ~ ComposeSt RWST      m a ~ Monoid w => StM m (a, s, w)

Methods

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

liftBaseWith is similar to liftIO and liftBase in that it lifts a base computation to the constructed monad.

Instances should satisfy similar laws as the MonadIO and MonadBase laws:

liftBaseWith . const . return = return
liftBaseWith (const (m >>= f)) = liftBaseWith (const m) >>= liftBaseWith . const . f

The difference with liftBase is that before lifting the base computation liftBaseWith captures the state of m. It then provides the base computation with a RunInBase function that allows running m computations in the base monad on the captured state:

withFileLifted :: MonadBaseControl IO m => FilePath -> IOMode -> (Handle -> m a) -> m a
withFileLifted file mode action = liftBaseWith (\runInBase -> withFile file mode (runInBase . action)) >>= restoreM
                             -- = control $ \runInBase -> withFile file mode (runInBase . action)
                             -- = liftBaseOp (withFile file mode) action

liftBaseWith is usually not implemented directly, but using defaultLiftBaseWith.

restoreM :: StM m a -> m a #

Construct a m computation from the monadic state of m that is returned from a RunInBase function.

Instances should satisfy:

liftBaseWith (\runInBase -> runInBase m) >>= restoreM = m

restoreM is usually not implemented directly, but using defaultRestoreM.

Instances
MonadBaseControl [] [] 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM [] a :: Type #

Methods

liftBaseWith :: (RunInBase [] [] -> [a]) -> [a] #

restoreM :: StM [] a -> [a] #

MonadBaseControl Maybe Maybe 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM Maybe a :: Type #

MonadBaseControl IO IO 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM IO a :: Type #

Methods

liftBaseWith :: (RunInBase IO IO -> IO a) -> IO a #

restoreM :: StM IO a -> IO a #

MonadBaseControl Identity Identity 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM Identity a :: Type #

MonadBaseControl STM STM 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM STM a :: Type #

Methods

liftBaseWith :: (RunInBase STM STM -> STM a) -> STM a #

restoreM :: StM STM a -> STM a #

MonadBaseControl b m => MonadBaseControl b (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (MaybeT m) a :: Type #

Methods

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

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

MonadBaseControl b m => MonadBaseControl b (ListT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ListT m) a :: Type #

Methods

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

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

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

Defined in Control.Effect.Fail

Associated Types

type StM (InterpretFailSimpleC m) a :: Type #

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

Defined in Control.Effect.Alt

Associated Types

type StM (InterpretAltSimpleC m) a :: Type #

Monad m => MonadBaseControl m (Itself m) Source # 
Instance details

Defined in Control.Effect.Internal.Itself

Associated Types

type StM (Itself m) a :: Type #

Methods

liftBaseWith :: (RunInBase (Itself m) m -> m a) -> Itself m a #

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

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (WriterT w m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a #

restoreM :: StM (WriterT w m) a -> WriterT w m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (WriterT w m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a #

restoreM :: StM (WriterT w m) a -> WriterT w m a #

MonadBaseControl b m => MonadBaseControl b (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (StateT s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a #

restoreM :: StM (StateT s m) a -> StateT s m a #

MonadBaseControl b m => MonadBaseControl b (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (StateT s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a #

restoreM :: StM (StateT s m) a -> StateT s m a #

MonadBaseControl b m => MonadBaseControl b (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ReaderT r m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ReaderT r m) b -> b a) -> ReaderT r m a #

restoreM :: StM (ReaderT r m) a -> ReaderT r m a #

MonadBaseControl b m => MonadBaseControl b (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (IdentityT m) a :: Type #

Methods

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

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

MonadBaseControl b m => MonadBaseControl b (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ExceptT e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ExceptT e m) b -> b a) -> ExceptT e m a #

restoreM :: StM (ExceptT e m) a -> ExceptT e m a #

(Error e, MonadBaseControl b m) => MonadBaseControl b (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ErrorT e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ErrorT e m) b -> b a) -> ErrorT e m a #

restoreM :: StM (ErrorT e m) a -> ErrorT e m a #

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 #

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

Defined in Control.Effect.Internal.Effly

Associated Types

type StM (Effly m) a :: Type #

Methods

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

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

MonadBaseControl b m => MonadBaseControl b (InterpretPrimSimpleC e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (InterpretPrimSimpleC e m) a :: Type #

MonadBaseControl b m => MonadBaseControl b (InterpretSimpleC e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (InterpretSimpleC e m) a :: Type #

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 #

(Monoid s, MonadBaseControl b m) => MonadBaseControl b (WriterCPS s m) Source # 
Instance details

Defined in Control.Effect.Type.Internal.BaseControl

Associated Types

type StM (WriterCPS s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WriterCPS s m) b -> b a) -> WriterCPS s m a #

restoreM :: StM (WriterCPS s m) a -> WriterCPS s m a #

(Monoid s, MonadBaseControl b m) => MonadBaseControl b (WriterLazyC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (WriterLazyC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WriterLazyC s m) b -> b a) -> WriterLazyC s m a #

restoreM :: StM (WriterLazyC s m) a -> WriterLazyC s m a #

(Monoid s, MonadBaseControl b m) => MonadBaseControl b (ListenLazyC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (ListenLazyC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ListenLazyC s m) b -> b a) -> ListenLazyC s m a #

restoreM :: StM (ListenLazyC s m) a -> ListenLazyC s m a #

(Monoid s, MonadBaseControl b m) => MonadBaseControl b (TellLazyC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (TellLazyC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (TellLazyC s m) b -> b a) -> TellLazyC s m a #

restoreM :: StM (TellLazyC s m) a -> TellLazyC s m a #

(MonadBaseControl b m, Monoid s) => MonadBaseControl b (WriterC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (WriterC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WriterC s m) b -> b a) -> WriterC s m a #

restoreM :: StM (WriterC s m) a -> WriterC s m a #

(MonadBaseControl b m, Monoid s) => MonadBaseControl b (ListenC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (ListenC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ListenC s m) b -> b a) -> ListenC s m a #

restoreM :: StM (ListenC s m) a -> ListenC s m a #

(MonadBaseControl b m, Monoid s) => MonadBaseControl b (TellC s m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type StM (TellC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (TellC s m) b -> b a) -> TellC s m a #

restoreM :: StM (TellC s m) a -> TellC s m a #

MonadBaseControl b m => MonadBaseControl b (StateLazyC s m) Source # 
Instance details

Defined in Control.Effect.Internal.State

Associated Types

type StM (StateLazyC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (StateLazyC s m) b -> b a) -> StateLazyC s m a #

restoreM :: StM (StateLazyC s m) a -> StateLazyC s m a #

MonadBaseControl b m => MonadBaseControl b (StateC s m) Source # 
Instance details

Defined in Control.Effect.Internal.State

Associated Types

type StM (StateC s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (StateC s m) b -> b a) -> StateC s m a #

restoreM :: StM (StateC s m) a -> StateC s m a #

MonadBaseControl b m => MonadBaseControl b (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Associated Types

type StM (ReaderC i m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ReaderC i m) b -> b a) -> ReaderC i m a #

restoreM :: StM (ReaderC i m) a -> ReaderC i m a #

MonadBaseControl b m => MonadBaseControl b (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (UnwrapTopC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (UnwrapTopC e m) b -> b a) -> UnwrapTopC e m a #

restoreM :: StM (UnwrapTopC e m) a -> UnwrapTopC e m a #

MonadBaseControl b m => MonadBaseControl b (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (UnwrapC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (UnwrapC e m) b -> b a) -> UnwrapC e m a #

restoreM :: StM (UnwrapC e m) a -> UnwrapC e m a #

MonadBaseControl b m => MonadBaseControl b (ErrorC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Error

Associated Types

type StM (ErrorC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ErrorC e m) b -> b a) -> ErrorC e m a #

restoreM :: StM (ErrorC e m) a -> ErrorC e m a #

MonadBaseControl b m => MonadBaseControl b (ThrowC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Error

Associated Types

type StM (ThrowC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ThrowC e m) b -> b a) -> ThrowC e m a #

restoreM :: StM (ThrowC e m) a -> ThrowC e m a #

MonadBaseControl b m => MonadBaseControl b (InterceptRC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Intercept

Associated Types

type StM (InterceptRC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (InterceptRC e m) b -> b a) -> InterceptRC e m a #

restoreM :: StM (InterceptRC e m) a -> InterceptRC e m a #

MonadBaseControl b m => MonadBaseControl b (InterpretFailC h m) Source # 
Instance details

Defined in Control.Effect.Fail

Associated Types

type StM (InterpretFailC h m) a :: Type #

Methods

liftBaseWith :: (RunInBase (InterpretFailC h m) b -> b a) -> InterpretFailC h m a #

restoreM :: StM (InterpretFailC h m) a -> InterpretFailC h m a #

MonadBaseControl b m => MonadBaseControl b (InterpretAltC h m) Source # 
Instance details

Defined in Control.Effect.Alt

Associated Types

type StM (InterpretAltC h m) a :: Type #

Methods

liftBaseWith :: (RunInBase (InterpretAltC h m) b -> b a) -> InterpretAltC h m a #

restoreM :: StM (InterpretAltC h m) a -> InterpretAltC h m a #

MonadBaseControl b m => MonadBaseControl b (SubsumeC e m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type StM (SubsumeC e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (SubsumeC e m) b -> b a) -> SubsumeC e m a #

restoreM :: StM (SubsumeC e m) a -> SubsumeC e m a #

MonadBaseControl b m => MonadBaseControl b (IntroC top new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Intro

Associated Types

type StM (IntroC top new m) a :: Type #

Methods

liftBaseWith :: (RunInBase (IntroC top new m) b -> b a) -> IntroC top new m a #

restoreM :: StM (IntroC top new m) a -> IntroC top new m a #

MonadBaseControl b m => MonadBaseControl b (ReinterpretSimpleC e new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (ReinterpretSimpleC e new m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ReinterpretSimpleC e new m) b -> b a) -> ReinterpretSimpleC e new m a #

restoreM :: StM (ReinterpretSimpleC e new m) a -> ReinterpretSimpleC e new m a #

MonadBaseControl b m => MonadBaseControl b (InterpretC h e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (InterpretC h e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (InterpretC h e m) b -> b a) -> InterpretC h e m a #

restoreM :: StM (InterpretC h e m) a -> InterpretC h e m a #

MonadBaseControl b m => MonadBaseControl b (InterpretPrimC s e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (InterpretPrimC s e m) a :: Type #

Methods

liftBaseWith :: (RunInBase (InterpretPrimC s e m) b -> b a) -> InterpretPrimC s e m a #

restoreM :: StM (InterpretPrimC s e m) a -> InterpretPrimC s e m a #

MonadBaseControl b m => MonadBaseControl b (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StM (UnionC l m) a :: Type #

Methods

liftBaseWith :: (RunInBase (UnionC l m) b -> b a) -> UnionC l m a #

restoreM :: StM (UnionC l m) a -> UnionC l m a #

MonadBaseControl b m => MonadBaseControl b (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (WrapC e e' m) a :: Type #

Methods

liftBaseWith :: (RunInBase (WrapC e e' m) b -> b a) -> WrapC e e' m a #

restoreM :: StM (WrapC e e' m) a -> WrapC e e' m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (RWST r w s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a #

restoreM :: StM (RWST r w s m) a -> RWST r w s m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (RWST r w s m) a :: Type #

Methods

liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a #

restoreM :: StM (RWST r w s m) a -> RWST r w s m a #

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 #

MonadBaseControl b m => MonadBaseControl b (ReinterpretC h e new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type StM (ReinterpretC h e new m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ReinterpretC h e new m) b -> b a) -> ReinterpretC h e new m a #

restoreM :: StM (ReinterpretC h e new m) a -> ReinterpretC h e new m a #

MonadBaseControl b' m => MonadBaseControl b' (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type StM (UnionizeC b m) a :: Type #

Methods

liftBaseWith :: (RunInBase (UnionizeC b m) b' -> b' a) -> UnionizeC b m a #

restoreM :: StM (UnionizeC b m) a -> UnionizeC b m a #

MonadBaseControl b m => MonadBaseControl b (ExceptionallyC eff exc m) Source # 
Instance details

Defined in Control.Effect.Exceptional

Associated Types

type StM (ExceptionallyC eff exc m) a :: Type #

Methods

liftBaseWith :: (RunInBase (ExceptionallyC eff exc m) b -> b a) -> ExceptionallyC eff exc m a #

restoreM :: StM (ExceptionallyC eff exc m) a -> ExceptionallyC eff exc m a #

(Monad m, MonadBaseControl b z, Coercible z m) => MonadBaseControl b (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Associated Types

type StM (GainBaseControlC b z m) a :: Type #

Methods

liftBaseWith :: (RunInBase (GainBaseControlC b z m) b -> b a) -> GainBaseControlC b z m a #

restoreM :: StM (GainBaseControlC b z m) a -> GainBaseControlC b z m a #

MonadBaseControl (Either e) (Either e) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (Either e) a :: Type #

Methods

liftBaseWith :: (RunInBase (Either e) (Either e) -> Either e a) -> Either e a #

restoreM :: StM (Either e) a -> Either e a #

MonadBaseControl (ST s) (ST s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ST s) a :: Type #

Methods

liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a #

restoreM :: StM (ST s) a -> ST s a #

MonadBaseControl (ST s) (ST s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ST s) a :: Type #

Methods

liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a #

restoreM :: StM (ST s) a -> ST s a #

MonadBaseControl ((->) r :: Type -> Type) ((->) r :: Type -> Type) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM ((->) r) a :: Type #

Methods

liftBaseWith :: (RunInBase ((->) r) ((->) r) -> r -> a) -> r -> a #

restoreM :: StM ((->) r) a -> r -> a #

control :: MonadBaseControl b m => (RunInBase m b -> b (StM m a)) -> m a #

An often used composition: control f = liftBaseWith f >>= restoreM

Example:

liftedBracket :: MonadBaseControl IO m => m a -> (a -> m b) -> (a -> m c) -> m c
liftedBracket acquire release action = control $ \runInBase ->
    bracket (runInBase acquire)
            (\saved -> runInBase (restoreM saved >>= release))
            (\saved -> runInBase (restoreM saved >>= action))

Threading utilities

threadBaseControlViaClass :: forall b t m a. (MonadTrans t, Monad m, forall z. MonadBaseControl b z => MonadBaseControl b (t z), forall z. Coercible z m => Coercible (t z) (t m)) => (forall x. BaseControl b m x -> m x) -> BaseControl b (t m) a -> t m a Source #

A valid definition of threadEff for a ThreadsEff t (BaseControl b) instance, given that t lifts MonadBaseControl b for any b.

Combinators for Algebras

powerAlgBaseControl :: forall m p a. Monad m => Algebra' p m a -> Algebra' (BaseControl m ': p) m a Source #

Strengthen an Algebra p m by adding a BaseControl m handler

powerAlgBaseControlFinal :: forall b m p a. MonadBaseControl b m => Algebra' p m a -> Algebra' (BaseControl b ': p) m a Source #

Strengthen an Algebra p m by adding a BaseControl b handler, where b is the final base monad.

Carriers

newtype GainBaseControlC b z m a Source #

Constructors

GainBaseControlC 

Fields

Instances
(Monad m, MonadBase b z, Coercible z m) => MonadBase b (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

liftBase :: b α -> GainBaseControlC b z m α #

(Monad m, MonadBaseControl b z, Coercible z m) => MonadBaseControl b (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Associated Types

type StM (GainBaseControlC b z m) a :: Type #

Methods

liftBaseWith :: (RunInBase (GainBaseControlC b z m) b -> b a) -> GainBaseControlC b z m a #

restoreM :: StM (GainBaseControlC b z m) a -> GainBaseControlC b z m a #

MonadTrans (GainBaseControlC b z :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

lift :: Monad m => m a -> GainBaseControlC b z m a #

MonadTransControl (GainBaseControlC b z :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.BaseControl

Associated Types

type StT (GainBaseControlC b z) a :: Type #

Methods

liftWith :: Monad m => (Run (GainBaseControlC b z) -> m a) -> GainBaseControlC b z m a #

restoreT :: Monad m => m (StT (GainBaseControlC b z) a) -> GainBaseControlC b z m a #

Monad m => Monad (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

(>>=) :: GainBaseControlC b z m a -> (a -> GainBaseControlC b z m b0) -> GainBaseControlC b z m b0 #

(>>) :: GainBaseControlC b z m a -> GainBaseControlC b z m b0 -> GainBaseControlC b z m b0 #

return :: a -> GainBaseControlC b z m a #

fail :: String -> GainBaseControlC b z m a #

Functor m => Functor (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

fmap :: (a -> b0) -> GainBaseControlC b z m a -> GainBaseControlC b z m b0 #

(<$) :: a -> GainBaseControlC b z m b0 -> GainBaseControlC b z m a #

MonadFix m => MonadFix (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

mfix :: (a -> GainBaseControlC b z m a) -> GainBaseControlC b z m a #

MonadFail m => MonadFail (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

fail :: String -> GainBaseControlC b z m a #

Applicative m => Applicative (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

pure :: a -> GainBaseControlC b z m a #

(<*>) :: GainBaseControlC b z m (a -> b0) -> GainBaseControlC b z m a -> GainBaseControlC b z m b0 #

liftA2 :: (a -> b0 -> c) -> GainBaseControlC b z m a -> GainBaseControlC b z m b0 -> GainBaseControlC b z m c #

(*>) :: GainBaseControlC b z m a -> GainBaseControlC b z m b0 -> GainBaseControlC b z m b0 #

(<*) :: GainBaseControlC b z m a -> GainBaseControlC b z m b0 -> GainBaseControlC b z m a #

MonadIO m => MonadIO (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

liftIO :: IO a -> GainBaseControlC b z m a #

Alternative m => Alternative (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

empty :: GainBaseControlC b z m a #

(<|>) :: GainBaseControlC b z m a -> GainBaseControlC b z m a -> GainBaseControlC b z m a #

some :: GainBaseControlC b z m a -> GainBaseControlC b z m [a] #

many :: GainBaseControlC b z m a -> GainBaseControlC b z m [a] #

MonadPlus m => MonadPlus (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

mzero :: GainBaseControlC b z m a #

mplus :: GainBaseControlC b z m a -> GainBaseControlC b z m a -> GainBaseControlC b z m a #

MonadThrow m => MonadThrow (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

throwM :: Exception e => e -> GainBaseControlC b z m a #

MonadCatch m => MonadCatch (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

catch :: Exception e => GainBaseControlC b z m a -> (e -> GainBaseControlC b z m a) -> GainBaseControlC b z m a #

MonadMask m => MonadMask (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Methods

mask :: ((forall a. GainBaseControlC b z m a -> GainBaseControlC b z m a) -> GainBaseControlC b z m b0) -> GainBaseControlC b z m b0 #

uninterruptibleMask :: ((forall a. GainBaseControlC b z m a -> GainBaseControlC b z m a) -> GainBaseControlC b z m b0) -> GainBaseControlC b z m b0 #

generalBracket :: GainBaseControlC b z m a -> (a -> ExitCase b0 -> GainBaseControlC b z m c) -> (a -> GainBaseControlC b z m b0) -> GainBaseControlC b z m (b0, c) #

Carrier m => Carrier (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Associated Types

type Derivs (GainBaseControlC b z m) :: [Effect] Source #

type Prims (GainBaseControlC b z m) :: [Effect] Source #

type StT (GainBaseControlC b z :: (Type -> Type) -> Type -> Type) a Source # 
Instance details

Defined in Control.Effect.BaseControl

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

Defined in Control.Effect.BaseControl

type Derivs (GainBaseControlC b z m) = Derivs m
type Prims (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

type Prims (GainBaseControlC b z m) = Prims m
type StM (GainBaseControlC b z m) a Source # 
Instance details

Defined in Control.Effect.BaseControl

type StM (GainBaseControlC b z m) a = StM z a

data BaseControlC m a Source #

Instances
MonadTrans (BaseControlC :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

Defined in Control.Effect.Internal.BaseControl

Associated Types

type StT BaseControlC a :: Type #

Methods

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

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

return :: a -> BaseControlC m a #

fail :: String -> BaseControlC m a #

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

fail :: String -> BaseControlC m a #

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

Defined in Control.Effect.Internal.BaseControl

Methods

pure :: a -> BaseControlC m a #

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

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

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

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

liftIO :: IO a -> BaseControlC m a #

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

Defined in Control.Effect.Internal.BaseControl

Methods

empty :: BaseControlC m a #

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

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

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

mzero :: BaseControlC m a #

mplus :: BaseControlC m a -> BaseControlC m a -> BaseControlC m a #

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

Defined in Control.Effect.Internal.BaseControl

Methods

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

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

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

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

Defined in Control.Effect.Internal.BaseControl

Associated Types

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

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

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

Defined in Control.Effect.Internal.BaseControl

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

Defined in Control.Effect.Internal.BaseControl

type Prims (BaseControlC m) Source # 
Instance details

Defined in Control.Effect.Internal.BaseControl

type BaseControlToFinalC b = InterpretPrimC BaseControlToFinalH (BaseControl b) Source #