F#'s "Hello, world" with 2 fs files
Sounds like this is an order-of-files-in-the-project issue. The last file is the entry point ("main method"), sounds like you have Alg.fs last, and you need Program.fs last. You can re-order them via the right-click context menu in VS Solution Explorer.
There are at least three separate things that need to be looked at here:
As mentioned by @Brian, the order of source control files is also the compile order. This matters in F# where type inference is heavily used. Make sure
Alg.fs
comes beforeProgram.fs
in your Visual Studio file list (try this: selectProgram.fs
and hitAlt+Down Arrow
until it's at the bottom).Since
Alg.fs
andProgram.fs
are now in modules, you need to actually open theAlg
module inProgram
to get access to its bindings (open Alg
), or add the[<AutoOpen>]
attribute onAlg
.As @Daniel says, the last problem could be the definition of the entry point to the program. You need either an
[<EntryPoint>]
attribute on a top level binding that is also the last function in the last file. Alternatively, this defaults to the last binding in the last file anyway, just make sure it has the right signature (see Daniel's link).