swagger2-2.8.7: Swagger 2.0 data model
MaintainerNickolay Kudasov <nickolay@getshoptv.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Swagger.Declare

Description

Declare monad transformer and associated functions.

Synopsis

Documentation

newtype DeclareT d m a Source #

A declare monad transformer parametrized by:

  • d — the output to accumulate (declarations);
  • m — the inner monad.

This monad transformer is similar to both state and writer monad transformers. Thus it can be seen as

  • a restricted append-only version of a state monad transformer or
  • a writer monad transformer with the extra ability to read all previous output.

Constructors

DeclareT 

Fields

Instances

Instances details
(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> DeclareT d m () Source #

look :: DeclareT d m d Source #

Monoid d => MonadTrans (DeclareT d) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

lift :: Monad m => m a -> DeclareT d m a #

(Applicative m, Monad m, Monoid d) => Monad (DeclareT d m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

(>>=) :: DeclareT d m a -> (a -> DeclareT d m b) -> DeclareT d m b #

(>>) :: DeclareT d m a -> DeclareT d m b -> DeclareT d m b #

return :: a -> DeclareT d m a #

Functor m => Functor (DeclareT d m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

fmap :: (a -> b) -> DeclareT d m a -> DeclareT d m b #

(<$) :: a -> DeclareT d m b -> DeclareT d m a #

(Applicative m, Monad m, Monoid d) => Applicative (DeclareT d m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

pure :: a -> DeclareT d m a #

(<*>) :: DeclareT d m (a -> b) -> DeclareT d m a -> DeclareT d m b #

liftA2 :: (a -> b -> c) -> DeclareT d m a -> DeclareT d m b -> DeclareT d m c #

(*>) :: DeclareT d m a -> DeclareT d m b -> DeclareT d m b #

(<*) :: DeclareT d m a -> DeclareT d m b -> DeclareT d m a #

class (Applicative m, Monad m) => MonadDeclare d m | m -> d where Source #

Definitions of declare and look must satisfy the following laws:

monoid homomorphism (mempty)
declare mempty == return ()
monoid homomorphism (mappend)
declare x >> declare y == declare (x <> y) for every x, y
declare-look
declare x >> look == fmap (<> x) look <* declare x for every x
look as left identity
look >> m == m for every m

Methods

declare :: d -> m () Source #

declare x is an action that produces the output x.

look :: m d Source #

look is an action that returns all the output so far.

Instances

Instances details
MonadDeclare d m => MonadDeclare d (MaybeT m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> MaybeT m () Source #

look :: MaybeT m d Source #

(Monoid w, MonadDeclare d m) => MonadDeclare d (WriterT w m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> WriterT w m () Source #

look :: WriterT w m d Source #

(Monoid w, MonadDeclare d m) => MonadDeclare d (WriterT w m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> WriterT w m () Source #

look :: WriterT w m d Source #

MonadDeclare d m => MonadDeclare d (StateT s m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> StateT s m () Source #

look :: StateT s m d Source #

MonadDeclare d m => MonadDeclare d (StateT s m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> StateT s m () Source #

look :: StateT s m d Source #

MonadDeclare d m => MonadDeclare d (ReaderT r m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> ReaderT r m () Source #

look :: ReaderT r m d Source #

MonadDeclare d m => MonadDeclare d (IdentityT m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> IdentityT m () Source #

look :: IdentityT m d Source #

MonadDeclare d m => MonadDeclare d (ExceptT e m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> ExceptT e m () Source #

look :: ExceptT e m d Source #

(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> DeclareT d m () Source #

look :: DeclareT d m d Source #

MonadDeclare d m => MonadDeclare d (ContT r m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> ContT r m () Source #

look :: ContT r m d Source #

(Monoid w, MonadDeclare d m) => MonadDeclare d (RWST r w s m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> RWST r w s m () Source #

look :: RWST r w s m d Source #

(Monoid w, MonadDeclare d m) => MonadDeclare d (RWST r w s m) Source # 
Instance details

Defined in Data.Swagger.Declare

Methods

declare :: d -> RWST r w s m () Source #

look :: RWST r w s m d Source #

liftDeclare :: MonadDeclare d m => Declare d a -> m a Source #

Lift a computation from the simple Declare monad.

looks :: MonadDeclare d m => (d -> a) -> m a Source #

Retrieve a function of all the output so far.

evalDeclareT :: Monad m => DeclareT d m a -> d -> m a Source #

Evaluate DeclareT d m a computation, ignoring new output d.

execDeclareT :: Monad m => DeclareT d m a -> d -> m d Source #

Execute DeclateT d m a computation, ignoring result and only producing new output d.

undeclareT :: (Monad m, Monoid d) => DeclareT d m a -> m a Source #

Evaluate DeclareT d m a computation, starting with empty output history.

type Declare d = DeclareT d Identity Source #

A declare monad parametrized by d — the output to accumulate (declarations).

This monad is similar to both state and writer monads. Thus it can be seen as

  • a restricted append-only version of a state monad or
  • a writer monad with the extra ability to read all previous output.

runDeclare :: Declare d a -> d -> (d, a) Source #

Run Declare d a computation with output history d, producing result a and new output d.

evalDeclare :: Declare d a -> d -> a Source #

Evaluate Declare d a computation, ignoring output d.

execDeclare :: Declare d a -> d -> d Source #

Execute Declate d a computation, ignoring result and only producing output d.

undeclare :: Monoid d => Declare d a -> a Source #

Evaluate DeclareT d m a computation, starting with empty output history.