adjunctions-4.4.2: Adjunctions and representable functors
Copyright (c) Edward Kmett 2011
(c) Conal Elliott 2008
License BSD3
Maintainer ekmett@gmail.com
Stability experimental
Safe Haskell Safe-Inferred
Language Haskell2010

Control.Monad.Representable.Reader

Description

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

Synopsis

Representable functor monad

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

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, Monad m) => Monad ( ReaderT f m) Source #
Instance details

Defined in Control.Monad.Representable.Reader

( 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, Applicative m) => Applicative ( ReaderT f m) Source #
Instance details

Defined in Control.Monad.Representable.Reader

( 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, MonadIO m) => MonadIO ( ReaderT f m) Source #
Instance details

Defined in Control.Monad.Representable.Reader

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

Defined in Control.Monad.Representable.Reader

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

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

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

Defined in Control.Monad.Representable.Reader

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

Defined in Control.Monad.Representable.Reader

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

Defined in Control.Monad.Representable.Reader

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

Defined in Control.Monad.Representable.Reader

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

type Rep ( ReaderT f m) Source #
Instance details

Defined in Control.Monad.Representable.Reader

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

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

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Representable.State

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

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

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

Since: mtl-2.2

Instance details

Defined in Control.Monad.Reader.Class

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

Defined in Control.Monad.Reader.Class

MonadReader r ((->) r :: Type -> Type )
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 #