I know this question is quite general and I even don't know how to better ask.
I don't have much experiences in C
and I just wish I can do similar thing in OCaml as in Java.
For example, in Java
, I normally create a project (using Eclipse
or other IDE), then I have a src
folder and a bin
folder. All compiled
stuff go to bin
.
So for the starter, how could I do something as simple as above? just split the source files and compile files easily?
Normally, how do you guys organise OCaml project files?
The final question is that should I use mli
or module
? I noticed that ocaml-batteries-included
is using mli
a lot.
There's plenty of differing opinion about this subject in the OCaml community and it really depends on how structure or flexibility do you want. Myself I use a makefile and ocamlbuild if I'm being lazy and oasis for everything else. You should check out a few random OCaml projects to see how it works and what you would like. For example an oasis project might look like so: https://github.com/avsm/ocaml-github. You only need to look at the _oasis file (think of it like pom.xml if you ever used maven). Running oasis setup
should generate all of the build files for you. ocaml setup.ml -all
followed by ocaml setup.ml -install
would install the library on your system.
As for using mli's. There's a tiny bit of controversy regarding them. Here's a discussion from the mailing lists: http://www.mentby.com/Group/caml-list/why-should-i-use-mli-files.html
My own opinion is that they are optional unless your modules are part of a public API that others will use. In which case they are mandatory.
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