Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support delayed substitutions #24

Open
fizruk opened this issue Aug 18, 2024 · 0 comments
Open

Support delayed substitutions #24

fizruk opened this issue Aug 18, 2024 · 0 comments

Comments

@fizruk
Copy link
Owner

fizruk commented Aug 18, 2024

When implementing evaluation of terms for $\lambda$-calculus or similar systems, NbE algorithms outperform other implementations by a large margin. It appears that the main ingredient here is the delayed substitutions. As mentioned in the «Free Foil: Generating Efficient and Scope-Safe Abstract Syntax»1, it seems reasonable to generalize terms with delayed substitution with a variation on free foil:

data ScopedClosure sig n where
  ScopedClosure :: Binder n l -> Closure sig l -> ScopedClosure sig n

data Closure sig n where
  VarC
    :: Name n -> Closure sig n
  Closure
    :: Subst (Closure sig) n o   -- Environment (values of captured variables).
    -> sig (ScopedClosure sig n) (Closure sig n)
    -> Closure sig o

It could be useful to add this variation under Control.Monad.Free.Foil.Delayed, possibly with generic conversion to/from regular free foil.

Footnotes

  1. Nikolai Kudasov, Renata Shakirova, Egor Shalagin, Karina Tyulebaeva. 2024. Free Foil: Generating Efficient and Scope-Safe Abstract Syntax. 4th International Conference on Code Quality (ICCQ), Innopolis, Russian Federation, 2024, pp. 1-16 http://doi.org/10.1109/ICCQ60895.2024.10576867 (arXiv version at https://arxiv.org/abs/2405.16384)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant