From: Edgar Friendly <thelema314@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Why should I use .mli files?
Date: Wed, 31 Oct 2012 09:50:05 -0400 [thread overview]
Message-ID: <50912C8D.9070600@gmail.com> (raw)
In-Reply-To: <CAPFanBHcmSy3vAS8G+CHey1YZ-6kyYxxgtHJdkt40fmr54Fw1g@mail.gmail.com>
On 10/30/2012 5:25 PM, Gabriel Scherer wrote:
> ## Proposal
>
> 1. allow to insert signature items anywhere in a module structure or
> .ml file, giving a reasonable semantics to it
> (in particular allow inclusion of signature as a structure item,
> with the derived semantics)
This seems a quite reasonable feature for OCaml to have, as annotating
the desired type of a declaration
> 2. have a syntax to designate the mli signature from the ml file
> (possible suggestion: "module type", used a signature expression)
Eww. This seems quite ugly, especially using the complex "with type foo
= bar" syntax for something as common as giving the implementation of an
abstract type.
> It is also natural, in particular if you come from the world of C
> prototypes and predeclared types, to wish to accept something like
> type u
> type u = int (* refining semantics *)
> I think we should reject those because they have a muddier semantic
> (you could define what the least abstract "unifier" of two definitions
> would be, but let's net get down that road). The "S with type u = ..."
> (in particular when S is "module type") allows to refine type in a
> principle way without shadowing/redeclaration.
Maybe it's my over-exposure to C++ lately, but I see a clear semantic
for type re-declaration:
1) It is only allowed to re-declare types from the auto-import of a
module signature
2) abstract types can be re-declared arbitrarily
3) private foo types can be re-declared to foo
Nothing else can be re-declared.
I might even go so far as to say that these re-declarations have to be
at the top of the module definition; before any value declarations or
private type declarations. I see some use in forcing these to complete
before normal compilation can proceed, to avoid the case of having to
type a value before its concrete type is declared.
module Foo = sig
type t
val x : t
end = struct
let x = 5
type t = string
end
Rules like this should allow a module signature to have its typechecking
effect on the associated module implementation as that module
implementation is compiled and typechecked without needing a second pass
over the inferred signature of the module to verify that the final
result of the module is compatible. Not that the second pass is a bad
thing, but you're right that we will enable better error messages from a
one-pass, local typing as opposed to a global structure comparison.
E.
next prev parent reply other threads:[~2012-10-31 13:50 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-30 0:43 Francois Berenger
2012-10-30 1:04 ` Peter Groves
2012-10-30 2:21 ` Francois Berenger
2012-10-30 1:15 ` malc
2012-10-30 2:24 ` Francois Berenger
2012-10-30 10:23 ` malc
2012-10-30 1:19 ` Daniel Bünzli
2012-10-30 2:36 ` Francois Berenger
2012-10-30 3:26 ` Anthony Tavener
2012-10-30 12:28 ` Daniel Bünzli
2012-10-31 0:53 ` Francois Berenger
2012-10-30 2:21 ` gallais @ ensl.org
2012-10-30 6:12 ` Anton Lavrik
2012-10-30 9:18 ` Francois Berenger
2012-10-30 10:01 ` Malcolm Matalka
2012-10-30 11:03 ` Richard W.M. Jones
2012-10-30 11:41 ` [Caml-list] " Hongbo Zhang
2012-10-30 13:31 ` Romain Bardou
2012-10-31 1:03 ` Francois Berenger
2012-10-31 1:44 ` Daniel Bünzli
2012-10-31 9:51 ` Oliver Bandel
2012-10-30 14:32 ` [Caml-list] " Oliver Bandel
2012-10-30 14:45 ` Anton Lavrik
2012-10-30 14:49 ` Oliver Bandel
2012-10-30 14:51 ` Didier Cassirame
2012-10-30 14:47 ` Romain Bardou
2012-10-30 16:06 ` Edgar Friendly
2012-10-30 16:21 ` Romain Bardou
2012-10-30 16:46 ` Edgar Friendly
2012-10-30 21:25 ` Gabriel Scherer
2012-10-30 22:18 ` Oliver Bandel
2012-10-31 9:25 ` Gabriel Scherer
2012-10-31 9:59 ` Daniel Bünzli
2012-10-31 13:22 ` Edgar Friendly
2012-10-31 13:38 ` Daniel Bünzli
2012-10-31 13:55 ` Edgar Friendly
2012-10-31 13:43 ` Gabriel Scherer
2012-11-01 0:38 ` Francois Berenger
2012-11-01 0:42 ` Edgar Friendly
2012-11-01 0:52 ` Francois Berenger
2012-11-01 2:06 ` Edgar Friendly
2012-11-01 2:37 ` Francois Berenger
2012-11-01 2:44 ` Jacques Garrigue
2012-11-01 7:45 ` Andreas Rossberg
2012-10-31 10:20 ` Alain Frisch
2012-10-31 13:50 ` Edgar Friendly [this message]
2012-10-31 15:12 ` Gabriel Scherer
2012-10-31 16:48 ` Edgar Friendly
2012-10-31 17:15 ` Gabriel Scherer
2012-10-31 19:05 ` Tiphaine Turpin
2012-10-30 7:43 ` Mike Lin
2012-10-30 15:52 ` Didier Cassirame
2012-10-30 15:56 ` Romain Bardou
2012-10-30 16:14 ` Didier Cassirame
2012-10-31 21:30 ` Oliver Bandel
2012-11-01 15:26 ` Didier Cassirame
2012-10-31 15:32 ` Alain Frisch
2012-10-31 17:32 ` Tiphaine Turpin
2012-10-31 21:40 ` Oliver Bandel
[not found] <fa.4zzWyGZIo+GsGOz7cSC34yWTunY@ifi.uio.no>
2012-10-31 14:32 ` Radu Grigore
[not found] ` <fa.pEEaqh4bLDLiRdYkCRHvi9787TQ@ifi.uio.no>
[not found] ` <fa.JtZOlOTbNCp6rOoRnHhKEARwLDQ@ifi.uio.no>
[not found] ` <fa.s4gDOdOTZVbthjceZ5OEMxHiH90@ifi.uio.no>
[not found] ` <fa.rfsHI3X48Zri1S2pu1SEFowmDZg@ifi.uio.no>
[not found] ` <fa.KulHINoVpgjN1uI63QvwcxoNuiY@ifi.uio.no>
2012-11-01 11:38 ` Radu Grigore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50912C8D.9070600@gmail.com \
--to=thelema314@gmail.com \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox