HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulefree-5.2Haskell2010

Control.Comonad.Trans.Coiter

The coiterative comonad generated by a comonad

Contents
  1. The coiterative comonad transformer
  2. The coiterative comonad
  3. Generating coiterative comonads
  4. Cofree comonads
  5. Examples
Synopsis
  • 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

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

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

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

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