From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id D9AD07F249 for ; Tue, 30 Oct 2012 04:26:12 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of anthony.tavener@gmail.com) identity=pra; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of anthony.tavener@gmail.com designates 209.85.210.182 as permitted sender) identity=mailfrom; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ia0-f182.google.com) identity=helo; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="postmaster@mail-ia0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnABAItHj1DRVdK2mGdsb2JhbAA6CrEfiSoBiG4IIwEBAQEBBgsNBxQngh4BAQEDARICLAEbEgsBAwELBgULDQ0hIgERAQUBChIGExIQh1EBAwkGC5xkYgkDjDCCdoRpChknAwpZiHUBBQyLaRCGTQOIWYlpgzKBGo1HFimCUIFg X-IronPort-AV: E=Sophos;i="4.80,676,1344204000"; d="scan'208";a="160829514" Received: from mail-ia0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Oct 2012 04:26:11 +0100 Received: by mail-ia0-f182.google.com with SMTP id k10so7859950iag.27 for ; Mon, 29 Oct 2012 20:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Jlf5VIxkSCmkRAbWVg9baeDqIC+2aFXGy8yivknuAtg=; b=HyIH2hrChGaNP/xRxayn5ZzvbXWruUGmgcfFBXj698FtQxrLkaPWHqYlQ2DG0limjS 2l071p1UOo8rIS07e6G+8BQUr5Ksu6kEuuGlBqYPmEKCSPsLAfjpfJJiJp3IuD6/d56e t7SqMPrU4ViIV36px4V+8rb8b8AdfqBD7jBMoLxCCYIXgym3bkegLmLTDWlLlzlW1N0+ /8OuiOFPurDuJIhHyZIR13ejLTb6XtlZpSzBtlIvks4fE6XAnctFcsnODR6Bsut+OauL qc0CgRY4KjznDxSMJ4dMXoSJ7IxQG0f+tJKx6UDcXWolCNOkcu5180hL86jPN8Whdwp3 vwiw== MIME-Version: 1.0 Received: by 10.50.196.193 with SMTP id io1mr215939igc.59.1351567570246; Mon, 29 Oct 2012 20:26:10 -0700 (PDT) Received: by 10.42.196.71 with HTTP; Mon, 29 Oct 2012 20:26:09 -0700 (PDT) In-Reply-To: <508F3D3D.3070600@riken.jp> References: <508F22BD.7010103@riken.jp> <508F3D3D.3070600@riken.jp> Date: Mon, 29 Oct 2012 21:26:09 -0600 Message-ID: From: Anthony Tavener To: Francois Berenger Cc: =?ISO-8859-1?Q?Daniel_B=FCnzli?= , caml-list Content-Type: multipart/alternative; boundary=14dae93411f5ea1c8d04cd3e5811 Subject: Re: [Caml-list] Why should I use .mli files? --14dae93411f5ea1c8d04cd3e5811 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 wrote: > On 10/30/2012 10:19 AM, Daniel B=FCnzli wrote: > >> Le mardi, 30 octobre 2012 =E0 01:43, Francois Berenger a =E9crit : >> >>> 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 oth= er > 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 parameter= s. > 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 > --14dae93411f5ea1c8d04cd3e5811 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Francois,

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

But parts of my cod= e 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 r= eally 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 fai= rly 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 l= ibrary-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 O= Caml has implicit mli files... so that in cases where they aren't neede= d, you can ignore them!

-Tony


On Mon, Oct 29, 2012 at 8:36 PM, Franco= is Berenger <berenger@riken.jp> wrote:
On 10/30/2012 10:19 AM, Daniel B=FCnzli wrote:
Le mardi, 30 octobre 2012 =E0 01:43, Francois Berenger a =E9crit :
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 an= d 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 invest= igate 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 fun= ctions/types that are local to a module and those that are used by other pa= rt 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.

--14dae93411f5ea1c8d04cd3e5811--