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

Lambda-lifting #32

Closed
j-hui opened this issue Oct 22, 2021 · 0 comments · Fixed by #44
Closed

Lambda-lifting #32

j-hui opened this issue Oct 22, 2021 · 0 comments · Fixed by #44
Assignees

Comments

@j-hui
Copy link
Contributor

j-hui commented Oct 22, 2021

We need to convert lambdas (aka closures) into top-level function definitions. So this:

f = \x -> (\() -> x) ()

should be converted to

type Fenv a = Fenv { x : a }

f__anon1 = \fenv -> \() -> fenv.x

f = \x -> f__anon (Fenv a) ()

That is, any lambdas that don't appear at the top-level of a top-level function definition should be hoisted into a name-mangled top-level definition and given an extra "environment" parameter that includes all variables captured by closure.

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

Successfully merging a pull request may close this issue.

2 participants