Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 050188f

Browse files
committed
Define subterms paramorphically.
1 parent 3861c38 commit 050188f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

semantic-analysis/src/Analysis/Syntax.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ instance (forall t . Eq t => Eq (sig t), forall t. Ord t => Ord (sig t), Ord v)
2828
compare _ _ = GT
2929

3030

31-
subterms :: (forall t . Eq t => Eq (sig t), forall t . Ord t => Ord (sig t), Ord v, Foldable sig) => Term sig v -> Set.Set (Term sig v)
32-
subterms t = case t of
33-
Var _ -> Set.singleton t
34-
Term s -> Set.insert t (foldMap subterms s)
31+
subterms :: (forall t . Eq t => Eq (sig t), forall t . Ord t => Ord (sig t), Ord v, Foldable sig, Functor sig) => Term sig v -> Set.Set (Term sig v)
32+
subterms = paraTerm (Set.singleton . Var) (foldMap (uncurry Set.insert))
3533

3634
foldTerm :: Functor sig => (v -> r) -> (sig r -> r) -> (Term sig v -> r)
3735
foldTerm var sig = go

0 commit comments

Comments
 (0)