Greetings,
Second post in here I’ve yet another problem understanding the module system, and how dune make them work.
My program contains simple functor called “Trip”, taking two modules as parametric modules : “Train” & “Road”. The “Trip” code is located in my /lib folder with the following dune file :
(library
(modules trip date)
(name trainmanager))
I’ve been told that it was unecessary to put the “modules” stanza, but still, it might help everyone understand.
So /lib contains date.ml, which contains multiple function regarding date manipulation, annd trip contains, the “Train”, “Road” modules, and the “Journey” functor.
My project works well this way, the library is called “trainmanager”, so in bin/main.ml I access my lib modules this way :
module TrainImpl = Trainmanager.Trip.Train
module Roadmpl = Trainmanager.Trip.Road
module Journey = Trainmanager.Trip.MakeJourney(TrainImpl)(RoaImpl)
And I can use them, it has helped me understand the functors principle, but, now I’d like to split all the trip.ml’s submodules into different files and have the following structure:
lib/ :
dune
date.ml
trip.ml
trip.mli
train.ml
train.mli
road.ml
road.mli
But I haven’t been able to make it work. I stumble upon this problem:
174 | module Journey = Trainmanager.Trip.MakeJourney(TrainImpl)(RoadImpl)
^^^^^^^^^
Error: Signature mismatch:
...
The value `get_associated_network' is required but not provided
File "trainmanager/lib/train.mli", line 10, characters 2-52:
Expected declaration
The value `check_station_network' is required but not provided
File "trainmanager/lib/train.mli", line 9, characters 2-59:
Expected declaration
The value `getTrainSpeed' is required but not provided
File "trainmanager/lib/train.mli", line 8, characters 2-37:
Expected declaration
The value `get_speed' is required but not provided
File "trainmanager/lib/train.mli", line 7, characters 2-28:
Expected declaration
The value `get_model' is required but not provided
File "trainmanager/lib/train.mli", line 6, characters 2-29:
Expected declaration
The value `create' is required but not provided
File "trainmanager/lib/train.mli", line 5, characters 2-35:
Expected declaration
The exception `Station_not_in_network' is required but not provided
The exception `Unknow_train_type' is required but not provided
The type `t' is required but not provided
File "trainmanager/lib/train.mli", line 2, characters 2-8:
Expected declaration
I changed the way TrainImpl and RoadImpl are assigned :
module TrainImpl = Trainmanager.Train
module RoadImpl = Trainmanager.Road
And the source files are organized the way I described above.
I’ve basically moved all the signature part of both Road & Train in their .mli files and the struct part in their .ml files but that just won’t work, what am I missing could anyone help ? I can always provides more details, code and please, tell me if the design is just wrong etc, thanks.