caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@best.com>
To: Dave Berry <dave@kal.com>
Cc: Claudio Russo <crusso@microsoft.com>,
	Alain Frisch <frisch@clipper.ens.fr>,
	Caml list <caml-list@inria.fr>
Subject: RE: first class, recursive, mixin modules (was: RE: first class m odules)
Date: Thu, 11 Jan 2001 12:01:26 -0800 (PST)	[thread overview]
Message-ID: <Pine.BSF.4.21.0101111143270.27116-100000@shell5.ba.best.com> (raw)
In-Reply-To: <3145774E67D8D111BE6E00C0DF418B663AD79C@nt.kal.com>

My "litmus test" for recursive modules is that it fixes the well known
problem with expressing what OO folk call the Composite pattern,
essentially a recursively defined collection type with a leaf/node
relationship. Here is an approxmation of what I want to do in "faux-Mosml
with OCaml libraries". Forgive my errors, I don't use SML. The idea
should be clear. 

signature COMPOSITE = 
    rec(X : sig structure CompositeSet : sig type t end end) 
    sig structure Composite : 
                  sig 
                    datatype t = 
                      { data : int ; children : X.CompositeSet.t }
                  end
        structure CompositeSet : (Set.S where type elt = Composite.t) 
    end;

structure T = rec(X : COMPOSITE) 
  struct 
	structure Composite = 
          struct 
            datatype t = { data : int ; children : X.CompositeSet.t }
          end
        structure Ord : Set.OrderedType = 
          struct 
            type t = Composite.t 
            let compare = Pervasives.compare
          end
	structure CompositeSet = Set.Make(Ord)  
    end

This is syntactically heavy, but better than the parameterization trick 
needed now, and I'd be satisfied. I do need to do that functor
instantiation, so if you can't do it in Mosml it needs to be added. 

I agree that the first-class module extension is useful on its own too,
but in my own programming the problem I mention above arises frequently
enough that I consider this a flaw of (current) ML style modules. Every 
language has flaws but since OCaml is so close to perfection every flaw 
seems large ;-). 

-- Brian

 On Thu, 11 Jan 2001, Dave Berry wrote:

> We ran into an example (in SML) during the development of MLWorks.  I can
> only remember it vaguely, but there were two large module hierarchies.
> These hierarchies were in logically different parts of the system.  A new
> development built on top of these hierarchies meant that we needed to make
> one element from the bottom of each hierarchy be mutually recursive with
> each other.  I suspect that since we were using a fully functorised style,
> what we wanted to do was to make two functors mutually recursive.  In
> practice we had to combine the module hierarchies to make the types and
> values mutually recursive at the bottom of the new hierarchy.
> 
> I wish I could remember what the example was, because it was a clear case
> where the ML module system was too inflexible to meet the pragmatic needs.
> Imagine how we would have been stuck if the two module hierarchies were
> libraries from different suppliers, especially if they were only distributed
> in compiled form.
> 
> Dave. 
>   
> 
> -----Original Message-----
> From: Claudio Russo [mailto:crusso@microsoft.com]
> Sent: Thursday, January 11, 2001 10:33
> To: Alain Frisch
> Cc: Brian Rogoff; Caml list
> Subject: RE: first class, recursive, mixin modules (was: RE: first class
> modules)
> 
> 
> 



  reply	other threads:[~2001-01-12  9:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-11 18:15 Dave Berry
2001-01-11 20:01 ` Brian Rogoff [this message]
2001-01-12 12:12 Claudio Russo
2001-01-14 20:51 Brian Rogoff
2001-01-15 14:13 Dave Berry
2001-02-09  9:41 Claudio Russo
2001-02-09 16:47 ` Brian Rogoff
2001-02-09 21:45 ` William Chesters

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=Pine.BSF.4.21.0101111143270.27116-100000@shell5.ba.best.com \
    --to=bpr@best.com \
    --cc=caml-list@inria.fr \
    --cc=crusso@microsoft.com \
    --cc=dave@kal.com \
    --cc=frisch@clipper.ens.fr \
    /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;
as well as URLs for NNTP newsgroup(s).