1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Define eliminators for TermF.

This commit is contained in:
Rob Rix 2017-11-23 13:14:46 -05:00
parent d17b6399f2
commit 89338a8570

View File

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