swagger2-2.2: Swagger 2.0 data model

Maintainer Nickolay Kudasov experimental Safe Haskell2010

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 FieldsrunDeclareT :: d -> m (d, a)

Instances

 (Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) Source # Methodsdeclare :: d -> DeclareT d m () Source #look :: DeclareT d m d Source # Monoid d => MonadTrans (DeclareT d) Source # Methodslift :: Monad m => m a -> DeclareT d m a # (Applicative m, Monad m, Monoid d) => Monad (DeclareT d m) Source # 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 #fail :: String -> DeclareT d m a # Functor m => Functor (DeclareT d m) Source # Methodsfmap :: (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 # Methodspure :: 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

Minimal complete definition

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

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.