HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulekan-extensions-5.2.7Haskell2010

Control.Monad.Codensity

  • 1 type
  • 11 values
newtypenewtype Codensity (m :: k -> TYPE rep) a
#

Codensity f is the Monad generated by taking the right Kan extension of any Functor f along itself (Ran f f).

This can often be more "efficient" to construct than f itself using repeated applications of (>>=).

See "Asymptotic Improvement of Computations over Free Monads" by Janis Voigtländer for more information about this type.

https://www.janis-voigtlaender.eu/papers/AsymptoticImprovementOfComputationsOverFreeMonads.pdf

Constructors

Instances14MonadReader, MonadState, MonadFree, MonadTrans, Monad, Functor, …
valuewrapCodensity :: (forall (a :: k). m a -> m a) -> Codensity m ()
#

Wrap the remainder of the Codensity action using the given function.

This function can be used to register cleanup actions that will be executed at the end. Example:

wrapCodensity (`finally` putStrLn "Done.")
valueimprove
  1. :: Functor f
  2. => forall (m :: Type -> Type). MonadFree f m => m a
  3. -> Free f a
#

Right associate all binds in a computation that generates a free monad

This can improve the asymptotic efficiency of the result, while preserving semantics.

See "Asymptotic Improvement of Computations over Free Monads" by Janis Voightländer for more information about this combinator.

http://www.iai.uni-bonn.de/~jv/mpc08.pdf

Delimited continuations

2 declarations