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 #

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

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

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

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

Defined in Control.Monad.Representable.Reader

Methods

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

(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 #

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

return :: a -> ReaderT f m a #

(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 #

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

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

Defined in Control.Monad.Representable.Reader

Methods

pure :: a -> ReaderT f m a #

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

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

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

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

(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 #

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

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

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

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

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

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

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

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

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

null :: ReaderT f m a -> Bool #

length :: ReaderT f m a -> Int #

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

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

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

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

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

(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) #

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

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

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

(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 #

(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 #

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

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

(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) #

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

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

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

(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) #

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

(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 #

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

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

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

(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 #

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

(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 #

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

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

(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) #

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

(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 #

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 #

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 #

Retrieves the monad environment.

local #

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 #

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 #

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

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

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

Defined in Control.Monad.Free

Methods

ask :: Free m e #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: MaybeT m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: ListT m r #

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

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

(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 #

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

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

(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 #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: WriterT w m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: StateT s m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: ReaderT r m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: IdentityT m r #

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

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

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 #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: ErrorT e m r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: r -> r #

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

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

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

Defined in Control.Monad.Reader.Class

Methods

ask :: ContT r m r' #

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

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

(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 #

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

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

(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 #

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

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