Is there any kind of keyword, like this
, to refere to a current module? For example, what should I put in gap here:
module Test: Test_Type =
struct
module N = Test_Outside(___);;
end;;
Where Test_Outside is another module parameterized by Test_Type.
No, there is not, but it's strange you need to.
You may be able to do weird tricks with recursive modules (an extension to the base language), but most likely the problem is in the way you formulate things, and you actually don't need such self-reference.
See the manual for recursive modules
In my experience, going the recursive route is always gonna be a problem in the end. You should rather take the time to simplify your design and break any dependency cycle by using a more layered approach. For example, here you want N to be defined in Test and at the same time to refer to Test. But does the Test_Outside module need to know about N and other parts of Test using N, or does it rather only use the "base" definitions of Test, that are "before N" ? You may use two separate "Test" modules, with the second extending the first :
module Test_Outside(Test : Small_Test_Type) = struct ... end
module InnerTest : Small_Test_Type = struct ... end
module Test : Test_type = struct
include InnerTest
module N = Test_Outside(InnerTest)
...
end
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