-
Notifications
You must be signed in to change notification settings - Fork 236
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
Add a new syntax to support partial open
s and include
s
#3369
Conversation
25ff94b
to
dcb2b47
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.
Hi Lucas, this looks great and it's very useful! Thank you!
I left some tiny comments, but other than that I'd be really happy merging this.
This commit introduces the following syntaxes: ```fstar // brings `MyModule.some_function`, `MyModule.some_type` and `MyModule.SomeConstructor` only, nothing else is visible open MyModule { some_function, some_type, SomeConstructor } // `include` works the same include MyModule { some_function, some_type, SomeConstructor } // renaming is possible include MyModule { some_function as f, SomeConstructor as X } ``` I call `{ ... }` a restriction that we impose on the open or include, maybe there's a better naming there. This PR: - tags auto generated records (when `type foo = | Foo {...}`) with a new attribute `desugar_of_variant_record` (this is important, so that `open Module {foo}` is able to look for that attribute and bring `foo__Foo__payload` in scope too); - add a type `restriction`; - change the parser to allow the new restriction syntax; - tweaks `DsEnv` accordingly.
7717f9f
to
07da2dd
Compare
Thanks for the fast review Guido! I addressed your comments, tell me if there's anything else I can do :) |
Thanks Lucas! This is great. |
Hi!
This PR introduces the following syntaxes:
I call
{ ... }
a restriction that we impose on the open or include, maybe there's a better naming there.This PR:
type foo = | Foo {...}
) with a new attributedesugar_of_variant_record
(this is important, so thatopen Module {foo}
is able to look for that attribute and bringfoo__Foo__payload
in scope too);restriction
;DsEnv
accordingly;module _ = Foo
syntax (that desugars toopen Foo {}
)What do you think about this new feature?
@mtzguido, I haven't hacked on F* for a while, and I have to say having typeclasses (and tactics, seems like! 👀) within the compiler sources is fantastic! Especially something as "stupid" as
showable
simplifies makes debugging much much nicer!More example in
tests/restricted_includes
, but here is a preview:Given the following module:
You can: