From 53de236860eb87786d8a17f8524b0323c8488151 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 18 Mar 2016 12:51:32 -0400 Subject: [PATCH] Generalize `cata` over `Cofree`. --- src/Term.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Term.hs b/src/Term.hs index d6e11d94e..d886ddbed 100644 --- a/src/Term.hs +++ b/src/Term.hs @@ -24,7 +24,7 @@ zipTerms (annotation1 :< a) (annotation2 :< b) = annotate $ zipUnwrap a b zipUnwrapMaps a' b' key = (,) key <$> zipTerms (a' ! key) (b' ! key) -- | Fold a term into some other value, starting with the leaves. -cata :: (annotation -> Syntax a b -> b) -> Term a annotation -> b +cata :: Functor f => (annotation -> f b -> b) -> Cofree f annotation -> b cata f (annotation :< syntax) = f annotation $ cata f <$> syntax -- | Unfold a term and its annotation starting from a seed value.