🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.caml
Article #36

Re: [Caml-list] automatic extaction of the .mli (and a little more) from the .ml

#36
From: oliver
Date: Fri, 31 May 2013 23:13
121 lines
7338 bytes
On Fri, May 31, 2013 at 03:26:11PM +0900, Francois Berenger wrote:
> On 05/31/2013 02:31 PM, Malcolm Matalka wrote:
> >I know of no such tool, but in counter to your premise: I used to think
> >maintaining a .ml and .mli was foolish, however I no longer do.
> 
[...]


[...]
> > so it's a valuable check that what I think my module does is also
> >what the compiler does.  I also tend to write the .mli first, then write
> >the .ml.  I find it to be a great way to develop.
> 
> I don't.
[...]


I also not always start with the mli-file, but it is a good way
to do it, it#s a good habit.

Why?

Because the interface is designed first.
And the implementation will follow.

Especially in teams, this is a really helpful issue:

  1.: Let the team agree on a interface (mli-file)

  2.: Let the project leader or other person who controls the interface for the modules,
      create the mli-files.
      (the interface for modules && responsibility of certain persons for asertain modules
        => interface between responsibilities)

  3.: Put the mli-files into a certain directory, where they have to live.
      Give read-permissions to all the programmers of the team and write permissions
      to the mli-files only for the person, who is responsible for them.


Then necessarily all programmers of the team know, what the interface is,
and can use these files, but not change them. Creating his/her own mli-files
will not make sense, sooner or later, the official mli-files must be used.

And each programmer can write ml-files in personal style, can write one
or more implementations, which need to fir the interface files.

      
But even if these team-worflow would not be used: deigning the
interface first (thinking about the program in types) can often be helpful
to make the design clear from the beginning.

Of course, especially if things are explored rather experimentally,
for example if there is a new field of topics, where the interface
is NOT clear in advance, starting with the mli-files might be rather
a show stopper.
if things are rather experimentally, starting with the ml-file might
be easier to handle.

So, which way to go depends on the field, on the knowledge of the field,
on how much planning (of interface) is possible or necessary and
if it is done in a team or as a single person.

So, both ways have their advantages and disadvantages.

camlc -i   most often worked for me.

In private projects I not necessarily use mli-files always.
At job I have to use other languages, but the above mentioned
way of read-only mli-files for the programmers of a team
would make sense to me.
This would make interfaces much clearer in the real world,
and IMHO is a good argument for OCaml at work.


If some small programs are one at home,
and the mli files follow the ml-files,
I wonder if they are necessary at all.

I sometimes use modules inside a compilation unit,
and if they clutter the interface too much, use signatures
for these inside-modules, not necessarily for the compilation
unit itself.

But it depends....


If ocamlc could print both: the default signature of the ml-file,
as well as the resulting signature, as delimited by the mli-file,
depending on cli-switches, as well as a diff between the ml-file's
default signature and the signature provided by the mli-file,
this would make handling much easier.
Same call of ocamlc, but just change the switch to get the interface
of the ml-file, the mli-file's signature or the diff between them,
this would be nice.

Something like

  ocamlc -i   foobar.ml   # prints default   sig of foobar.ml
  ocamlc -ii  foobar.ml   # prints resulting sig of foobar.ml (either def.-sig or mli-file-sig)

  ocamlc -id   foobar.ml   # prints diff between default sig and resulting sig (mli-sig if there is a mli-file)
  ocamlc -iid  foobar.ml   # prints diff between resulting sig (mli-sig if there is a mli-file) and default sig


Why ocamlc -ii foobar.ml, if 'cat foobar.mli' or 'ocamlc -i foobar.mli' would
give the same result?
Just because the handling would be unified: same command, same filename, just a
different switch.


Hope, this does make some sense not only for me ;-)


Ciao,
   Oliver

-- 
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.PlHGltP7lV5tJscCE9VKosU9coE@ifi.uio.no>
Path: arc1-ca.pugleaf.net!bp1ni28627pbd.1!nntp.google.com!npeer01.iad.highwinds-media.com!feed-me.highwinds-media.com!peer02.fr7!cyclone02.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
References: <fa.ysPYFL5+u0NnfGu8UBtNleD9SeQ@ifi.uio.no> <fa.OQroQDVDk9br1ZhQEIL1NaakR5I@ifi.uio.no> <fa.bD6TGMY7hcijji7TE20fgVNMYJ0@ifi.uio.no>

Show Full Headers
Complete Article Headers
X-Google-Thread: c0fe4b917e,bcac4a6e27ff55dd,start
X-Google-Attributes: gidc0fe4b917e,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.66.227.71 with SMTP id ry7mr2794288pac.30.1370041999870;
        Fri, 31 May 2013 16:13:19 -0700 (PDT)
Path: arc1-ca.pugleaf.net!bp1ni28627pbd.1!nntp.google.com!npeer01.iad.highwinds-media.com!feed-me.highwinds-media.com!peer02.fr7!cyclone02.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: oliver <oliver@first.in-berlin.de>
Newsgroups: fa.caml
Subject: Re: [Caml-list] automatic extaction of the .mli (and a little more)
 from the .ml
Date: Fri, 31 May 2013 23:13:19 UTC
Organization: Internet mailing list
Lines: 121
Sender: caml-list-request@inria.fr
Message-ID: <fa.PlHGltP7lV5tJscCE9VKosU9coE@ifi.uio.no>
References: <fa.ysPYFL5+u0NnfGu8UBtNleD9SeQ@ifi.uio.no> <fa.OQroQDVDk9br1ZhQEIL1NaakR5I@ifi.uio.no> <fa.bD6TGMY7hcijji7TE20fgVNMYJ0@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1370041999 13245 129.240.7.9 (31 May 2013 23:13:19 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Fri, 31 May 2013 23:13:19 +0000 (UTC)
User-Agent: Mutt/1.5.20 (2009-06-14)
Cc: caml-list@inria.fr
To: Francois Berenger <berenger@riken.jp>
X-IronPort-AV: E=Sophos;i="4.87,781,1363129200"; 
   d="scan'208";a="19841620"
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: AugAAJ0tqVHAbSoIe2dsb2JhbABZgzmDPLYahSaBAhYOAQELCwoIFAQkgiMBAQUjVhALCQ8CAgUhAgIPBRgxiCAEp3WSEBaBEI17B4JDM2EDjwmINIEqkW+BOQ
X-IPAS-Result: AugAAJ0tqVHAbSoIe2dsb2JhbABZgzmDPLYahSaBAhYOAQELCwoIFAQkgiMBAQUjVhALCQ8CAgUhAgIPBRgxiCAEp3WSEBaBEI17B4JDM2EDjwmINIEqkW+BOQ
X-IronPort-AV: E=Sophos;i="4.87,781,1363129200"; 
   d="scan'208";a="16382146"
X-Envelope-From: oliver@first.in-berlin.de
In-Reply-To: <51A84283.80309@riken.jp>
X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8
X-Sequence: 6861
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: Sat, 1 Jun 2013 01:13:08 +0200
Original-Message-Id: <20130531231308.GC6483@siouxsie>
Original-References: <51A81C67.50902@riken.jp>
 <87bo7rogub.fsf@gmail.com>
 <51A84283.80309@riken.jp>
X-Received-Bytes: 6958
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline