Article View: fa.caml
Article #52RE: [Caml-list] automatic extaction of the .mli (and a little more) from the .ml
From: David Allsopp
Date: Tue, 04 Jun 2013 07:53
Date: Tue, 04 Jun 2013 07:53
61 lines
6057 bytes
6057 bytes
Romain Bardou wrote: > I also used to believe the .mli file should be somehow included in the .ml > file. Now I don't. +1, FWIW! It's easy to start without the .mli when prototyping and then add it as things mature. > But if you design such a tool, here are some things to consider. > > - Using numbers to order stuff creates some issues of scalability. In > particular, inserting a declaration between #3 and #4 may require you to > move #4 to #5, #5 to #6 and so on, which (in particular if everything is > not in the right order in the implementation) can prove more annoying than > reordering stuff in an .mli. This is horrible, IMO - any design decision which looks like it'll *require* refactoring support from an editor to be able to work with it strikes me as a bad design decision. If you have hundreds of these in a file, at some point you'll need a "renumber everything" macro. I have wondered if this problem is perhaps looked at the wrong way around - in other words, the complaint takes the form "how can we export to the .mli file automatically" rather than "how can we *import* from the .ml file automatically". The thing I do find irritating maintaining .mli/.ml files is having to type anything out twice - and for the most part that means fully exported type declarations. Say you have a simple module: Foo.mli (separate file, so the items can appear in a different order trivially) ======= (** Foo. This module is an example *) (** Annotation *) type t = A (** Annotation *) | B (** Annotation *) val bar : t -> bool (** [bar x] returns true if [x] is [A] *) Foo.ml ====== type t = A | B (* This duplication is annoying *) let bar x = (x = A) (* No type declaration needed here *) For me, "val bar" in the .mli and "let bar" in the .ml is not duplication as one is the implementation and the other is the exported type. However, I do find having to maintain type t in two files irritating (say if I want to add the constructor C) - especially if t has hundreds of constructors where you have to make sure the order is the same too, of course. What would be nice would be to be able to put this in the /.ml/ file: (** Annotation *) type t = A (** Annotation *) | B (** Annotation *) and then this in the /.mli/ file: type t from implementation or export type t which would export the entire declaration and also its ocamldoc comments. For an opaque type, you have different declarations anyway, so just write them. The same would be true of module types and so on. Just my 2p! David -- 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
Technical Details
Message-ID:
<fa.1Prz+i/q1iTOfA4HYPhd0lmmYco@ifi.uio.no>Path:
arc1-ca.pugleaf.net!fw11ni944wic.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.208.113.1.MISMATCH!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mailReferences:
<fa.ysPYFL5+u0NnfGu8UBtNleD9SeQ@ifi.uio.no> <fa.OQroQDVDk9br1ZhQEIL1NaakR5I@ifi.uio.no> <fa.bD6TGMY7hcijji7TE20fgVNMYJ0@ifi.uio.no> <fa.kLitjS6+thDvPu069t19jM9fjnc@ifi.uio.no>Show Full Headers
Complete Article Headers
X-Google-Thread: ff861,bcac4a6e27ff55dd
X-Google-NewGroupId: yes
X-Google-Attributes: gidc0fe4b917e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.180.14.40 with SMTP id m8mr92043wic.7.1370332436123;
Tue, 04 Jun 2013 00:53:56 -0700 (PDT)
Path: arc1-ca.pugleaf.net!fw11ni944wic.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.208.113.1.MISMATCH!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: David Allsopp <dra-news@metastack.com>
Newsgroups: fa.caml
Subject: RE: [Caml-list] automatic extaction of the .mli (and a little more)
from the .ml
Date: Tue, 04 Jun 2013 07:53:55 UTC
Organization: MetaStack Solutions Ltd.
Lines: 61
Sender: caml-list-request@inria.fr
Message-ID: <fa.1Prz+i/q1iTOfA4HYPhd0lmmYco@ifi.uio.no>
References: <fa.ysPYFL5+u0NnfGu8UBtNleD9SeQ@ifi.uio.no> <fa.OQroQDVDk9br1ZhQEIL1NaakR5I@ifi.uio.no> <fa.bD6TGMY7hcijji7TE20fgVNMYJ0@ifi.uio.no> <fa.kLitjS6+thDvPu069t19jM9fjnc@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1370332435 831 129.240.7.9 (4 Jun 2013 07:53:55 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Tue, 4 Jun 2013 07:53:55 +0000 (UTC)
To: Romain Bardou <romain.bardou@inria.fr>,
"caml-list@inria.fr"
<caml-list@inria.fr>
X-IronPort-AV: E=Sophos;i="4.87,798,1363129200";
d="scan'208";a="20195169"
X-Original-To: caml-list@sympa.inria.fr
Delivered-To: caml-list@sympa.inria.fr
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AooAALqbrVFRZ900nGdsb2JhbABZgmhRvwaBABYOAQEBAQEGDQkJFCiCIwEBAQMBJxNECwIBCBgKFBAyJQIEARqHfwcDvROOdTiCd2EDk22DUZMYgTeCJw
X-IPAS-Result: AooAALqbrVFRZ900nGdsb2JhbABZgmhRvwaBABYOAQEBAQEGDQkJFCiCIwEBAQMBJxNECwIBCBgKFBAyJQIEARqHfwcDvROOdTiCd2EDk22DUZMYgTeCJw
X-IronPort-AV: E=Sophos;i="4.87,798,1363129200";
d="scan'208";a="16668698"
Thread-Topic: [Caml-list] automatic extaction of the .mli (and a little
more) from the .ml
Thread-Index: AQHOXbEfSaBAF3FKQU2pLmZI8Q/+85kexO87///+Z4CAAC3YAIAGQFww
In-Reply-To: <51A868F8.9050101@inria.fr>
Accept-Language: en-GB, en-US
x-originating-ip: [172.16.0.18]
X-Scanned-By: MIMEDefang 2.65 on 172.16.0.20
X-Cloudmark-Analysis: v=1.1 cv=AUhbpHVS+xhHrj9wLCYAQoYnFLYUZdbP8UM0GmH2jwk= c=1 sm=0 a=IXlcok0kcmcA:10 a=WqH6JILulzsA:10 a=cTs9vV391PwA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=OsdYDu0FkERgdrBRIMsA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
X-Sequence: 6882
X-no-archive: yes
List-Id: <caml-list.inria.fr>
List-Archive: <http://sympa.inria.fr/sympa/arc/caml-list>
List-Help: <mailto:sympa_inria@inria.fr?subject=help>
List-Owner: <mailto:caml-list-request@inria.fr>
List-Post: <mailto:caml-list@inria.fr>
List-Subscribe: <mailto:sympa_inria@inria.fr?subject=subscribe%20caml-list>
List-Unsubscribe: <mailto:sympa_inria@inria.fr?subject=unsubscribe%20caml-list>
Original-Date: Tue, 4 Jun 2013 07:53:44 +0000
Original-Message-Id: <E51C5B015DBD1348A1D85763337FB6D9CC7F39B8@Remus.metastack.local>
Original-References: <51A81C67.50902@riken.jp> <87bo7rogub.fsf@gmail.com>
<51A84283.80309@riken.jp> <51A868F8.9050101@inria.fr>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
Content-Language: en-US