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

Compute term sizes as node counts.

This commit is contained in:
Rob Rix 2016-04-11 13:54:46 -04:00
parent 4cce0deb34
commit 0b4696062d

View File

@ -29,7 +29,4 @@ cata f (annotation :< syntax) = f annotation $ cata f <$> syntax
-- | Return the number of leaves in the node.
termSize :: Term a annotation -> Integer
termSize = cata size where
size _ (Leaf _) = 1
size _ (Indexed i) = sum i
size _ (Fixed f) = sum f
size _ (Keyed k) = sum k
size _ syntax = 1 + sum syntax