-
Notifications
You must be signed in to change notification settings - Fork 20
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 unsafe versions of inlining macros #826
Conversation
This reverts commit 1d67849. `#[cfg(hax)]` makes the names crate not exporting the name, for some reason... I spent half an hour debbuging that, I have no clue what is going on. I give up for now.
2e404db
to
88b4821
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.
Very useful, but it croaks when you use hax_lib::fstar
instead of fstar
in the requires/ensures. Would this be easy to fix?
I see that future
cannot be used within F*, which may also be confusing for people. In a future PR, let's figure out the recommended style for this, once we have some experience.
Thanks!
|
Closes #825.
(note: replace BACKEND by
fstar
,coq
, etc. in the text of this PR)This PR:
hax_lib::inline_unsafe
function, hidden in documentation, that allows to inline BACKEND code of any type directly as an expression. This is an internal function, it not supposed to be used directly.It exists only when compiling through hax(see my last reverted commit). The body of this function is anunreachable!
.hax_lib_macro:BACKEND_unsafe_expr
macro (exposed ashax_lib::BACKEND_unsafe_expr
, hidden in doc) which leveragesinline_unsafe
to produce inlined BACKEND code of any type.hax_lib_macro:BACKEND_unsafe_expr
locally asBACKEND
in pre and post conditions. Thus we can use e.g.fstar!("forall x. ...")
in ensures and requires clauses.future(...)
within a quote (e.g.fstar!("... ${future(arg)} ...")
): due to the way macros expand in a fixed sequence (thefstar!("...")
expands afterrequires
expands, so therequires
macro cannot rewrite future nodes in"..."
-- note that will be the same thing, but withold
instead offuture
, when Pre/post&mut
argument: removefuture
in favor ofold
#773 will be fixed)Example of what you can do:
https://hax-playground.cryspen.com/#fstar/88b4821690/gist=49d80be217020e9fd41f9e0a6a23714e