adjunctions-4.4: Adjunctions and representable functors

Copyright(c) Edward Kmett 2011
(c) Conal Elliott 2008
LicenseBSD3
Maintainerekmett@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

Control.Monad.Representable.Reader

Contents

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

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

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 # 

Methods

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

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

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 #

fail :: String -> ReaderT f m a #

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

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 # 

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 # 

Methods

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

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

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 # 

Methods

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

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

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

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

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

Methods

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

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

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 # 

Methods

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

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

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

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

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

Methods

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

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

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

Methods

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

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

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

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

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 # 

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 #

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

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 # 

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 # 
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 :: * -> *) | 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

(Representable f, (~) * (Rep f) a) => MonadReader a (Co f) # 

Methods

ask :: Co f a #

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

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

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

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) 

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) 

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

Methods

ask :: StateT g m e #

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

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

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

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) 

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) 

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) 

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 (IdentityT * m) 

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) 

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) 

Methods

ask :: ErrorT e m r #

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

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

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

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 ((->) LiftedRep LiftedRep r) 

Methods

ask :: (LiftedRep -> LiftedRep) r r #

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

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

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

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) 

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) 

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 #