Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use one module from another

Tags:

module

f#

I have two F# modules, say a module called A in A.fs and B in B.fs. However, when I use module A from module B, F# does not see it. I've tried all combinations of open directives, i.e., open A, open MyNamespace.A, and so on - nothing helps. What am I doing wrong?

like image 911
Dmitri Nesteruk Avatar asked Nov 24 '10 18:11

Dmitri Nesteruk


2 Answers

I am guessing. The order the files appear in the project explorer is important. When you want to use module A from module B, A.fs has to appear before B.fs.

like image 128
PetPaulsen Avatar answered Nov 08 '22 22:11

PetPaulsen


Since F# doesn't allow recursive modules (IIRC) the only thing you have to care about is that the order of modules is correct (you can't "forward declare" them) so that you build your adding a module that requires just the previous ones step by step.

If you ever find a situation in which you have a cyclic reference between a set of modules, then you will have to factor out the common part and remove the cycle.

This other question can clarify the topic: F# mutual recursion between modules

like image 42
Jack Avatar answered Nov 08 '22 22:11

Jack