Any ideas why the following doesn’t compile?
On the last line it tells me that Module1 is not defined. If I remove the “internal” from Module1 it works fine.
I've got two code files and Module1.fs is above Module2.fs in the project.
Module1.fs
module internal Module1
let sample =
5 + 4
Module2.fs
module Module2
let sample2 =
3 + Module1.sample
You'll need to give your modules a namespace so the internal
module is visible to later ones.
let module internal MyNamespace.Module1
let module MyNamespace.Module2
Compiler bug
While the answers here are workarounds, this behavior is still a compiler bug. Reading the docs and Don Syme's Expert F#, there is no point that says that types in internal modules will be accessible only if you also use namespaces.
Considering the code the compiler emits I would not see a difficulty to make types inside internal modules visible inside the assembly.
Edit: Having filed this behavior to @fsbugs, the master himself, Don Syme, soon confirmed this being a bug. I added a workitem for this case:
https://visualfsharp.codeplex.com/workitem/29
this should be a namespace problem. Just add namespace definitions on top of both your files (the same namespace!) like this:
namespace MyNamespace
module internal Module1 =
let sample = 5+4
and
namespace MyNamespace
module Module2 =
let sample2 = 3 + Module1.sample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With