FStar icon indicating copy to clipboard operation
FStar copied to clipboard

What's the correct order of including the generated files?

Open WhiteBlackGoose opened this issue 3 years ago • 5 comments

Hello.

fstar --codegen FSharp generates a number of F# files from the standard library of F*. I want to include them in the project. Is there a way to understand the order in which they should go? (aside from building the graph of deps and finding the order like that)

WhiteBlackGoose avatar Feb 15 '22 17:02 WhiteBlackGoose

@mateuszbujalski : Do you have any advice about this?

nikswamy avatar Feb 16 '22 06:02 nikswamy

@WhiteBlackGoose in meantime, maybe this could be used as a workaround: https://github.com/fsprojects/Mechanic#getting-started

smoothdeveloper avatar Feb 16 '22 07:02 smoothdeveloper

Yeah, seen it, thanks. Just thought maybe there's an existing known way that I didn't find

WhiteBlackGoose avatar Feb 16 '22 08:02 WhiteBlackGoose

@nikswamy AFAIR we've discussed in the past reworking the --dep option in fstar to add a mode where it would produce a dependency graph consumable by msbuild (I couldn't find this discussion anymore unfortunately), but eventually I took a simpler route where I just follow F# and put the files in the project in right order. Then, the msbuild targets I've added that manipulate source files take care to keep the order intact. It seemed to be fine, as F# would require you to keep order of your files explicit anyway, and simply replacing *.fs files with *.fst(i) files in fsproj was a quick and easy way forward.

See https://github.com/FStarLang/FStar/blob/master/fsharp.extraction.targets (or newer version that supports sdk projects https://github.com/FStarLang/FStar/pull/2308/files#diff-07d2f3ff15bc554e5da8657aa18e55dd9ded3b8550a057916f4a0ec1054ddd6e).

mateuszbujalski avatar Feb 16 '22 09:02 mateuszbujalski

A good way of doing this is hiding F* standard library in the F# generated code, we could have a nugget called FStar with all the standard library compiled, when generating the F# code, generate it with a .net 6 .fsproj project solution with the Fstar dependency.

For fsi files would be easy to add just a #r nuget: fstar at the top of the file

UPDATE: There is a PR for this https://github.com/FStarLang/FStar/pull/2608

lucasteles avatar Jun 19 '22 21:06 lucasteles