-
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
Extraction examples eg. examples/hello failing with F# #1087
Comments
I tracked down the issue with FSharp.Powerpack.dll dependency to prims.fs defining a type I've provided a realized FStar.Pervasives.Native.fst in a PR #1092, The issue in FStar.Pervasives.fs is that F# won't accept type abbreviations that don't use all of the declared type parameters in the type being abbreviated, whereas OCaml will, which gives several FS0035 errors when trying to compile FStar.Pervasives.fs. See https://stackoverflow.com/questions/9838098/getting-fs0035-construct-is-deprecated.
Which gets extracted to the following, in FStar.Pervasives.fs:
Since This error is not restricted to instances where F* extracts
Which extracts to
Which is not valid, since |
Another issue with F# extraction is that only implicit arguments at the start of a function are erased, whereas the others are extracted to
Extracts to
These both compile just fine, but if one tries to actually use them :
fails to compile with error
whereas |
@A-Manning Thanks a lot for looking into these problems. This is starting to look like an F# extraction pinhada than a bug report though. How about keeping this report for issues related to extracting the hello world example, and filing more issues for the other problems? |
Ok, should I make seperate issues for each problem, or one issue for F# extraction issues? |
Your call. We do allow for "meta issues", just that they tend to stick around forever. |
Besides the issue raised in fsharp/fslang-suggestions#597 (F# requiring the use of all declared type parameters in type abbreviations), parts of
|
@drvink Which version of F* are you using? I can't reproduce this error. |
I was trying to compile the extracted source by hand, since the
...and then I built the stuff in
...then you should be able to see these errors if you try running something like:
|
This is probably due to the makefile for |
Especially given #1096 ... it seems that extraction to F# is far from complete. So, fixing hello.exe on its own is really just a small first step. |
Was there any progress on this since Sept 2017? I run over it again recently: https://fstar.zulipchat.com/#narrow/stream/184683-questions-and.20help/topic/Compiling.20to.20F.23 |
It seems that F# extraction regressed further at least on this Hello example. Now we're getting an empty |
F# extraction works again in the version 0.9.6.001 |
version 0.9.6 is very old, so no |
Hi, @Nik Swamy, I was playing a little bit with your branch (nik_fsharp_extraction). I can say that the most basic hello example works fine now :). I have a few questions/concerns before moving forward.
|
Hi Mateusz, Thanks for digging into this!
2 & 3. As we try more examples, we will certainly have code that depends on FStar.Pervasives. On the OCaml side, this module appears as ulib/ml/extracted/FStar_Pervasives.ml. I agree that we should probably not have an
Thanks again! |
Thanks! Re 4. Would changing the directory structure in examples like below be ok?
One thing I'm not sure about yet is how to deal with examples that consist of multiple fst files. In particular how to make the fsproj include the generated files in the right order for F# compilation to work. |
Hi Mateusz, Sorry for the slow reply! That directory structure sounds fine to me. Regarding the order of dependences: F* has a dependence analysis which currently emits dependences in makefile format for F*, OCaml and Kremlin. See the output of |
I have few more questions about ulib extraction :)
|
…d fixing hello example for f# extraction
…st of hello examples
Hi Mateusz, All three of your questions are intertwined in some way. The short answer is that F* is heavily biased towards verifying and extracting one module at a time. In some cases, it is possible to verify and extract multiple modules in a single invocation. However, this is not a common usage in all but the simplest projects. Now, a more elaborate response. .fsti files: Interface files are an essential mechanism in F* for enforcing abstraction. Consider the following example: A.fsti: An interface for module
A.fst: An implementation of the interface providing concretely the value
B.fst: A client module of
Now, if you try to invoke F* on all these files together
That's because in this single invocation, F* cannot guarantee to hide the implementation details of So, coming to your questions
We at least have to verify modules one at a time with separate invocations of F*. We could, conceivably, after verifying all modules and producing .checked files, extract them all to .fs or .ml in a single additional invocation. But, I'm not sure if that adds much value.
Not really applicable, since single invocation for all modules doesn't fly.
First, about lax: Lax checking and lax.cache are a bit peculiar. Basically, running F* with --lax disables the verifier. One shouldn't really be using --lax in a project where verification is intended. We currenly use --lax primarily for bootstrapping the compiler sources (which are not verified). There is also a remnant use of lax for the extraction of fstarlib ... but this should probably be removed, since those files are also verified properly (without --lax) as part of Then interfaces: These are definitely typechecked and extracted. An interface in F* can include both type signatures, definitions of inductive types, as well as let bindings. All of this is verified and extracted along with the implementation files. See https://github.com/FStarLang/FStar/wiki/F%E2%98%85-Interfaces-(simple-version) I shouldn't be too hard to get |
Thanks, that's really helpful! It looks like I've misunderstood how some things work :)
I might be able to use it now, but I most likely won't be able to do that in my work environment, so I would prefer to avoid adding a dependency on make for windows build. I was planning to look into generating the right order with fstar later, once I make sure that the extraction works for ulib and examples (at least some non-trivial examples). For now, I'm ordering the extraction manually with fsproj - the current code invokes fstar per FStarSourceFile item in the order those items are defined in the project file. My idea was that I could add "--dep msbuild" option that would simply generate an ordered list of modules to extract, plus perhaps a separate list of fs files to compile if we can't assume those are the same (up to a small name transformation like FStar.Module.fst -> FStar_Module.fs).
I didn't see any codegen commands that would be running on an fsti file when building ocaml version of ulib, so can I assume that ulib always uses 'realised modules' for interfaces? Or should we also allow https://github.com/FStarLang/FStar/wiki/F★-interfaces-%28split-file%2C-more-complicated-version%29? |
No, it actually uses the complicated version quite extensively. For example, take FStar.BigOps.fsti and FStar.BigOps.fst. The extracted code FStar_BigOps.ml contains elements of both the .fst and the .fsti files. |
…ing an example with minimal repro of an issue
Preserve the order of files for extraction and F# compilation
…tar.exe are passed to msbuild
#1087 Allow interleaving of F# and F* sources in a project
…ation of FStar.HyperStack.ST which seems to be out of sync
building examples/hello with
make -C examples/hello fs
is failing to build with F#, with the errorThis is due to compilation being commented out in the makefile:
uncommenting gives another error - seemingly related to the removal of Powerpack
Placing FSharp.PowerPack.dll in /bin/ then gives a different error:
The text was updated successfully, but these errors were encountered: