openapi3-3.2.3: OpenAPI 3.0 data model
Maintainer Nickolay Kudasov <nickolay@getshoptv.com>
Stability experimental
Safe Haskell Safe-Inferred
Language Haskell2010

Data.OpenApi.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

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.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.Declare

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

Defined in Data.OpenApi.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.OpenApi.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.