5
votes

I have two classes, Foo and Bar, two distinct files, foo.fs and bar.fs

namespace Ganymede.Versioning

type foo = class 
    val Bar : bar
    new(input) = { Bar = input }    
    end


namespace Ganymede.Versioning

type bar = class
    val Test : string
    new (input) = { Test = input; }
    end

I get a "The type 'bar' is not defined." error inside class foo, for val Bar : bar

Why is that?

2

2 Answers

11
votes

Files in a project must be ordered by dependency, so you need to put bar.fs above foo.fs in the project so that foo can see bar.

2
votes

See this blog entry, but briefly, if you don't specify a namespace or module at the top of a file, the code implicitly goes in a module named by the filename. So if your project contains bar.fs and foo.fs (in that order, order matters) then to reference the type named 'bar' from file 'foo.fs' you must use 'bar.bar' (where the first is the module name, and the second is the type name).