Is there a way to force a module to load when it opens through FSI?

If I compile the following module in dll

namespace MyNs
module SomeModule =
    do printfn "module loading"
    let x = 23

then refer to the dll in FSI and run the command open MyNs.SomeModule"Download module" does not print immediately. It prints only on access to x, which causes the execution of all the upper levels of let and do bindings (normal behavior that I know in the .NET world). Is there a way, perhaps through the module attribute, I can indicate that the module should load immediately after opening in FSI?

+3
source share
3 answers

. .

12.5 - , - , .

, , , , exe.

.. , , .

:

ModuleType.TypeInitializer.Invoke(null, null)

.

+2

AutoOpen

[<AutoOpen>]
module SomeModule =
  do printfn "module loading"
  let x = 23

x .

0

, , , - , , .

What I did was installed in the module let start() =inside the module and call the method using static do xxx.start()from my main type Site.

Found that by reading the language specification related to Koot.

0
source

All Articles