diff --git a/src/Data/Term.hs b/src/Data/Term.hs index 8af569a1a..263fe9e7f 100644 --- a/src/Data/Term.hs +++ b/src/Data/Term.hs @@ -3,6 +3,8 @@ module Data.Term ( Term(..) , termIn , TermF(..) +, termFAnnotation +, termFOut , termSize , extract , unwrap @@ -31,6 +33,13 @@ data TermF syntax ann recur = In { termAnnotation :: ann, termOut :: syntax recu deriving (Eq, Foldable, Functor, Show, Traversable) +termFAnnotation :: TermF syntax ann recur -> ann +termFAnnotation (In ann _) = ann + +termFOut :: TermF syntax ann recur -> syntax recur +termFOut (In _ out) = out + + -- | Return the node count of a term. termSize :: (Foldable f, Functor f) => Term f annotation -> Int termSize = cata size where