caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Importing module signatures ?
@ 2007-10-04 12:19 David Teller
  2007-10-04 12:29 ` [Caml-list] " David Allsopp
  2007-10-04 14:09 ` Chris King
  0 siblings, 2 replies; 9+ messages in thread
From: David Teller @ 2007-10-04 12:19 UTC (permalink / raw)
  To: OCaml

   Hi everyone,
 I'm trying to extend a module into another module, preferably without
using functors. For the implementation, I have no problem, simply using
"include" does what I need. For the signature, however, I'm obviously
doing something wrong:
        
        module A =
        struct
        	include String
        end
        
        => works
        
        module A :
        sig
          include String
        end
        
        => "Unbound module type String"
        
It seems that String is the name of the module structure itself rather
than its signature. But what is the name of the signature ?
        
Thanks,
 David
-- 
David Teller ------------------------------------------
Security of Distributed Systems -----------------------
-- http://www.univ-orleans.fr/lifo/Members/David.Teller
----- Laboratoire d'Informatique Fondamentale d'Orleans


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [Caml-list] Importing module signatures ?
  2007-10-04 12:19 Importing module signatures ? David Teller
@ 2007-10-04 12:29 ` David Allsopp
  2007-10-04 13:02   ` David Teller
  2007-10-04 14:09 ` Chris King
  1 sibling, 1 reply; 9+ messages in thread
From: David Allsopp @ 2007-10-04 12:29 UTC (permalink / raw)
  To: 'OCaml'

> It seems that String is the name of the module structure itself rather
> than its signature. But what is the name of the signature ?
        
Module String is not constrained by a named signature - you either need to
copy the interface from string.mli (it'll be in your ocaml lib directory) or
use ocamlc -i to generate an inferred interface and copy it in (cf. the
Extlib module ExtList.List). If there is another way, then I'd be fascinated
to hear it too!


David


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [Caml-list] Importing module signatures ?
  2007-10-04 12:29 ` [Caml-list] " David Allsopp
@ 2007-10-04 13:02   ` David Teller
  0 siblings, 0 replies; 9+ messages in thread
From: David Teller @ 2007-10-04 13:02 UTC (permalink / raw)
  To: David Allsopp; +Cc: 'OCaml'

On Thu, 2007-10-04 at 13:29 +0100, David Allsopp wrote:
> > It seems that String is the name of the module structure itself rather
> > than its signature. But what is the name of the signature ?
>         
> Module String is not constrained by a named signature - you either need to
> copy the interface from string.mli (it'll be in your ocaml lib directory) or
> use ocamlc -i to generate an inferred interface and copy it in (cf. the
> Extlib module ExtList.List). If there is another way, then I'd be fascinated
> to hear it too!

Well, that's what I did. And I'm deeply dissatisfied with copying and
pasting myself.

Cheers,
 David


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 12:19 Importing module signatures ? David Teller
  2007-10-04 12:29 ` [Caml-list] " David Allsopp
@ 2007-10-04 14:09 ` Chris King
  2007-10-04 14:16   ` Daniel Bünzli
  1 sibling, 1 reply; 9+ messages in thread
From: Chris King @ 2007-10-04 14:09 UTC (permalink / raw)
  To: David Teller; +Cc: OCaml

On 10/4/07, David Teller <David.Teller@univ-orleans.fr> wrote:
> It seems that String is the name of the module structure itself rather
> than its signature. But what is the name of the signature ?

The relationship between the foo.ml and foo.mli file is exactly this:

module Foo: sig
  <contents of foo.mli>
end = struct
  <contents of foo.ml>
end

i.e., the .mli is not given a name.  There is a patch to support what
you want to do here [1], using a new statement "import" to include the
signature from an .mli file... it's one of a handful [2] [3] of
patches from Piotr Wieczorek that I'd love to see make it into the
official tree, but I haven't heard from the O'Caml dev team one way or
the other.

- Chris

[1] http://rainbow.mimuw.edu.pl/~pw189451/ocaml/extsig.patch
[2] http://caml.inria.fr/pub/ml-archives/caml-list/2006/12/c7461312202053f2213a9bb33206fcb8.en.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 14:09 ` Chris King
@ 2007-10-04 14:16   ` Daniel Bünzli
  2007-10-04 14:39     ` Vincent Aravantinos
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Bünzli @ 2007-10-04 14:16 UTC (permalink / raw)
  To: OCaml


Le 4 oct. 07 à 16:09, Chris King a écrit :

> I'd love to see make it into the official tree, but I haven't heard  
> from the O'Caml dev team one way or the other.

If you want to raise the chances for this to happen I suggest you  
file a feature request in the bug tracking system. Or if one already  
exists, monitor the issue to give them a hint the feature is  
important to more than a single individual.

