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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id AF8797F249 for ; Tue, 30 Oct 2012 17:14:45 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of didier.cassirame@gmail.com) identity=pra; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of didier.cassirame@gmail.com designates 209.85.219.54 as permitted sender) identity=mailfrom; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-oa0-f54.google.com) identity=helo; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="postmaster@mail-oa0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAAX8j1DRVds2m2dsb2JhbABEhhirBoksAYh1CCMBAQEBAQgJCwkUJ4IeAQEBAwESAg8dARsSCwEDAQsGBQsaGgMCAiIBEQEFAQoBEQYTEhCHUQEDCQYLnWNiCQOLYU+BbIEKhQgKGScDClmIdQEFDItrhUqBEwOVdYEajUcWKYJQgUI X-IronPort-AV: E=Sophos;i="4.80,680,1344204000"; d="scan'208";a="179567431" Received: from mail-oa0-f54.google.com ([209.85.219.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Oct 2012 17:14:44 +0100 Received: by mail-oa0-f54.google.com with SMTP id n9so747427oag.27 for ; Tue, 30 Oct 2012 09:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=CQK3zSlLbhmOqxSDmZ9xRRElpUaYki5aV/2htUGraU8=; b=bS3uXHuaJkBfETi5RYZANicmhBKZwAgENJvZ8MZcVYJEcrHtTkpejsCdfRivPTrzIL rf1m08j/Y9Tyr6T387kz/0R3T2jjbMoQDoArzAUGhkfobCRh0o3kKbN1G4KQ8XAAi2fp ry8TFR1QlYEMKe909Qw0hGJV/xLVTuySWNkDl9bs5PoRDvG8ekzplnVbAjVSS9DNSgEV yzD8dxxBqVR+2TLXYRNNEMiwZOuaz44w5SSzBoNBk7wKAQtKisE60u4iYsbxpt7oYDxi kWVaAgezJqavKBKKNL19DXR4m4s1Bw9W6PC5YCsLaOzZyOj+7e1Nez0AtTL9NV9KqWt0 ArNw== Received: by 10.60.7.225 with SMTP id m1mr29968825oea.122.1351613683319; Tue, 30 Oct 2012 09:14:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.137.198 with HTTP; Tue, 30 Oct 2012 09:14:23 -0700 (PDT) In-Reply-To: <508FF8B2.8080209@inria.fr> References: <508F22BD.7010103@riken.jp> <508FF8B2.8080209@inria.fr> From: Didier Cassirame Date: Tue, 30 Oct 2012 17:14:23 +0100 Message-ID: To: Romain Bardou Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=e89a8fb1ef4077c3e004cd49151f Subject: Re: [Caml-list] Why should I use .mli files? --e89a8fb1ef4077c3e004cd49151f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Indeed, I didn't know the "module type of" construct! didier 2012/10/30 Romain Bardou > Maybe you can just write "include module type of X" where X is the module > which already has the .mli. Or you define the signature as a module type > Sig in a separate file "x.ml" and write "include X.Sig". > > Cheers, > > -- > Romain Bardou > > Le 30/10/2012 16:52, Didier Cassirame a =C3=A9crit : > >> >> Thinking about it, there's at least one case where mli files are not so >> useful: When you have several modules which must all comply with a >> certain module type. In that case, all the mli files would be identical, >> and a modification of the module type would necessitate to change all >> the .mli. >> What would be the best way to handle that situation? >> I was thinking of making an inner module, coerce it to the desired type, >> and open it afterwards, but the resulting module would still have a ref >> to the inner module in its type. >> >> E.g.: >> >> in the file mymodule.ml >> >> >> -----------------------8<-----**-------------- >> >> module Inner =3D ( >> struct >> >> (* implementation *) >> >> end : Sig) >> >> open Inner >> >> -----------------------8<-----**-------------- >> >> and the file sig.mli would be the required module type. >> >> didier >> >> 2012/10/30 Francois Berenger > >> >> >> >> 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 >> >> > >> >> >> > > -- > 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 > --e89a8fb1ef4077c3e004cd49151f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Indeed, I didn't know the "module type of" construct!
didier

2012/10/30 Romain Bardou <r= omain.bardou@inria.fr>
Maybe you can just write "include modul= e type of X" where X is the module which already has the .mli. Or you = define the signature as a module type Sig in a separate file "x.ml" and write "include X= .Sig".

Cheers,

--
Romain Bardou

Le 30/10/2012 16:52, Didier Cassirame a =C3=A9crit :

Thinking about it, there's at least one case where mli files are not so=
useful: When you have several modules which must all comply with a
certain module type. In that case, all the mli files would be identical,
and a modification of the module type would necessitate to change all
the .mli.
What would be the best way to handle that situation?
I was thinking of making an inner module, coerce it to the desired type,
and open it afterwards, but the resulting module would still have a ref
to the inner module in its type.

E.g.:

in the file mymodule.ml <http://mymodule.ml>


-----------------------8<-------------------

module Inner =3D (
struct

=C2=A0 =C2=A0(* implementation *)

end : Sig)

open Inner

-----------------------8<-------------------

and the file sig.mli would be the required module type.

didier

2012/10/30 Francois Berenger <
berenger@riken.jp <mailto:berenger@riken.jp>>


=C2=A0 =C2=A0 Hello,

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

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

=C2=A0 =C2=A0 Does it make compilation of large software faster
=C2=A0 =C2=A0 by allowing for more parallelization and maybe later on avoid= ing to
=C2=A0 =C2=A0 recompile some parts?

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

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

=C2=A0 =C2=A0 Thanks a lot,
=C2=A0 =C2=A0 Francois.

=C2=A0 =C2=A0 --
=C2=A0 =C2=A0 Caml-list mailing list. =C2=A0Subscription management and arc= hives:
=C2=A0 =C2=A0 https://sympa.inria.fr/sympa/__arc/caml-list
=C2=A0 =C2=A0 <https://sympa.inria.fr/sympa/arc/caml-list> =C2=A0 =C2=A0 Beginner's list: http://groups.yahoo.com/group/= __ocaml_beginners
=C2=A0 =C2=A0 <http://groups.yahoo.com/group/ocaml_beginners= >
=C2=A0 =C2=A0 Bug reports: http://caml.inria.fr/bin/caml-__bugs
=C2=A0 =C2=A0 <http://caml.inria.fr/bin/caml-bugs>



--e89a8fb1ef4077c3e004cd49151f--