swagger2-2.1.4.1: Swagger 2.0 data model

Maintainer | Nickolay Kudasov <nickolay@getshoptv.com>
Stability | experimental
Safe Haskell | Safe
Language | Haskell2010

Data.Swagger.Declare

Description

Declare monad transformer and associated functions.

Synopsis

- newtype DeclareT d m a = DeclareT {
  - runDeclareT :: d -> m (d, a)
  }
- class (Applicative m, Monad m) => MonadDeclare d m | m -> d where
- liftDeclare :: MonadDeclare d m => Declare d a -> m a
- looks :: MonadDeclare d m => (d -> a) -> m a
- evalDeclareT :: Monad m => DeclareT d m a -> d -> m a
- execDeclareT :: Monad m => DeclareT d m a -> d -> m d
- undeclareT :: (Monad m, Monoid d) => DeclareT d m a -> m a
- type Declare d = DeclareT d Identity
- runDeclare :: Declare d a -> d -> (d, a)
- evalDeclare :: Declare d a -> d -> a
- execDeclare :: Declare d a -> d -> d
- undeclare :: Monoid d => Declare d a -> a

# Documentation

newtype DeclareT d m a #

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)

Instances

(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) # |
Methods declare :: d -> DeclareT d m () # look :: DeclareT d m d #
Monoid d => MonadTrans (DeclareT d) # |
Methods lift :: Monad m => m a -> DeclareT d m a #
(Applicative m, Monad m, Monoid d) => Monad (DeclareT d m) # |
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) # |
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) # |
Methods pure :: a -> DeclareT d m a # (<*>) :: DeclareT d m (a -> b) -> DeclareT d m a -> DeclareT d m b # (*>) :: 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 #

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

declare, look

Methods

declare :: d -> m () #

``declare` x` is an action that produces the output `x`.

look :: m d #

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

Instances

MonadDeclare d m => MonadDeclare d (MaybeT m) # |
Methods declare :: d -> MaybeT m () # look :: MaybeT m d #
MonadDeclare d m => MonadDeclare d (ListT m) # |
Methods declare :: d -> ListT m () # look :: ListT m d #
(Monoid w, MonadDeclare d m) => MonadDeclare d (WriterT w m) # |
Methods declare :: d -> WriterT w m () # look :: WriterT w m d #
(Monoid w, MonadDeclare d m) => MonadDeclare d (WriterT w m) # |
Methods declare :: d -> WriterT w m () # look :: WriterT w m d #
MonadDeclare d m => MonadDeclare d (StateT s m) # |
Methods declare :: d -> StateT s m () # look :: StateT s m d #
MonadDeclare d m => MonadDeclare d (StateT s m) # |
Methods declare :: d -> StateT s m () # look :: StateT s m d #
MonadDeclare d m => MonadDeclare d (IdentityT * m) # |
Methods declare :: d -> IdentityT * m () # look :: IdentityT * m d #
MonadDeclare d m => MonadDeclare d (ExceptT e m) # |
Methods declare :: d -> ExceptT e m () # look :: ExceptT e m d #
(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) # |
Methods declare :: d -> DeclareT d m () # look :: DeclareT d m d #
MonadDeclare d m => MonadDeclare d (ReaderT * r m) # |
Methods declare :: d -> ReaderT * r m () # look :: ReaderT * r m d #
MonadDeclare d m => MonadDeclare d (ContT * r m) # |
Methods declare :: d -> ContT * r m () # look :: ContT * r m d #
(Monoid w, MonadDeclare d m) => MonadDeclare d (RWST r w s m) # |
Methods declare :: d -> RWST r w s m () # look :: RWST r w s m d #
(Monoid w, MonadDeclare d m) => MonadDeclare d (RWST r w s m) # |
Methods declare :: d -> RWST r w s m () # look :: RWST r w s m d #

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

Lift a computation from the simple Declare monad.

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

Retrieve a function of all the output so far.

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

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

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

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 #

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

type Declare d = DeclareT d Identity #

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

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

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

Evaluate ``Declare` d a` computation, ignoring output `d`.

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

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

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

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