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

Modulefree-5.2Haskell2010

Control.Comonad.Trans.Coiter

The coiterative comonad generated by a comonad

  • 2 types
  • 1 class
  • 3 values
  • Packagefree-5.2
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceCoiter.hs

Coiterative comonads represent non-terminating, productive computations.

They are the dual notion of iterative monads. While iterative computations produce no values or eventually terminate with one, coiterative computations constantly produce values and they never terminate.

It's simpler form, Coiter, is an infinite stream of data. CoiterT extends this so that each step of the computation can be performed in a comonadic context.

The coiterative comonad transformer

1 declaration
newtypenewtype CoiterT (w :: Type -> Type) a
#

This is the coiterative comonad generated by a comonad

Constructors

Instances19ComonadTrans, ComonadHoist, ComonadEnv, ComonadStore, ComonadTraced, ComonadCofree, …

The coiterative comonad

3 declarations
valuecoiter :: a -> Coiter a -> Coiter a
#

Prepends a result to a coiterative computation.

Property
runCoiter . uncurry coiter == id
valuerunCoiter :: Coiter a -> (a, Coiter a)
#

Extracts the first result from a coiterative computation.

Property
uncurry coiter . runCoiter == id

Generating coiterative comonads

1 declaration
valueunfold :: Comonad w => (w a -> a) -> w a -> CoiterT w a
#

Unfold a CoiterT comonad transformer from a cokleisli arrow and an initial comonadic seed.

Cofree comonads

1 declaration
classclass (Functor f, Comonad w) => ComonadCofree (f :: Type -> Type) (w :: Type -> Type) | w -> f where
#

Allows you to peel a layer off a cofree comonad.

Methods

  • unwrap :: w a -> f (w a)

    Remove a layer.

Instances10ComonadCofree, …

Examples

0 declarations