mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Generalize cata
over Cofree
.
This commit is contained in:
parent
82e29e2df7
commit
53de236860
@ -24,7 +24,7 @@ zipTerms (annotation1 :< a) (annotation2 :< b) = annotate $ zipUnwrap a b
|
|||||||
zipUnwrapMaps a' b' key = (,) key <$> zipTerms (a' ! key) (b' ! key)
|
zipUnwrapMaps a' b' key = (,) key <$> zipTerms (a' ! key) (b' ! key)
|
||||||
|
|
||||||
-- | Fold a term into some other value, starting with the leaves.
|
-- | 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
|
cata f (annotation :< syntax) = f annotation $ cata f <$> syntax
|
||||||
|
|
||||||
-- | Unfold a term and its annotation starting from a seed value.
|
-- | Unfold a term and its annotation starting from a seed value.
|
||||||
|
Loading…
Reference in New Issue
Block a user