Clean up the Cofree implementation and provide a nicer way of working with it.
Implementation details
Cofree is a type to obtain a Comonad from any Functor. It is represented by a pair (A, F<Cofree<F, A>>), which, given the Swift type system, can yield to an eager unfold of the second part of the pair. Therefore, to avoid this, this implementation wraps the tail part on an Eval to make the unfolding lazy.
Related issues
Closes #297
Goal
Clean up the Cofree implementation and provide a nicer way of working with it.
Implementation details
Cofree is a type to obtain a Comonad from any Functor. It is represented by a pair
(A, F<Cofree<F, A>>)
, which, given the Swift type system, can yield to an eager unfold of the second part of the pair. Therefore, to avoid this, this implementation wraps the tail part on anEval
to make the unfolding lazy.