From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 8066DBBC4 for ; Sat, 18 Apr 2009 07:47:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiAGAOYG6UnRVdmeWmdsb2JhbACCITCKUohXNQEWCgsHEgKlaIEJkAEBAwEDg3oGh2E X-IronPort-AV: E=Sophos;i="4.40,208,1238968800"; d="scan'208";a="38665937" Received: from mail-gx0-f158.google.com ([209.85.217.158]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Apr 2009 07:47:40 +0200 Received: by gxk2 with SMTP id 2so33597gxk.3 for ; Fri, 17 Apr 2009 22:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=DhkjpfXsltatBfI+dUFeinnqbycfUDsaSwRD5HUTYs4=; b=Au7zhBb7tfntgs+sWdxmEGRuqvX0ZNSgoYWpIRfXiJuswzPNvKgW11afkh6LBmBUJX NlXkLn1RtaJo23ID2aALsPviXa4+/ZpwSLJEJx0WAk4knYy3I3kfWtkdzrgCzXMIlbiN jftT1v/Fj/opotqA0WU0fQKjFCkhwYeDKcdFw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=i7HHH/+IqOw8ossnCnwqRFglTOy9DFEMUEoJzeQQGCU/8BU3/WkH5vHM+GdkVMA9co WYkCUDjdbui6YG77Rp31yJC0E5n1dylPxl1t1Ld0+EfF4M3vXvENeGqM9vM45EzFgFuX FAuUBIGn/XhKPA5aGn97wyhWuboyf5bYhzKmU= MIME-Version: 1.0 Received: by 10.90.70.6 with SMTP id s6mr4143841aga.52.1240033658536; Fri, 17 Apr 2009 22:47:38 -0700 (PDT) In-Reply-To: References: Date: Sat, 18 Apr 2009 01:47:38 -0400 Message-ID: Subject: Re: [Caml-list] Extending modules and signatures From: Ashish Agarwal To: Peter Hawkins Cc: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=00163630f4a1ba071a0467cdd546 X-Spam: no; 0.00; mli:01 mylist:01 struct:01 foo:01 mli:01 mylist:01 sig:01 val:01 foo:01 val:01 cheers:01 beginner's:01 ocaml:01 bug:01 struct:01 --00163630f4a1ba071a0467cdd546 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This is a commonly requested feature. One issue is that a file a.ml creates a module A. However, a file a.mli does not create a module type A. I'm not sure why this is the case. Does anyone know if there is a specific reason? On Fri, Apr 17, 2009 at 4:51 PM, Peter Hawkins wrote: > Hi... > > I have a quick question. I want to extend the List module with various > functions that I want that aren't present in the standard library, > much as the Batteries ExtList library does. > > I might write the following code in "mylibrary.ml": > module MyList = struct > include List > let foo x = ... code here > let bar y = ... code here > end > > That's ok so far, but now suppose I want to write a "mylibrary.mli" > interface file corresponding to "mylibrary.ml". Ideally I'd write > something like this in "mylibrary.mli": > module MyList : sig > include List (* unknown module type List *) > val foo : ... > val bar : ... > end > > Unfortunately I can't include "List" here since it is a structure, not > a signature. I don't think there is a way to say "include the > signature associated with List". > > I can think of three solutions: > a) Copy the complete signature of List into MyList. This is a bad idea > since the List module might change in the future. This is what the > Batteries ExtList module does. > b) Alter the List module to define a signature, say List.S, in > addition to its other contents. I can't easily do this since I didn't > write the List module. > c) Don't write a .mli file at all. > > Are there any other alternatives? > > Cheers, > Peter > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --00163630f4a1ba071a0467cdd546 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This is a commonly requested feature. One issue is that a file a.ml creates a module A. However, a file a.mli does not cre= ate a module type A. I'm not sure why this is the case. Does anyone kno= w if there is a specific reason?


On Fri, Apr 17, 2009 at 4:51 PM, Peter H= awkins <ha= wkinsp@cs.stanford.edu> wrote:
Hi...

I have a quick question. I want to extend the List module with various
functions that I want that aren't present in the standard library,
much as the Batteries ExtList library does.

I might write the following code in "mylibrary.ml":
module MyList =3D struct
=A0include List
=A0let foo x =3D ... code here
=A0let bar y =3D ... code here
end

That's ok so far, but now suppose I want to write a "mylibrary.mli= "
interface file corresponding to "mylibrary.ml". Ideally I'd write
something like this in "mylibrary.mli":
module MyList : sig
=A0include List =A0(* unknown module type List *)
=A0val foo : ...
=A0val bar : ...
end

Unfortunately I can't include "List" here since it is a struc= ture, not
a signature. I don't think there is a way to say "include the
signature associated with List".

I can think of three solutions:
a) Copy the complete signature of List into MyList. This is a bad idea
since the List module might change in the future. This is what the
Batteries ExtList module does.
b) Alter the List module to define a signature, say List.S, in
addition to its other contents. I can't easily do this since I didn'= ;t
write the List module.
c) Don't write a .mli file at all.

Are there any other alternatives?

Cheers,
Peter

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--00163630f4a1ba071a0467cdd546--