Skip to content

Refactor lattice flipping for modes #3949

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 5 commits into from
May 22, 2025
Merged

Refactor lattice flipping for modes #3949

merged 5 commits into from
May 22, 2025

Conversation

riaqn
Copy link
Contributor

@riaqn riaqn commented Apr 30, 2025

Currently in solver.ml there is Solver_mono which can handle monotone morphisms. Based on that, there are two polarized solvers Positive and Negative, used for comonadic and monadic axes respectively. The intention is such that user code (mode.ml) doesn't need to think about the flipping. This has two issues:

  • It turns out that mode.ml still needs to think about the flipping in some definitions but not all of them. This mixture, and the fact that both mode.ml and solver.ml handles flipping, makes the code more confusing.
  • Positive.t and Negative.t are different types and complicates type polymorphism. In particular, Value.Axis.t is a complicated GADT.

So we remove both Positive and Negative, and let mode.ml to be the only file that cares about flipping. We move some code such that the flipping are concentrated to fewer places.

The downside is that code that uses mode might see (Uniqueness.Const.t, allowed * disallowed) mode instead of (disallowed * allowed) Uniqueness.t. The two types are the same, but ideally we want to show the latter.

Review

Please review by commit.

@riaqn riaqn requested a review from goldfirere April 30, 2025 11:04
@dkalinichenko-js dkalinichenko-js force-pushed the clean-up-mode-axis-gadt branch from 9f251f0 to 7260beb Compare May 20, 2025 18:36
@riaqn riaqn merged commit 3a8999d into main May 22, 2025
28 checks passed
@riaqn riaqn deleted the clean-up-mode-axis-gadt branch May 22, 2025 03:01
Gbury pushed a commit to Gbury/flambda-backend that referenced this pull request May 27, 2025
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