-
Notifications
You must be signed in to change notification settings - Fork 238
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
Extraction of user-defined effects (#886) #1011
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modulo some bugs with names generated in DM4F which are not valid in OCaml (#1001)
Not automatically generated, so extracted code using them couldn't be built
So we don't start with an uppercase, which is not good in OCaml ... and don't duplicate implementation secrets too!
`x^w` is not OCaml friendly. Use `x__w` instead
Bind, return and effect actions are no longer qualified with the effect name. Similar to actions, bind and return are extracted as projectors.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code which uses non-primitive effects is extracted using a simple approach, similar to the one used for SMT encoding. Terms which have a reifiable computation type are reified using the normalizer, inlining applications of
return
andbind
.To avoid duplication, I also refactored the relevant bits from
FStar.SMTEncoding.Encode.fs
into separate functions inFStar.TypeChecker.Util.fs
. Other additions include fixes for some issues that only became apparent when attempting to extract code with user-defined effects, including a fix for #1001 due to @mtzguido.Currently, effect actions are extracted as projectors of the effect, belonging to a namespace that is also named after the effect (e.g. action
get
for effectRAND
is extracted asuu___RAND___proj__RAND__item__get
). This works, but is perhaps a bit brittle and convoluted. One potential improvement we discussed was to extract effect definitions as modules (so in the previous example, we would get something likeRAND.get
). Implementing this would require supporting submodules in the extracted ML syntax.4/05/16: For the naming issue, the solution used in the end is to extract both actions and
bind
andreturn
as projectors and to not qualify them with the effect name (e.g.__proj__EFF__item__bind
)