Skip to content
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

noextract only impacts KreMLin function bodies #1221

Closed
tchajed opened this issue Aug 25, 2017 · 6 comments
Closed

noextract only impacts KreMLin function bodies #1221

tchajed opened this issue Aug 25, 2017 · 6 comments

Comments

@tchajed
Copy link
Contributor

tchajed commented Aug 25, 2017

I wanted to create an issue to track discussion on the behavior of noextract. Currently this qualifier only impacts KreMLin, and even there a signature is still generated with a body that throws an error.

Would it make sense to instead skip the entire extraction pipeline for this attribute, including F# and OCaml extraction? I ran into this in FStarLang/karamel#54 and as mentioned there Guido was able to change the behavior of extraction to bail out on noextract much earlier with a simple change.

At this point changing the behavior is not too costly since this qualifier has very little usage so far.

@ad-l
Copy link
Contributor

ad-l commented Aug 25, 2017

noextract is used in 54 places in Hacl*.

@tchajed
Copy link
Contributor Author

tchajed commented Aug 25, 2017

Do you expect that it would break Hacl* if those uses were not extracted to OCaml?

@ad-l
Copy link
Contributor

ad-l commented Aug 25, 2017

I would expect so, considering the fact that the ML backend erases very little. This is easy enough to try - I think the change to noextract you propose is easy to implement.

@A-Manning
Copy link
Contributor

noextract would be very helpful as a module qualifier, since it's burdensome to remember which files in a project should be realised and which should be extracted when passing them on a command line.

@msprotz
Copy link
Collaborator

msprotz commented Sep 8, 2017

Beware: if you drop the declaration without even passing it to kremlin, then kremlin's internal checker will be confused and may have less type information at call-site, which may be break some invariants later on.

This is why the declaration is kept. Example:

noextract
let f x: option int = None

if you don't pass the type signature to kremlin, then kremlin's checker won't have enough information for:

match f x with
| None -> ...

and won't generate the proper monomorphization of option int.

Perhaps noextract should only be used for pure functions in conjunction with inline_for_extraction

@msprotz
Copy link
Collaborator

msprotz commented Sep 12, 2017

Closing after I reverted @mtzguido 's change... noextract may be poorly named but we still need the stubs to type-check the code at the kremlin level in Low*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants