HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleopenapi3-3.2.4Haskell2010

Data.OpenApi.Declare

Declare monad transformer and associated functions.

  • 2 types
  • 1 class
  • 9 values
  • Packageopenapi3-3.2.4
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceDeclare.hs
newtypenewtype DeclareT d (m :: Type -> Type) 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

Instances5MonadDeclare, MonadTrans, Monad, Functor, Applicative
classclass (Applicative m, Monad m) => MonadDeclare d (m :: Type -> Type) | 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

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.

Instances12MonadDeclare, …
valuelooks :: MonadDeclare d m => (d -> a) -> m a
#

Retrieve a function of all the output so far.

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

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

typetype 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.

valuerunDeclare :: Declare d a -> d -> (d, a)
#

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

valueexecDeclare :: Declare d a -> d -> d
#

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