ekmett / free

free monads
http://hackage.haskell.org/package/free
Other
161 stars 65 forks source link

Missing fold for Cofree #136

Open ekmett opened 8 years ago

ekmett commented 8 years ago

E.g.

foldCofree :: Functor f => (a -> f b -> b) -> Cofree f a -> b
foldCofree f = go where
    go (x :< ts) = f x (fmap go ts)
andrewthad commented 8 years ago

And its monadic variant too.

stephen-smith commented 8 years ago

How about Functor f => (CofreeF f a b -> b) -> Cofree f a -> b instead? https://github.com/ekmett/recursion-schemes/pull/26 adds that to recursion-schemes as cata in a new instance for Recursive.