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 UAA27071 for caml-redistribution; Tue, 19 Nov 1996 20:18:52 +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 RAA24012 for ; Tue, 19 Nov 1996 17:36:22 +0100 (MET) Received: from cherub.hd.ibm.de (cherub.hd.ibm.de [192.101.197.10]) by nez-perce.inria.fr (8.7.6/8.7.1) with SMTP id RAA23875 for ; Tue, 19 Nov 1996 17:36:15 +0100 (MET) Received: from kaa.heidelbg.ibm.com by cherub.hd.ibm.de (AIX 3.2/UCB 5.64/4.03/chkV1.0) id AA18380; Tue, 19 Nov 1996 17:35:13 +0100 Received: from idse.heidelbg.ibm.com by kaa.heidelbg.ibm.com (AIX 3.2/UCB 5.64/4.03) id AA50155; Tue, 19 Nov 1996 17:35:41 +0100 Received: by idse.heidelbg.ibm.com (AIX 3.2/UCB 5.64/4.03) id AA60112; Tue, 19 Nov 1996 17:35:38 +0100 Message-Id: <9611191635.AA60112@idse.heidelbg.ibm.com> To: Emmanuel Engel Cc: caml-list@inria.fr Subject: Re: Some cosmetics problems with ocaml In-Reply-To: (Your message of Mon, 18 Nov 96 16:23:50 N.) <32907F85.15BC@lri.fr> Date: Tue, 19 Nov 96 17:35:38 +0100 From: Wolfgang Lux Sender: weis Emanuel Engel wrote: > I have some cosmetics problems with ocaml. > > [much stuff deleted] > > Let's take an example. I'd like to write: > > ************* foo.ml ******************** > type foo = N > | C of int * froz ref > > and froz = V of foo > | T of (unit -> foo) > > > let rec eval_all = function > C(_,{contents=V x}) -> > eval_all x; > | C(_,({contents=T f} as t)) -> > let v= f () in > t.contents <- (V v); > v; > | _ -> > () > > module FooSet= > struct > type t = int list > let rec eval_all = function > | [] -> > () > | hd::tl -> > (Foo.eval_all hd); > (Foo.FooSet.eval_all tl) > end > ******************************************************* You might use a functor in this case: module MakeFooSet(Foo : sig val eval_all : foo -> foo end) = struct type t = int list let rec eval_all = function [] -> () | hd::tl -> Foo.eval_all hd; eval_all tl end;; module FooSet = MakeFooSet(struct let eval_all = eval_all end) Hope this helps, Wolfgang ---- Wolfgang Lux WZH Heidelberg, IBM Germany Internet: lux@heidelbg.ibm.com +49-6221-59-4546 VNET: LUX at HEIDELBG +49-6221-59-3500 (fax) EARN: LUX at DHDIBMIP