From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA13601 for caml-red; Sun, 14 Jan 2001 21:53:45 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA14377 for ; Sun, 14 Jan 2001 21:51:22 +0100 (MET) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f0EKpLr06728 for ; Sun, 14 Jan 2001 21:51:21 +0100 (MET) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id MAA24755 for ; Sun, 14 Jan 2001 12:51:21 -0800 (PST) Date: Sun, 14 Jan 2001 12:51:21 -0800 (PST) From: Brian Rogoff To: caml-list@inria.fr Subject: RE: first class, recursive, mixin modules (was: RE: first class m odules) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis@pauillac.inria.fr 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