Hi Francois,

To add a different perspective, I usually start without mli files. I do this for one of the reasons you give: leaving most typing up to inferencing.

But parts of my code move into the realm of libraries which are reused, and here I'll make the mli files concrete. This aids in pinning down type errors where they really are, forms a kind of documentation, and provides a nice abstract view of a module suitable for functors.

When you pin down some types, it gives the type system more info to help you, the programmer. So if you have a module which is fairly concrete and not likely to change -- specifying the exact signature in an mli can identify erroneous usage of this module, rather than throwing a more obscure type error because the inference can't know if the problem is in the module you're using or the way it's used.

If you are writing small programs and not much reused library-like code, then you really might not benefit from explicit mli files. They can be a minor pain, since you have to update them with additions or changes of the corresponding ml.

Overall, mli's have their place, but I'm glad OCaml has implicit mli files... so that in cases where they aren't needed, you can ignore them!

-Tony


On Mon, Oct 29, 2012 at 8:36 PM, Francois Berenger <berenger@riken.jp> wrote:
On 10/30/2012 10:19 AM, Daniel Bünzli wrote:
Le mardi, 30 octobre 2012 à 01:43, Francois Berenger a écrit :
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.

For me, a program that lacks mli files means lack of design, abstraction and documentation and hence equates with rubbish.

Thanks for the compliment.

To my defence, my main programming goal because of my employer
and colleagues is to deliver fast and correct (software) in order to investigate research ideas.
We don't deliver libraries or things targeting at a wide developer
audience (we don't do research in computer science, also).


For example at a certain point you (or others) will read your code.

I don't have any problem reading my code.
It reads like an English text usually.


>At that moment simple things like being able to distinguish between functions/types that are local to a module and those that are used by other part of the program is immensely useful.

Well, if I want to know this, I change the function parameters
and let the compiler tell me where it was used with the initial parameters.
I also quite know my swiss knives (egrep and co).


> And that's only one of the purpose of mli files.

In fact mli files are the first thing I write when I design programs.

OK, so you too are a top-down design practitioner
and use .mli files to this end.

Thanks,
F.



--
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