3
votes

I'm using F# power tools which gives me a handy way to create folders in F# solution.

Now, I have 2 similar console app projects in the solution. Both projects contain a util folder. In one project util folder contains namespaced module with functions. In other project util folder contains namespaced enum and class definition.

Namespacing is done in the following way: ProjectName.Folder

Both projects have Program.fs file with "EntryPoint" main function. Program.fs is the last file in the solution. Main function is inside "ProjectName" namespace.

Because both files have the same root namespace, I expect to see sub-namespace from the Program.fs file when I try to "open" the sub-namespace and use the code from the other file.

Well that works in the first project with module but not in the other one which contains class definitions in a sub-namespace... when I try to open a sub-namespace in the second project, I need to provide fully qualified namespace even though both files share the same namespace root.

In the first project I can reference sub-namespace directly without specifying root namespace - it is simply visible.

This confuses me a lot, especially that sometimes I have compilation issues which I resolve by moving Program.fs file with main() up and down in the project, and suddenly I can compile.

Do you have any ideas if described issues are related to problems in the project structure (file) which are not visible from solution explorer or am I missing something related to F# syntax and how using (open) namespaced modules with functions work compared to namespaced classes (types) ? Could it be that F# powertools are somehow causing problems when creating folders and files inside of those folders ?

I can provide code samples. They are mostly taken from the tutorial, but I wanted to make question as short as possible.

Edit 1

I've just merged the code in a new project to test things out and as it turns out, when I'm opening a namespaced module, a can provide only a relative namespaced path to that module, but when I'm opening a name space in order to use classes defined there, I need to provide a fully qualified path of that namespace, even though I'm opening that namespace from the same root namespace. Can someone confirm this behaviour ? Meanwhile, I'm going to dig through http://en.wikibooks.org/wiki/F_Sharp_Programming/Modules_and_Namespaces

1

1 Answers

4
votes

As for the file order with folders, check your actual fsproj with the xml editor. I have had PowerTools create the correct file path, i.e. Folder\MyFile.fs, but put it in the wrong place. All files within a folder have to appear straight after each other. For instance, you cannot make an order like this:

FolderA\File1.fs, File2.fs, FolderA\File3.fs