mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
Define eliminators for TermF.
This commit is contained in:
parent
d17b6399f2
commit
89338a8570
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user