From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA28704; Mon, 15 Mar 2004 17:20:39 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 RAA28767 for ; Mon, 15 Mar 2004 17:20:38 +0100 (MET) From: ronniec95@lineone.net Received: from mk-smarthost-4.mail.uk.tiscali.com (mk-smarthost-4.mail.uk.tiscali.com [212.74.114.40]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2FGL2KW030178 for ; Mon, 15 Mar 2004 17:21:02 +0100 Received: from mk-cpfront-1.mail.uk.tiscali.com ([212.74.114.3]:43948 helo=mk-cpfrontend.uk.tiscali.com) by mk-smarthost-4.mail.uk.tiscali.com with esmtp (Exim 4.30) id 1B2upS-000B1O-E1; Mon, 15 Mar 2004 16:20:38 +0000 Received: from [141.228.156.225] by mk-cpfrontend.uk.tiscali.com with HTTP; Mon, 15 Mar 2004 16:20:36 +0000 Date: Mon, 15 Mar 2004 16:20:36 +0000 Message-ID: <404398E50002D707@mk-cpfrontend-1.mail.uk.tiscali.com> In-Reply-To: <4055A2C6.9070608@ps.uni-sb.de> Subject: Re: [Caml-list] Module/functor question To: "Andreas Rossberg" Cc: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ronniec:01 lineone:01 caml-list:01 functor:01 2004:99 rossberg:01 rossberg:01 uni-sb:01 ronniec:01 lineone:01 caml-list:01 functor:01 mli:01 'type:99 mli:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 137 Thanks for that. It's all kind of starting to make sense now!! I'll experiment a little more and hopefully should be able to get some bu= yin at work for using Ocaml for our trading applications. Now the messaging is working, along with XML transforms (thanks to all who helped). Just th= e DB to do..... Ronnie >-- Original Message -- >Date: Mon, 15 Mar 2004 13:34:14 +0100 >From: Andreas Rossberg >To: ronniec95@lineone.net >CC: caml-list@inria.fr >Subject: Re: [Caml-list] Module/functor question > > >ronniec95@lineone.net wrote: >> >> I've copied the exact code below since it's not that long. I wonder >> about header.mli which has 'type t=3Du' in it which was the only way o= f >> getting it all to fit together. Why do I have to do that? > >You don't have to, if you declare the types at the right places, i.e. >inside the modules. Actually, you don't need the local modules at all, >since compilation units are already modules. Here is the sketch of a >simplified version (not tested). > > (* header.mli *) > type t > val as_xml : t -> Xml.xml > val create : Xml.xml -> t > val make : ?version:int -> ?msgtypeid:int -> > string -> string -> string -> t > > (* header.ml *) > type t =3D { version : int; > created : Calendar.t; > environment : string; > msgtypeid : int; > msgtype : string; > originatorid : string; > machineid: string; } > let as_xml d =3D ... > let create (root:Xml.xml) : t =3D ... > let make ?(version =3D 1) ?(msgtypeid=3D1) msgtype originator env =3D= ... > > (* main.ml *) > module type CONSTRUCTOR =3D > sig > type t > val as_xml : t -> Xml.xml > val create : Xml.xml -> t > end > > module MessageSender (C : CONSTRUCTOR) =3D > struct > let send msg =3D print_string (Xml.to_string (C.as_xml msg)) > end > > let _ =3D > let module M =3D MessageSender(Header) in > M.send (Header.make "Header" "TestMessage" "DEV") > >-- >Andreas Rossberg, rossberg@ps.uni-sb.de > >Let's get rid of those possible thingies! -- TB > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners