Module

Control.Comonad.Cofree.Trans

This module defines a lazy implementation of the cofree monad transformer. Given a CofreeT f m a:

  • 'f' is a Functor, generally representing an AST,
  • 'm' is a 'Monad', generally representing an effect,
  • and 'a' is the type of the annotation.

Usually, you would use CofreeT to annotate an existing AST with metadata such as source locations, file names, etc.

#CofreeT

newtype CofreeT f w a

The cofree comonad transformer for the functor 'f'.

Constructors

Instances

#cofreeT

cofreeT :: forall f w a. (Unit -> w (Tuple a (f (CofreeT f w a)))) -> CofreeT f w a

Construct a CofreeT from a lazy computation with an annotation 'a'.

#cofreeT'

cofreeT' :: forall f w a. w (Tuple a (f (CofreeT f w a))) -> CofreeT f w a

Construct a CofreeT from a computation with an annotation 'a'.

#runCofreeT

runCofreeT :: forall f w a. CofreeT f w a -> w (Tuple a (f (CofreeT f w a)))

Unpack CofreeT into the inner computation.

#head

head :: forall f w a. Functor w => CofreeT f w a -> w a

Obtain the annotation stored within a CofreeT.

#tail

tail :: forall f w a. Functor w => CofreeT f w a -> w (f (CofreeT f w a))

Obtain the inner computation stored within a CofreeT.

#hoistCofreeT

hoistCofreeT :: forall f w u a. Functor f => Functor u => (w ~> u) -> CofreeT f w a -> CofreeT f u a

'hoist' the effect type using a natural transform.

#interpretCofreeT

interpretCofreeT :: forall f g w a. Functor g => Functor w => (f ~> g) -> CofreeT f w a -> CofreeT g w a

'interpret' the inner functor using a natural transform.

#bimapCofreeT

bimapCofreeT :: forall f g w u a. Functor u => Functor g => (f ~> g) -> (w ~> u) -> CofreeT f w a -> CofreeT g u a

Both 'interpret' and 'hoist' the inner functor as well as the effect using natural transforms.

Modules