Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reference types or modules defined in other F# files? [duplicate]

Tags:

f#

This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition

Stack.fs

namespace Col

type Stack= 
 ...

Now I try to include the namespace in Program.fs by declaring

open Col

This doesn't work and gives me the error "The namespace or module Col is not defined." Yet it's defined within the same project. I've got to be missing something obvious

like image 341
JaredPar Avatar asked Oct 06 '08 00:10

JaredPar


2 Answers

What order are the files in the .fsproj file? Stack.fs needs to come before Program.fs for Program.fs to be able to 'see' it.

See also the start of

http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry

and the end of

http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!347.entry

like image 159
Brian Avatar answered Oct 15 '22 13:10

Brian


I had the same problems, and you are right, the order of the files is taken in account by the compiler. Instead of the Remove and Add pattern, you can use the Move Up / Move Down items in the context menu associated to the .fs files. (Alt-Up and Alt-Down are the shortcut keys in most of the standard key-bindings)

like image 46
Horacio N. Hdez. Avatar answered Oct 15 '22 15:10

Horacio N. Hdez.