I am trying to figure out the difference between unfold/coiter from Control.Comonad.Cofree and unfold/ana from Data.Control.Fixedpoint . Hacker libraries - respectively. free and recursion-schemes .
Cofree and Fix seem to be cousins, and I'm trying to figure out what is possible with both and what is possible with only one of them.
I could write a Foldable instance for Cofree , so I can apply cata to the free monad derived from unfold/coiter :
type instance Base (Cofree fa) = f instance Functor f => Foldable (Cofree fa) where project = unwrap
But I could not build an instance of Unfoldable :
instance Functor f => Unfoldable (Cofree fa) where embed = xembed xembed :: Functor f => f (Cofree fa) -> Cofree fa xembed = undefined
Is it possible at all?
source share