F# Projects - Order Does Matter
It's common to run into a few simple problems when learning a new programming language. One such problem that I ran into with F# was resolving dependencies within projects.
With the September F# CTP (version 1.9.6.2), it's pretty easy to handle dependencies on external projects since it is done as it is in C# with the "Add Reference..." context menu item. Dependencies between .fs files within a project behave a bit differently, though. As it turns out, the order that the files appear in the project determines the order that they are compiled in.
For example, lets say that I have the following two files:
SomeLibrary.fs
#light
namespace SomeLibrary
type SomeType = { foo : int }
Dependent.fs
#light
open SomeLibrary
let deFoo (x:SomeType) =
x.foo
If I place Dependent.fs above SomeLibrary.fs in the project as shown below, I get a lovely compile error telling me that "The namespace or module 'SomeLibrary' is not defined".
However, once you switch the order using the "Move Up" or "Move Down" context menu actions, everything works as expected.
