Skip to content

spill: change default of bound var visibility for to-prop functions #340

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

Merged
merged 2 commits into from
May 25, 2025

Conversation

gares
Copy link
Contributor

@gares gares commented May 20, 2025

The new algorithm:

  • walks backward until it finds an application of type X1 -> .. XN -> prop
  • eta expand
  • attach the spill (under the lambdas)
  • sigma quantify spilled variables

once finished

  • remove toplevel sigmas

@gares gares force-pushed the spill-map branch 2 times, most recently from d4500a2 to ca516b7 Compare May 20, 2025 19:32
@lweqx
Copy link

lweqx commented May 21, 2025

I'm trying to understand the changes, so first of all sorry if what I'm saying is irrelevant/off the mark.

Wouldn't it be better to systematically transform a spill {f x1 ... xn} occurring inside a (potentially partial) application f y1 ... {f x1 ... xn} ... yn of f: Y1 -> ... -> YN -> Z1 -> ... ZM -> prop into:

% transformation of `f y1 ... {f x1 ... xn} ... yn`
(z1\ ... zm\ sigma Spilled\
  f x1 ... xn Spilled,
  f y1 ... Spilled ... yn z1 ... zm)

(idea stolen from Cyril). Basically, eta-expanding and then "limiting the scope" of the spill unification variable.

This way we would keep spills inside partial applications possible (which is a nice feature in my opinion) and doing things like this would work, as one might intuitively expect:

pred f i:int, o:int.
f X X.

main :-
  std.forall [1, 2] (x\
    x = {f x}
  ).

where prior to this PR crashed with the "Unification problem outside the pattern fragment." error and with this PR unification fails.

@gares gares force-pushed the spill-map branch 2 times, most recently from 8929bea to 052c71d Compare May 22, 2025 12:08
@gares gares marked this pull request as ready for review May 25, 2025 15:09
@gares gares merged commit 8ad8fe7 into master May 25, 2025
9 of 10 checks passed
@gares gares deleted the spill-map branch May 25, 2025 15:09
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 this pull request may close these issues.

2 participants