adjunctions-4.4.2: Adjunctions and representable functors
Copyright(c) Edward Kmett 2011
(c) Conal Elliott 2008
LicenseBSD3
Maintainerekmett@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Representable.Reader

Description

Representable functors on Hask are all monads, because they are isomorphic to a Reader monad.

Synopsis

Representable functor monad

runReader :: Representable f => Reader f b -> Rep f -> b Source #

Monad Transformer

newtype ReaderT f m b Source #

Constructors

ReaderT 

Fields

Instances

Instances details
(Representable f, MonadWriter w m) => MonadWriter w (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

writer :: (a, w) -> ReaderT f m a Source #

tell :: w -> ReaderT f m () Source #

listen :: ReaderT f m a -> ReaderT f m (a, w) Source #

pass :: ReaderT f m (a, w -> w) -> ReaderT f m a Source #

Representable f => MonadTrans (ReaderT f) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

lift :: Monad m => m a -> ReaderT f m a Source #

(Representable f, Representable m) => Representable (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Associated Types

type Rep (ReaderT f m) Source #

Methods

tabulate :: (Rep (ReaderT f m) -> a) -> ReaderT f m a Source #

index :: ReaderT f m a -> Rep (ReaderT f m) -> a Source #

(Representable f, MonadIO m) => MonadIO (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

liftIO :: IO a -> ReaderT f m a Source #

(Foldable f, Foldable m) => Foldable (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

fold :: Monoid m0 => ReaderT f m m0 -> m0 Source #

foldMap :: Monoid m0 => (a -> m0) -> ReaderT f m a -> m0 Source #

foldMap' :: Monoid m0 => (a -> m0) -> ReaderT f m a -> m0 Source #

foldr :: (a -> b -> b) -> b -> ReaderT f m a -> b Source #

foldr' :: (a -> b -> b) -> b -> ReaderT f m a -> b Source #

foldl :: (b -> a -> b) -> b -> ReaderT f m a -> b Source #

foldl' :: (b -> a -> b) -> b -> ReaderT f m a -> b Source #

foldr1 :: (a -> a -> a) -> ReaderT f m a -> a Source #

foldl1 :: (a -> a -> a) -> ReaderT f m a -> a Source #

toList :: ReaderT f m a -> [a] Source #

null :: ReaderT f m a -> Bool Source #

length :: ReaderT f m a -> Int Source #

elem :: Eq a => a -> ReaderT f m a -> Bool Source #

maximum :: Ord a => ReaderT f m a -> a Source #

minimum :: Ord a => ReaderT f m a -> a Source #

sum :: Num a => ReaderT f m a -> a Source #

product :: Num a => ReaderT f m a -> a Source #

(Traversable f, Traversable m) => Traversable (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ReaderT f m a -> f0 (ReaderT f m b) Source #

sequenceA :: Applicative f0 => ReaderT f m (f0 a) -> f0 (ReaderT f m a) Source #

mapM :: Monad m0 => (a -> m0 b) -> ReaderT f m a -> m0 (ReaderT f m b) Source #

sequence :: Monad m0 => ReaderT f m (m0 a) -> m0 (ReaderT f m a) Source #

(Representable f, Applicative m) => Applicative (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

pure :: a -> ReaderT f m a Source #

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

liftA2 :: (a -> b -> c) -> ReaderT f m a -> ReaderT f m b -> ReaderT f m c Source #

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

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

(Functor f, Functor m) => Functor (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

fmap :: (a -> b) -> ReaderT f m a -> ReaderT f m b Source #

(<$) :: a -> ReaderT f m b -> ReaderT f m a Source #

(Representable f, Monad m) => Monad (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

(>>=) :: ReaderT f m a -> (a -> ReaderT f m b) -> ReaderT f m b Source #

(>>) :: ReaderT f m a -> ReaderT f m b -> ReaderT f m b Source #

return :: a -> ReaderT f m a Source #

(Representable f, Representable m, Monoid (Rep f), Monoid (Rep m)) => Comonad (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

extract :: ReaderT f m a -> a Source #

duplicate :: ReaderT f m a -> ReaderT f m (ReaderT f m a) Source #

extend :: (ReaderT f m a -> b) -> ReaderT f m a -> ReaderT f m b Source #

(Representable f, Distributive m) => Distributive (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

distribute :: Functor f0 => f0 (ReaderT f m a) -> ReaderT f m (f0 a) Source #

collect :: Functor f0 => (a -> ReaderT f m b) -> f0 a -> ReaderT f m (f0 b) Source #

distributeM :: Monad m0 => m0 (ReaderT f m a) -> ReaderT f m (m0 a) Source #

collectM :: Monad m0 => (a -> ReaderT f m b) -> m0 a -> ReaderT f m (m0 b) Source #

(Representable f, Apply m) => Apply (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

(<.>) :: ReaderT f m (a -> b) -> ReaderT f m a -> ReaderT f m b Source #

(.>) :: ReaderT f m a -> ReaderT f m b -> ReaderT f m b Source #

(<.) :: ReaderT f m a -> ReaderT f m b -> ReaderT f m a Source #

liftF2 :: (a -> b -> c) -> ReaderT f m a -> ReaderT f m b -> ReaderT f m c Source #

(Representable f, Bind m) => Bind (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

(>>-) :: ReaderT f m a -> (a -> ReaderT f m b) -> ReaderT f m b Source #

join :: ReaderT f m (ReaderT f m a) -> ReaderT f m a Source #

(Representable f, Representable m, Semigroup (Rep f), Semigroup (Rep m)) => Extend (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

duplicated :: ReaderT f m a -> ReaderT f m (ReaderT f m a) Source #

extended :: (ReaderT f m a -> b) -> ReaderT f m a -> ReaderT f m b Source #

(Foldable1 f, Foldable1 m) => Foldable1 (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

fold1 :: Semigroup m0 => ReaderT f m m0 -> m0 Source #

foldMap1 :: Semigroup m0 => (a -> m0) -> ReaderT f m a -> m0 Source #

toNonEmpty :: ReaderT f m a -> NonEmpty a Source #

(Traversable1 f, Traversable1 m) => Traversable1 (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

Methods

traverse1 :: Apply f0 => (a -> f0 b) -> ReaderT f m a -> f0 (ReaderT f m b) Source #

sequence1 :: Apply f0 => ReaderT f m (f0 b) -> f0 (ReaderT f m b) Source #

type Rep (ReaderT f m) Source # 
Instance details

Defined in Control.Monad.Representable.Reader

type Rep (ReaderT f m) = (Rep f, Rep m)

readerT :: Representable f => (Rep f -> m b) -> ReaderT f m b Source #

runReaderT :: Representable f => ReaderT f m b -> Rep f -> m b Source #

class Monad m => MonadReader r (m :: Type -> Type) | m -> r where Source #

See examples in Control.Monad.Reader. Note, the partially applied function type (->) r is a simple reader monad. See the instance declaration below.

Minimal complete definition

(ask | reader), local

Methods

ask :: m r Source #

Retrieves the monad environment.

local Source #

Arguments

:: (r -> r)

The function to modify the environment.

-> m a

Reader to run in the modified environment.

-> m a 

Executes a computation in a modified environment.

reader Source #

Arguments

:: (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

Instances

Instances details
(Representable f, Rep f ~ a) => MonadReader a (Co f) Source # 
Instance details

Defined in Data.Functor.Rep

Methods

ask :: Co f a Source #

local :: (a -> a) -> Co f a0 -> Co f a0 Source #

reader :: (a -> a0) -> Co f a0 Source #

(Functor m, MonadReader e m) => MonadReader e (Free m) 
Instance details

Defined in Control.Monad.Free

Methods

ask :: Free m e Source #

local :: (e -> e) -> Free m a -> Free m a Source #

reader :: (e -> a) -> Free m a Source #

MonadReader r m => MonadReader r (ListT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ListT m r Source #

local :: (r -> r) -> ListT m a -> ListT m a Source #

reader :: (r -> a) -> ListT m a Source #

MonadReader r m => MonadReader r (MaybeT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: MaybeT m r Source #

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

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

(Representable g, MonadReader e m) => MonadReader e (StateT g m) Source # 
Instance details

Defined in Control.Monad.Representable.State

Methods

ask :: StateT g m e Source #

local :: (e -> e) -> StateT g m a -> StateT g m a Source #

reader :: (e -> a) -> StateT g m a Source #

(Functor f, Functor m, MonadReader r m) => MonadReader r (FreeT f m) 
Instance details

Defined in Control.Monad.Trans.Free

Methods

ask :: FreeT f m r Source #

local :: (r -> r) -> FreeT f m a -> FreeT f m a Source #

reader :: (r -> a) -> FreeT f m a Source #

(Error e, MonadReader r m) => MonadReader r (ErrorT e m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ErrorT e m r Source #

local :: (r -> r) -> ErrorT e m a -> ErrorT e m a Source #

reader :: (r -> a) -> ErrorT e m a Source #

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

Since: mtl-2.2

Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ExceptT e m r Source #

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

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

MonadReader r m => MonadReader r (IdentityT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: IdentityT m r Source #

local :: (r -> r) -> IdentityT m a -> IdentityT m a Source #

reader :: (r -> a) -> IdentityT m a Source #

Monad m => MonadReader r (ReaderT r m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ReaderT r m r Source #

local :: (r -> r) -> ReaderT r m a -> ReaderT r m a Source #

reader :: (r -> a) -> ReaderT r m a Source #

MonadReader r m => MonadReader r (StateT s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r Source #

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

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

MonadReader r m => MonadReader r (StateT s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r Source #

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

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

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r Source #

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

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

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r Source #

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

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

MonadReader r ((->) r) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: r -> r Source #

local :: (r -> r) -> (r -> a) -> r -> a Source #

reader :: (r -> a) -> r -> a Source #

MonadReader r' m => MonadReader r' (ContT r m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ContT r m r' Source #

local :: (r' -> r') -> ContT r m a -> ContT r m a Source #

reader :: (r' -> a) -> ContT r m a Source #

(Monad m, Monoid w) => MonadReader r (RWST r w s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: RWST r w s m r Source #

local :: (r -> r) -> RWST r w s m a -> RWST r w s m a Source #

reader :: (r -> a) -> RWST r w s m a Source #

(Monad m, Monoid w) => MonadReader r (RWST r w s m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: RWST r w s m r Source #

local :: (r -> r) -> RWST r w s m a -> RWST r w s m a Source #

reader :: (r -> a) -> RWST r w s m a Source #