Daniel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 14:16   ` Daniel Bünzli
@ 2007-10-04 14:39     ` Vincent Aravantinos
  2007-10-04 18:42       ` Ashish Agarwal
  2007-10-04 18:53       ` Martin Jambon
  0 siblings, 2 replies; 9+ messages in thread
From: Vincent Aravantinos @ 2007-10-04 14:39 UTC (permalink / raw)
  To: OCaml

Le 4 oct. 07 à 16:16, Daniel Bünzli a écrit :
> Le 4 oct. 07 à 16:09, Chris King a écrit :
>
>> I'd love to see make it into the official tree, but I haven't  
>> heard from the O'Caml dev team one way or the other.
>
> If you want to raise the chances for this to happen I suggest you  
> file a feature request in the bug tracking system. Or if one  
> already exists, monitor the issue to give them a hint the feature  
> is important to more than a single individual.
>

I'd love it to (that makes at least two individuals...).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 14:39     ` Vincent Aravantinos
@ 2007-10-04 18:42       ` Ashish Agarwal
  2007-10-04 21:56         ` Chris King
  2007-10-04 18:53       ` Martin Jambon
  1 sibling, 1 reply; 9+ messages in thread
From: Ashish Agarwal @ 2007-10-04 18:42 UTC (permalink / raw)
  To: OCaml

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

(* Sorry if this is posted twice. Last one did not seem to go through. *)

This would be very useful. Also is there a good naming convention for
extending standard modules? I've been doing:

----MyString.ml-----
module String = struct
  include String
  (* ... my extensions *)
end
This way I can do "open MyString" and easily switch between my
extended module versus the standard library. Is this good style?



On 10/4/07, Vincent Aravantinos <vincent.aravantinos@yahoo.fr> wrote:
>
> Le 4 oct. 07 à 16:16, Daniel Bünzli a écrit :
> > Le 4 oct. 07 à 16:09, Chris King a écrit :
> >
> >> I'd love to see make it into the official tree, but I haven't
> >> heard from the O'Caml dev team one way or the other.
> >
> > If you want to raise the chances for this to happen I suggest you
> > file a feature request in the bug tracking system. Or if one
> > already exists, monitor the issue to give them a hint the feature
> > is important to more than a single individual.
> >
>
> I'd love it to (that makes at least two individuals...).
>
> _______________________________________________
> 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
>

[-- Attachment #2: Type: text/html, Size: 2018 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 14:39     ` Vincent Aravantinos
  2007-10-04 18:42       ` Ashish Agarwal
@ 2007-10-04 18:53       ` Martin Jambon
  1 sibling, 0 replies; 9+ messages in thread
From: Martin Jambon @ 2007-10-04 18:53 UTC (permalink / raw)
  To: Vincent Aravantinos; +Cc: OCaml

[-- Attachment #1: Type: TEXT/PLAIN, Size: 858 bytes --]

On Thu, 4 Oct 2007, Vincent Aravantinos wrote:

> Le 4 oct. 07 à 16:16, Daniel Bünzli a écrit :
>> Le 4 oct. 07 à 16:09, Chris King a écrit :
>> 
>> > I'd love to see make it into the official tree, but I haven't heard from 
>> > the O'Caml dev team one way or the other.
>> 
>> If you want to raise the chances for this to happen I suggest you file a 
>> feature request in the bug tracking system. Or if one already exists, 
>> monitor the issue to give them a hint the feature is important to more than 
>> a single individual.
>> 
>
> I'd love it to (that makes at least two individuals...).

Yes, an equivalent for modules of "inherit", which does the job of 
inheriting both the class type and the class implementation... would be 
convenient and easy. Of course, I don't know how it plays with functors, 
etc.


Martin

--
http://martin.jambon.free.fr

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Importing module signatures ?
  2007-10-04 18:42       ` Ashish Agarwal
@ 2007-10-04 21:56         ` Chris King
  0 siblings, 0 replies; 9+ messages in thread
From: Chris King @ 2007-10-04 21:56 UTC (permalink / raw)
  To: Ashish Agarwal; +Cc: OCaml

On 10/4/07, Ashish Agarwal <agarwal1975@gmail.com> wrote:
> ----MyString.ml-----
>  module String = struct
>    include String
>    (* ... my extensions *)
>  end
>  This way I can do "open MyString" and easily switch between my
>  extended module versus the standard library. Is this good style?

This is what's used in ExtLib, and it seems to work well.

- Chris


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-10-04 21:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-04 12:19 Importing module signatures ? David Teller
2007-10-04 12:29 ` [Caml-list] " David Allsopp
2007-10-04 13:02   ` David Teller
2007-10-04 14:09 ` Chris King
2007-10-04 14:16   ` Daniel Bünzli
2007-10-04 14:39     ` Vincent Aravantinos
2007-10-04 18:42       ` Ashish Agarwal
2007-10-04 21:56         ` Chris King
2007-10-04 18:53       ` Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).