caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@best.com>
To: caml-list@inria.fr
Subject: RE: first class, recursive, mixin modules (was: RE: first class m  odules)
Date: Sun, 14 Jan 2001 12:51:21 -0800 (PST)	[thread overview]
Message-ID: <Pine.BSF.4.21.0101141249270.2654-100000@shell5.ba.best.com> (raw)

On Fri, 12 Jan 2001, Claudio Russo wrote:
> I wasn't quite sure of your intention, but I did get the attached code
> to work in Mosml (it includes a port of the Ocaml libraries and a
> fleshed out implementation of your idea).

Cool! OK, now Alain has at least one example of a practically useful case
handled by your scheme :-). I suspect that this problem bites lots of ML 
programmers, and a fix is eagerly desired by at least two OCaml
programmers. Congratulations on making this work, the millenium is
starting off on a great note already!

> Unfortunately, this only works in an internal release of Moscow, because
> of a (known) bug in the current distribution. 

Well, even more unfortunately, a fix in Mosml doesn't help me unless you
change to Mosocaml. I couldn't switch to SML even if I wanted to, and I 
don't want to! Hopefully the OCaml Implementors (you guys are even
capitalized now) will "borrow back" the Mosml improvements into OCaml. 

> For the record, your functor application Make(Ord)is fine because it is
> applied to a local, already defined structure.
[...snip...]
> An application like Make(T.Ord), through the forward reference, would
> raise the Bind exception, because T (and T.Ord) is 
> undefined at that point (although Ord is).

That's no problem for me. Dave, in the case you mentioned, do you think
this would this be problematic? I couldn't guess from your description.

-- Brian 

> > -----Original Message-----
> > From: Brian Rogoff [mailto:bpr@best.com]
> > Sent: 11 January 2001 20:01
> > To: Dave Berry
> > Cc: Claudio Russo; Alain Frisch; Caml list
> > Subject: RE: first class, recursive, mixin modules (was: RE: 
> > first class
> > m odules)
> > 
> > 
> > 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



             reply	other threads:[~2001-01-14 20:53 UTC|newest]

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

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.0101141249270.2654-100000@shell5.ba.best.com \
    --to=bpr@best.com \
    --cc=caml-list@inria.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).