1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Generalize cata over Cofree.

This commit is contained in:
Rob Rix 2016-03-18 12:51:32 -04:00
parent 82e29e2df7
commit 53de236860

View File

@ -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.