constrained-monads-0.1.0.0: Typeclasses and instances for monads with constraints.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Constrained.Reader

Description

This module duplicates the Control.Monad.Reader module from the mtl, for constrained monads.

Synopsis

Documentation

class Monad m => MonadReader r m | m -> r where Source #

A class for reader monads.

Minimal complete definition

reader, local

Associated Types

type ReaderSuitable m a :: Constraint Source #

Methods

ask :: ReaderSuitable m r => m r Source #

Retrieves the environment

local :: (ReaderSuitable m a, ReaderSuitable m r) => (r -> r) -> m a -> m a Source #

Executes a computation in a modified environment.

reader :: (ReaderSuitable m r, ReaderSuitable m a) => (r -> a) -> m a Source #

Retrieves a function of the current environment.

Instances

MonadReader r m => MonadReader r (MaybeT m) Source # 

Associated Types

type ReaderSuitable (MaybeT m :: * -> *) a :: Constraint Source #

Methods

ask :: MaybeT m r Source #

local :: (ReaderSuitable (MaybeT m) a, ReaderSuitable (MaybeT m) r) => (r -> r) -> MaybeT m a -> MaybeT m a Source #

reader :: (ReaderSuitable (MaybeT m) r, ReaderSuitable (MaybeT m) a) => (r -> a) -> MaybeT m a Source #

MonadReader r ((->) r) Source # 

Associated Types

type ReaderSuitable ((->) r :: * -> *) a :: Constraint Source #

Methods

ask :: r -> r Source #

local :: (ReaderSuitable ((->) r) a, ReaderSuitable ((->) r) r) => (r -> r) -> (r -> a) -> r -> a Source #

reader :: (ReaderSuitable ((->) r) r, ReaderSuitable ((->) r) a) => (r -> a) -> r -> a Source #

MonadReader r m => MonadReader r (StateT s m) Source # 

Associated Types

type ReaderSuitable (StateT s m :: * -> *) a :: Constraint Source #

Methods

ask :: StateT s m r Source #

local :: (ReaderSuitable (StateT s m) a, ReaderSuitable (StateT s m) r) => (r -> r) -> StateT s m a -> StateT s m a Source #

reader :: (ReaderSuitable (StateT s m) r, ReaderSuitable (StateT s m) a) => (r -> a) -> StateT s m a Source #

MonadReader r m => MonadReader r (StateT s m) Source # 

Associated Types

type ReaderSuitable (StateT s m :: * -> *) a :: Constraint Source #

Methods

ask :: StateT s m r Source #

local :: (ReaderSuitable (StateT s m) a, ReaderSuitable (StateT s m) r) => (r -> r) -> StateT s m a -> StateT s m a Source #

reader :: (ReaderSuitable (StateT s m) r, ReaderSuitable (StateT s m) a) => (r -> a) -> StateT s m a Source #

MonadReader r m => MonadReader r (IdentityT * m) Source # 

Associated Types

type ReaderSuitable (IdentityT * m :: * -> *) a :: Constraint Source #

Methods

ask :: IdentityT * m r Source #

local :: (ReaderSuitable (IdentityT * m) a, ReaderSuitable (IdentityT * m) r) => (r -> r) -> IdentityT * m a -> IdentityT * m a Source #

reader :: (ReaderSuitable (IdentityT * m) r, ReaderSuitable (IdentityT * m) a) => (r -> a) -> IdentityT * m a Source #

MonadReader r m => MonadReader r (ExceptT e m) Source # 

Associated Types

type ReaderSuitable (ExceptT e m :: * -> *) a :: Constraint Source #

Methods

ask :: ExceptT e m r Source #

local :: (ReaderSuitable (ExceptT e m) a, ReaderSuitable (ExceptT e m) r) => (r -> r) -> ExceptT e m a -> ExceptT e m a Source #

reader :: (ReaderSuitable (ExceptT e m) r, ReaderSuitable (ExceptT e m) a) => (r -> a) -> ExceptT e m a Source #

MonadReader r m => MonadReader r (WriterT w m) Source # 

Associated Types

type ReaderSuitable (WriterT w m :: * -> *) a :: Constraint Source #

Methods

ask :: WriterT w m r Source #

local :: (ReaderSuitable (WriterT w m) a, ReaderSuitable (WriterT w m) r) => (r -> r) -> WriterT w m a -> WriterT w m a Source #

reader :: (ReaderSuitable (WriterT w m) r, ReaderSuitable (WriterT w m) a) => (r -> a) -> WriterT w m a Source #

MonadReader r' m => MonadReader r' (ContT * r m) Source # 

Associated Types

type ReaderSuitable (ContT * r m :: * -> *) a :: Constraint Source #

Methods

