Module

Control.Comonad.Cofree.Trans

Package
purescript-freet
Repository
purescript-contrib/purescript-freet

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

  • 'f' is a Functor, generally representing an AST,
  • 'w' is a 'Comonad',
  • 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 Source

newtype CofreeT :: (Type -> Type) -> (Type -> Type) -> Type -> Typenewtype CofreeT f w a

The cofree comonad transformer for the functor 'f'.

Constructors

Instances

#cofreeT Source

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' Source

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 Source

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

Unpack CofreeT into the inner computation.

#head Source

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

Obtain the annotation stored within a CofreeT.

#tail Source

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 Source

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 Source

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 Source

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.