Skip to content

Commit

Permalink
Mendler-style recursion.
Browse files Browse the repository at this point in the history
  • Loading branch information
robrix committed Mar 19, 2024
1 parent 050188f commit c746f93
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions semantic-analysis/src/Analysis/Syntax.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
module Analysis.Syntax
( -- * Syntax
Term(..)
, subterms
, foldTerm
, paraTerm
, mendlerTerm
) where

import qualified Data.Set as Set
Expand Down Expand Up @@ -42,3 +44,9 @@ paraTerm var sig = go
where
go (Var v) = var v
go (Term s) = sig ((,) <*> go <$> s)

mendlerTerm :: (v -> r) -> (forall r' . (r' -> r) -> sig r'-> r) -> (Term sig v -> r)
mendlerTerm var sig = go
where
go (Var v) = var v
go (Term s) = sig go s

0 comments on commit c746f93

Please sign in to comment.