Module

Control.Comonad.Cofree

Package
purescript-free
Repository
purescript/purescript-free

The cofree comonad for a Functor.

#CofreeSource

data Cofree f a

The Cofree Comonad for a functor.

A value of type Cofree f a consists of an f-branching tree, annotated with labels of type a.

The Comonad instance supports redecoration, recomputing labels from the local context.

Instances

#mkCofreeSource

mkCofree :: forall f a. a -> (f (Cofree f a)) -> Cofree f a

Create a value of type Cofree f a from a label and a functor-full of "subtrees".

#headSource

head :: forall f a. Cofree f a -> a

Returns the label for a tree.

#tailSource

tail :: forall f a. Cofree f a -> f (Cofree f a)

Returns the "subtrees" of a tree.