-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Purity inference #7170
Purity inference #7170
Conversation
9039954
to
c063025
Compare
c063025
to
ee94d81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial review, only partway through. More comments tomorrow!
crates/compiler/can/tests/snapshots/test_suffixed__suffixed_tests__apply_argument_multiple.snap
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've finished reading the whole thing (more or less). It looks good to me! A couple of minor things, and then I think we're good to go. You supporting both Tasks and effectful functions makes this need much less coordination to get right than the built-in Task effort.
@agu-z can you ping me for review after rebase? |
dcbff1f
to
2b8d9aa
Compare
/// Require idents to be accurately suffixed | ||
FxSuffix(Index<FxSuffixConstraint>), | ||
/// Set an fx var as pure if flex (no effectful functions were called) | ||
FlexToPure(Variable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Would it be sufficient to add an Eq constraint that the fx var on a function is Pure or Impure depending on the suffix? With an appropriate context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean FlexToPure
or FxSuffix
should use Eq
?
The former I think wouldn't work because the logic is different than the normal unification of fx vars. However, FxSuffix
might work as Eq
with a custom Reason
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ayazhafiz let me know which one you mean when you have a chance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to merge this, but I'm happy to clean this up in a follow up PR!
a5aeb82
to
d3abe4a
Compare
This is because the NoIdentifiersIntroduced error was moved to the type checker.
Non-top-level defs are already covered
5c2edf6
to
a4ccef9
Compare
Things go wrong when multiple tests depend on the same platform on Linux. Tried a few workarounds but the problem persisted. We decided to keep only one test for now.
a4ccef9
to
7f8149d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Massive upgrade, thank you for all the hard work Agus 🎉 😍
Introduces the "Purity Inference" model of effects as described in Richard's talk:
!
and viceversa!
suffix is not only required on defs, but also on record fields, and all pattern matched identifiers (tuple, tags, opaques, etc).IGNORED RESULT
warning is produced if they return anything other than{}
_
:roc run
a program with a pure/effectful mismatch, which can be useful while you're debuggingTask
still works if that's what the platform exposes in itshosted
module. This will allow us to migrate platforms incrementally.Type checking and errors preview:
https://www.youtube.com/watch?v=5a3r88-oEQQ