swagger2-2.0.2: Swagger 2.0 data model

MaintainerNickolay Kudasov <nickolay@getshoptv.com>
Stabilityexperimental
Safe HaskellSafe
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

runDeclareT :: d -> m (d, 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

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.