If you only do small projects, you're probably doing things right by ignoring the .mli files. Languages like Ruby and Python don't have signature files and that's part of what makes them good for scripting tasks.

But since you asked, here's why I use mli files almost always:

1) The signature files are my "architecture." When I start implementing something substantial, I'll first make the .mli files for the modules I think I'll need. I can pretty quickly refactor them until they make sense semantically and compile against each other. It's not unusual for me to change an .mli file 10 times before I bother starting to implement it. After that, I just use the unimplemented methods as my todo list.

2) Documentation. Sometimes I have a module with a 1000 line .ml file and 30 line .mli file (with comments). Much easier to refer to the .mli to reuse it's methods.

-Peter

On Mon, Oct 29, 2012 at 7:43 PM, Francois Berenger <berenger@riken.jp> wrote:
Hello,

Here is my stupid question of the day:
what's the use of those .mli files?

Is it just to separate interface from implementation
so that the implementation of a module can be changed
without clients of its interface to have to bother?

Does it make compilation of large software faster
by allowing for more parallelization and maybe later on avoiding to recompile some parts?

Usually I program in a pure functional style, so my modules
don't carry an internal state.
I feel like "if someone want to re-use a function, so be it".
If I really want to hide a function that I am afraid people
may call in an incorrect manner, I declare it internally
to some public function and use it correctly.

Also, maybe I only work on toy-size OCaml projects. So, I never bothrered to create any .mli file.
I would like to know if I should bother about them.

Thanks a lot,
Francois.

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs