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 D6D0A7EE20 for ; Mon, 19 Nov 2012 15:48:26 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of Tiphaine.Turpin@free.fr) identity=pra; client-ip=212.27.42.1; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Tiphaine.Turpin@free.fr"; x-sender="Tiphaine.Turpin@free.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of Tiphaine.Turpin@free.fr) identity=mailfrom; client-ip=212.27.42.1; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Tiphaine.Turpin@free.fr"; x-sender="Tiphaine.Turpin@free.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp1-g21.free.fr) identity=helo; client-ip=212.27.42.1; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Tiphaine.Turpin@free.fr"; x-sender="postmaster@smtp1-g21.free.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai4BAApGqlDUGyoBjmdsb2JhbABFhiCFX6QnkxsjAQEBAQkLCQkSBSSCHgEBBAEjMBsKBgsLGAkEEggDAgIJAwIBAgEzARETBgIBAQ4Jh18BAwkKB60MiBUJQQOJXow0g3qBEwOVfIEchE+NSA X-IronPort-AV: E=Sophos;i="4.83,280,1352070000"; d="scan'208,217";a="182177215" Received: from smtp1-g21.free.fr ([212.27.42.1]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Nov 2012 15:48:25 +0100 Received: from [192.168.0.1] (bur91-2-82-231-161-160.fbx.proxad.net [82.231.161.160]) (Authenticated sender: tiphaine.turpin) by smtp1-g21.free.fr (Postfix) with ESMTPA id 89697940194 for ; Mon, 19 Nov 2012 15:48:22 +0100 (CET) Message-ID: <50AA5462.9090201@free.fr> Date: Mon, 19 Nov 2012 16:46:42 +0100 From: Tiphaine Turpin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120501 Thunderbird/10.0.3 MIME-Version: 1.0 To: caml-list@inria.fr References: <50A9C3BB.2050900@riken.jp> <50A9CB66.1020207@ens-lyon.org> <50A9D378.4020403@riken.jp> In-Reply-To: Content-Type: multipart/alternative; boundary="------------040201050809000004080406" Subject: Re: [Caml-list] module alias in a .mli file This is a multi-part message in MIME format. --------------040201050809000004080406 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit In fact, the solution module V3 : module type of Vector3 does not work completely, because, the equality between Vector3 and V3 is lost, which poses problem with the types defined by Vector 3. What works is: include module type of struct module V3 = Vector3 end Here is a full example: module M : sig module Vector3 : sig type t end (* module V3 : module type of Vector3 *) include module type of struct module V3 = Vector3 end end = struct module Vector3 = struct type t end module V3 = Vector3 end open M let id (x : Vector3.t) : V3.t = x Regards, Tiphaine On 11/19/12 13:44, Paolo Donadeo wrote: > > Actually this is not true, Martin explained how. :-) > > > -- > Paolo > Sent by Gmail from Android > > Il giorno 19/nov/2012 11:35, "David House" > ha scritto: > > Annoyingly though, there is no way to create a module alias in an mli. > > If, in an ml file, you have to refer often to > Some_very_long_module_name, it can quite convenient to define an alias > by doing "module Mod = Some_very_long_module_name" (or, locally, "let > module Mod = Some_very_long_module_name in"). But there is no way of > doing this in an mli: you have to use the long name every time. > > This is especially annoying if you have some big type that you want to > expose in the mli. You really just want to copy-paste out of the ml > file and stick it into the mli, but then you have to expand all the > module aliases. (It's just a couple of goes with M-%, but still...) > > On Mon, Nov 19, 2012 at 6:36 AM, Francois Berenger > > wrote: > > On 11/19/2012 03:02 PM, Martin Jambon wrote: > >> > >> On Sun 18 Nov 2012 09:29:31 PM PST, Francois Berenger wrote: > >>> > >>> Hello, > >>> > >>> Here is my stupid question of the day: > >>> can't I declare the following in a .mli file? > >>> > >>> module V3 = Vector3 > >> > >> > >> No, because "= Vector3" specifies an implementation. > >> An mli file is a module interface, and module interfaces never > contain > >> implementations. > >> > >> However, you may want to do this, which does what it says: > >> > >> module V3 : module type of Vector3 > > > > > > Thanks a lot! That's exactly what I needed. :) > > > > > > > > > > -- > > 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 > --------------040201050809000004080406 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit In fact, the solution

  module V3 : module type of Vector3

does not work completely, because, the equality between Vector3 and V3 is lost, which poses problem with the types defined by Vector 3. What works is:

  include module type of struct module V3 = Vector3 end

Here is a full example:

module M : sig

  module Vector3 : sig type t end
  (* module V3 : module type of Vector3 *)
  include module type of struct module V3 = Vector3 end

end = struct

  module Vector3 = struct type t end
  module V3 = Vector3

end 

open M
let id (x : Vector3.t) : V3.t = x


Regards,

Tiphaine


On 11/19/12 13:44, Paolo Donadeo wrote:

Actually this is not true, Martin explained how. :-)


--
Paolo
Sent by Gmail from Android

Il giorno 19/nov/2012 11:35, "David House" <dhouse@janestreet.com> ha scritto:
Annoyingly though, there is no way to create a module alias in an mli.

If, in an ml file, you have to refer often to
Some_very_long_module_name, it can quite convenient to define an alias
by doing "module Mod = Some_very_long_module_name" (or, locally, "let
module Mod = Some_very_long_module_name in"). But there is no way of
doing this in an mli: you have to use the long name every time.

This is especially annoying if you have some big type that you want to
expose in the mli. You really just want to copy-paste out of the ml
file and stick it into the mli, but then you have to expand all the
module aliases. (It's just a couple of goes with M-%, but still...)

On Mon, Nov 19, 2012 at 6:36 AM, Francois Berenger <berenger@riken.jp> wrote:
> On 11/19/2012 03:02 PM, Martin Jambon wrote:
>>
>> On Sun 18 Nov 2012 09:29:31 PM PST, Francois Berenger wrote:
>>>
>>> Hello,
>>>
>>> Here is my stupid question of the day:
>>> can't I declare the following in a .mli file?
>>>
>>> module V3 = Vector3
>>
>>
>> No, because "= Vector3" specifies an implementation.
>> An mli file is a module interface, and module interfaces never contain
>> implementations.
>>
>> However, you may want to do this, which does what it says:
>>
>>   module V3 : module type of Vector3
>
>
> Thanks a lot! That's exactly what I needed. :)
>
>
>
>
> --
> 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

--------------040201050809000004080406--