ask :: ContT * r m r' Source #

local :: (ReaderSuitable (ContT * r m) a, ReaderSuitable (ContT * r m) r') => (r' -> r') -> ContT * r m a -> ContT * r m a Source #

reader :: (ReaderSuitable (ContT * r m) r', ReaderSuitable (ContT * r m) a) => (r' -> a) -> ContT * r m a Source #

Monad m => MonadReader r (ReaderT * r m) Source # 

Associated Types

type ReaderSuitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

ask :: ReaderT * r m r Source #

local :: (ReaderSuitable (ReaderT * r m) a, ReaderSuitable (ReaderT * r m) r) => (r -> r) -> ReaderT * r m a -> ReaderT * r m a Source #

reader :: (ReaderSuitable (ReaderT * r m) r, ReaderSuitable (ReaderT * r m) a) => (r -> a) -> ReaderT * r m a Source #

newtype ReaderT k r m a :: forall k. * -> (k -> *) -> k -> * #

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

Constructors

ReaderT 

Fields

Instances

MonadError e m => MonadError e (ReaderT * r m) Source # 

Associated Types

type SuitableError (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

throwError :: SuitableError (ReaderT * r m) a => e -> ReaderT * r m a Source #

catchError :: SuitableError (ReaderT * r m) a => ReaderT * r m a -> (e -> ReaderT * r m a) -> ReaderT * r m a Source #

Monad m => MonadReader r (ReaderT * r m) Source # 

Associated Types

type ReaderSuitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

ask :: ReaderT * r m r Source #

local :: (ReaderSuitable (ReaderT * r m) a, ReaderSuitable (ReaderT * r m) r) => (r -> r) -> ReaderT * r m a -> ReaderT * r m a Source #

reader :: (ReaderSuitable (ReaderT * r m) r, ReaderSuitable (ReaderT * r m) a) => (r -> a) -> ReaderT * r m a Source #

MonadState s m => MonadState s (ReaderT * r m) Source # 

Associated Types

type StateSuitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

get :: ReaderT * r m s Source #

put :: s -> ReaderT * r m () Source #

state :: (StateSuitable (ReaderT * r m) a, StateSuitable (ReaderT * r m) s) => (s -> (a, s)) -> ReaderT * r m a Source #

MonadWriter w m => MonadWriter w (ReaderT * r m) Source # 

Associated Types

type WriterSuitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

writer :: WriterSuitable (ReaderT * r m) a => (a, w) -> ReaderT * r m a Source #

tell :: w -> ReaderT * r m () Source #

listenC :: WriterSuitable (ReaderT * r m) b => (a -> w -> b) -> ReaderT * r m a -> ReaderT * r m b Source #

passC :: WriterSuitable (ReaderT * r m) a => (a -> w -> w) -> ReaderT * r m a -> ReaderT * r m a Source #

MonadTrans (ReaderT * r) 

Methods

lift :: Monad m => m a -> ReaderT * r m a #

MonadTrans (ReaderT * r) Source # 

Associated Types

type SuitableLift (ReaderT * r :: (* -> *) -> * -> *) (m :: * -> *) a :: Constraint Source #

Methods

lift :: (Monad m, SuitableLift (ReaderT * r) m a) => m a -> ReaderT * r m a Source #

Monad m => Monad (ReaderT * r m) 

Methods

(>>=) :: ReaderT * r m a -> (a -> ReaderT * r m b) -> ReaderT * r m b #

(>>) :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m b #

return :: a -> ReaderT * r m a #

fail :: String -> ReaderT * r m a #

Functor m => Functor (ReaderT * r m) 

Methods

fmap :: (a -> b) -> ReaderT * r m a -> ReaderT * r m b #

(<$) :: a -> ReaderT * r m b -> ReaderT * r m a #

MonadFix m => MonadFix (ReaderT * r m) 

Methods

mfix :: (a -> ReaderT * r m a) -> ReaderT * r m a #

MonadFail m => MonadFail (ReaderT * r m) 

Methods

fail :: String -> ReaderT * r m a #

Applicative m => Applicative (ReaderT * r m) 

Methods

pure :: a -> ReaderT * r m a #

(<*>) :: ReaderT * r m (a -> b) -> ReaderT * r m a -> ReaderT * r m b #

(*>) :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m b #

(<*) :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m a #

MonadZip m => MonadZip (ReaderT * r m) 

Methods

mzip :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m (a, b) #

mzipWith :: (a -> b -> c) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c #

munzip :: ReaderT * r m (a, b) -> (ReaderT * r m a, ReaderT * r m b) #

MonadIO m => MonadIO (ReaderT * r m) 

Methods

liftIO :: IO a -> ReaderT * r m a #

Alternative m => Alternative (ReaderT * r m) 

Methods

empty :: ReaderT * r m a #

(<|>) :: ReaderT * r m a -> ReaderT * r m a -> ReaderT * r m a #

some :: ReaderT * r m a -> ReaderT * r m [a] #

many :: ReaderT * r m a -> ReaderT * r m [a] #

MonadPlus m => MonadPlus (ReaderT * r m) 

Methods

mzero :: ReaderT * r m a #

mplus :: ReaderT * r m a -> ReaderT * r m a -> ReaderT * r m a #

Alternative m => Alternative (ReaderT * r m) Source # 

Methods

empty :: Suitable (ReaderT * r m) a => ReaderT * r m a Source #

(<|>) :: Suitable (ReaderT * r m) a => ReaderT * r m a -> ReaderT * r m a -> ReaderT * r m a Source #

some :: Suitable (ReaderT * r m) [a] => ReaderT * r m a -> ReaderT * r m [a] Source #

many :: Suitable (ReaderT * r m) [a] => ReaderT * r m a -> ReaderT * r m [a] Source #

Monad m => Monad (ReaderT * r m) Source # 

Methods

(>>=) :: Suitable (ReaderT * r m) b => ReaderT * r m a -> (a -> ReaderT * r m b) -> ReaderT * r m b Source #

Applicative m => Applicative (ReaderT * r m) Source # 

Methods

pure :: Suitable (ReaderT * r m) a => a -> ReaderT * r m a Source #

(<*>) :: Suitable (ReaderT * r m) b => ReaderT * r m (a -> b) -> ReaderT * r m a -> ReaderT * r m b Source #

(*>) :: Suitable (ReaderT * r m) b => ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m b Source #

(<*) :: Suitable (ReaderT * r m) a => ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m a Source #

liftA :: Suitable (ReaderT * r m) b => (Vect xs -> b) -> AppVect (ReaderT * r m) xs -> ReaderT * r m b Source #

liftA2 :: Suitable (ReaderT * r m) c => (a -> b -> c) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c Source #

liftA3 :: Suitable (ReaderT * r m) d => (a -> b -> c -> d) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d Source #

liftA4 :: Suitable (ReaderT * r m) e => (a -> b -> c -> d -> e) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e Source #

liftA5 :: Suitable (ReaderT * r m) g => (a -> b -> c -> d -> e -> g) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g Source #

liftA6 :: Suitable (ReaderT * r m) h => (a -> b -> c -> d -> e -> g -> h) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h Source #

liftA7 :: Suitable (ReaderT * r m) i => (a -> b -> c -> d -> e -> g -> h -> i) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i Source #

liftA8 :: Suitable (ReaderT * r m) j => (a -> b -> c -> d -> e -> g -> h -> i -> j) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i -> ReaderT * r m j Source #

liftA9 :: Suitable (ReaderT * r m) k => (a -> b -> c -> d -> e -> g -> h -> i -> j -> k) -> ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m c -> ReaderT * r m d -> ReaderT * r m e -> ReaderT * r m g -> ReaderT * r m h -> ReaderT * r m i -> ReaderT * r m j -> ReaderT * r m k Source #

Functor m => Functor (ReaderT * r m) Source # 

Associated Types

type Suitable (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

fmap :: Suitable (ReaderT * r m) b => (a -> b) -> ReaderT * r m a -> ReaderT * r m b Source #

(<$) :: Suitable (ReaderT * r m) a => a -> ReaderT * r m b -> ReaderT * r m a Source #

MonadCont m => MonadCont (ReaderT * r m) Source # 

Methods

callCC :: ((a -> ReaderT * r m b) -> ReaderT * r m a) -> ReaderT * r m a Source #

MonadIO m => MonadIO (ReaderT * r m) Source # 

Associated Types

type SuitableIO (ReaderT * r m :: * -> *) a :: Constraint Source #

Methods

liftIO :: SuitableIO (ReaderT * r m) a => IO a -> ReaderT * r m a Source #

type SuitableLift (ReaderT * r) m a Source # 
type SuitableLift (ReaderT * r) m a = ()
type Suitable (ReaderT * r m) a Source # 
type Suitable (ReaderT * r m) a = Suitable m a
type SuitableError (ReaderT * r m) a Source # 
type SuitableIO (ReaderT * r m) a Source # 
type SuitableIO (ReaderT * r m) a = SuitableIO m a
type ReaderSuitable (ReaderT * r m) a Source # 
type ReaderSuitable (ReaderT * r m) a = Suitable m a
type StateSuitable (ReaderT * r m) a Source # 
type WriterSuitable (ReaderT * r m) a Source # 

type Reader r = ReaderT * r Identity #

The parameterizable reader monad.

Computations are functions of a shared environment.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.