Skip to content

Commit

Permalink
Define subterms paramorphically.
Browse files Browse the repository at this point in the history
  • Loading branch information
robrix committed Mar 19, 2024
1 parent 3861c38 commit 050188f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions semantic-analysis/src/Analysis/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ instance (forall t . Eq t => Eq (sig t), forall t. Ord t => Ord (sig t), Ord v)
compare _ _ = GT


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)
subterms t = case t of
Var _ -> Set.singleton t
Term s -> Set.insert t (foldMap subterms s)
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)
subterms = paraTerm (Set.singleton . Var) (foldMap (uncurry Set.insert))

foldTerm :: Functor sig => (v -> r) -> (sig r -> r) -> (Term sig v -> r)
foldTerm var sig = go
Expand Down

0 comments on commit 050188f

Please sign in to comment.