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

Control.Effect.Reader

Synopsis

Effects

data Ask i :: Effect where Source #

An effect for arbitrary input

Constructors

Ask :: Ask i m i 

data Local i :: Effect where Source #

An effect for locally modifying an environment used to gain access to information.

Constructors

Local :: (i -> i) -> m a -> Local i m a 

type Reader i = Bundle [Local i, Ask i] Source #

A pseudo-effect for connected Ask i and Local i effects.

Reader should only ever be used inside of Eff and Effs constraints. It is not a real effect! See Bundle.

Actions

ask :: Eff (Ask i) m => m i Source #

asks :: Eff (Ask i) m => (i -> a) -> m a Source #

local :: Eff (Local i) m => (i -> i) -> m a -> m a Source #

Interpretations

runAskConst :: forall i m a. Carrier m => i -> InterpretReifiedC (Ask i) m a -> m a Source #

Run an Ask effect by providing a constant to be given at each use of ask.

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

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

runAskAction :: forall i m a. Carrier m => m i -> InterpretReifiedC (Ask i) m a -> m a Source #

Run an Ask effect by providing an action to be executed at each use of ask.

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

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

askToAsk :: forall i j m a. Eff (Ask j) m => (j -> i) -> InterpretReifiedC (Ask i) m a -> m a Source #

Transform an Ask i effect into an Ask j effect by providing a function to convert j to i.

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

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

runReader :: forall i m a p. (Carrier m, Threaders '[ReaderThreads] m p) => i -> ReaderC i m a -> m a Source #

Run connected Ask i and Local i effects -- i.e. Reader i.

Derivs (ReaderC i m) = Local i ': Ask i ': Derivs m
Prims  (ReaderC i m) = ReaderPrim i ': Prims m

Simple variants

runAskConstSimple :: forall i m a p. (Carrier m, Threaders '[ReaderThreads] m p) => i -> InterpretSimpleC (Ask i) m a -> m a Source #

Run an Ask effect by providing a constant to be given at each use of ask

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

runAskActionSimple :: forall i m a p. (Carrier m, Threaders '[ReaderThreads] m p) => m i -> InterpretSimpleC (Ask i) m a -> m a Source #

Run an Ask effect by providing an action to be executed at each use of ask.

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

askToAskSimple :: forall i j m a p. (Eff (Ask j) m, Threaders '[ReaderThreads] m p) => (j -> i) -> InterpretSimpleC (Ask i) m a -> m a Source #

Transform an Ask i effect into an Ask j effect by providing a function to convert j to i.

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

Threading constraints

class (forall i. Threads (ReaderT i) p) => ReaderThreads p Source #

The most common threading constraint of the library, as it is emitted by -Simple interpreters (interpreters that internally make use of interpretSimple or reinterpretSimple).

ReaderThreads accepts all the primitive effects (intended to be used as such) offered in this library.

Most notably, ReaderThreads accepts Unlift b.

Instances

Instances details
(forall i. Threads (ReaderT i) p) => ReaderThreads p Source # 
Instance details

Defined in Control.Effect.Internal.Union

Carriers

data ReaderC i m a Source #

Instances

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

Defined in Control.Effect.Internal.Reader

Methods

liftBase :: b α -> ReaderC i m α #

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 #

Methods

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

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

MonadTrans (ReaderC i) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

lift :: Monad m => m a -> ReaderC i m a #

MonadTransControl (ReaderC i) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Associated Types

type StT (ReaderC i) a #

Methods

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

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

Monad m => Monad (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

(>>=) :: ReaderC i m a -> (a -> ReaderC i m b) -> ReaderC i m b #

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

return :: a -> ReaderC i m a #

Functor m => Functor (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

fmap :: (a -> b) -> ReaderC i m a -> ReaderC i m b #

(<$) :: a -> ReaderC i m b -> ReaderC i m a #

MonadFix m => MonadFix (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

mfix :: (a -> ReaderC i m a) -> ReaderC i m a #

MonadFail m => MonadFail (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

fail :: String -> ReaderC i m a #

Applicative m => Applicative (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

pure :: a -> ReaderC i m a #

(<*>) :: ReaderC i m (a -> b) -> ReaderC i m a -> ReaderC i m b #

liftA2 :: (a -> b -> c) -> ReaderC i m a -> ReaderC i m b -> ReaderC i m c #

(*>) :: ReaderC i m a -> ReaderC i m b -> ReaderC i m b #

(<*) :: ReaderC i m a -> ReaderC i m b -> ReaderC i m a #

MonadIO m => MonadIO (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

liftIO :: IO a -> ReaderC i m a #

Alternative m => Alternative (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

empty :: ReaderC i m a #

(<|>) :: ReaderC i m a -> ReaderC i m a -> ReaderC i m a #

some :: ReaderC i m a -> ReaderC i m [a] #

many :: ReaderC i m a -> ReaderC i m [a] #

MonadPlus m => MonadPlus (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

mzero :: ReaderC i m a #

mplus :: ReaderC i m a -> ReaderC i m a -> ReaderC i m a #

MonadThrow m => MonadThrow (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

throwM :: Exception e => e -> ReaderC i m a #

MonadCatch m => MonadCatch (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

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

MonadMask m => MonadMask (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Methods

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

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

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

(Threads (ReaderT i) (Prims m), Carrier m) => Carrier (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Associated Types

type Derivs (ReaderC i m) :: [Effect] Source #

type Prims (ReaderC i m) :: [Effect] Source #

type StT (ReaderC i) a Source # 
Instance details

Defined in Control.Effect.Internal.Reader

type StT (ReaderC i) a = StT (ReaderT i) a
type Derivs (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

type Derivs (ReaderC i m) = Local i ': (Ask i ': Derivs m)
type Prims (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

type Prims (ReaderC i m) = ReaderPrim i ': Prims m
type StM (ReaderC i m) a Source # 
Instance details

Defined in Control.Effect.Internal.Reader

type StM (ReaderC i m) a = StM (ReaderT i m) a