I'm trying to figure out the difference between unfold/coiter from Control.Comonad.Cofree and unfold/ana from Data.Control.Fixedpoint. Hackage libraries are resp. 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 an instance of Foldable for Cofree so I can apply cata to a free monad obtained from unfold/coiter:
type instance Base (Cofree f a) = f
instance Functor f => Foldable (Cofree f a) where
project = unwrap
But I couldn't construct an Unfoldable instance:
instance Functor f => Unfoldable (Cofree f a) where
embed = xembed
xembed :: Functor f => f (Cofree f a) -> Cofree f a
xembed = undefined
Is it possible at all?