caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ronniec95@lineone.net
To: "Andreas Rossberg" <rossberg@ps.uni-sb.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Module/functor question
Date: Mon, 15 Mar 2004 16:20:36 +0000	[thread overview]
Message-ID: <404398E50002D707@mk-cpfrontend-1.mail.uk.tiscali.com> (raw)
In-Reply-To: <4055A2C6.9070608@ps.uni-sb.de>

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 buyin
at work for using Ocaml for our trading applications. Now the messaging
is working, along with XML transforms (thanks to all who helped). Just the
DB to do.....

Ronnie

>-- Original Message --
>Date: Mon, 15 Mar 2004 13:34:14 +0100
>From: Andreas Rossberg <rossberg@ps.uni-sb.de>
>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=u' in it which was the only way of
>> 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 = { version : int;
>              created : Calendar.t;
>              environment : string;
>              msgtypeid : int;
>              msgtype : string;
>              originatorid : string;
>              machineid: string; }
>   let as_xml d = ...
>   let create (root:Xml.xml) : t = ...
>   let make ?(version = 1) ?(msgtypeid=1) msgtype originator env = ...
>
>   (* main.ml *)
>   module type CONSTRUCTOR =
>   sig
>       type t
>       val as_xml : t -> Xml.xml
>       val create : Xml.xml -> t
>   end
>
>   module MessageSender (C : CONSTRUCTOR) =
>   struct
>       let send msg = print_string (Xml.to_string (C.as_xml msg))
>   end
>
>   let _ =
>       let module M = 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


      reply	other threads:[~2004-03-15 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-14 19:05 ronniec95
2004-03-14 19:22 ` Yamagata Yoriyuki
2004-03-14 23:46   ` ronniec95
2004-03-15 12:34     ` Andreas Rossberg
2004-03-15 16:20       ` ronniec95 [this message]

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=404398E50002D707@mk-cpfrontend-1.mail.uk.tiscali.com \
    --to=ronniec95@lineone.net \
    --cc=caml-list@inria.fr \
    --cc=rossberg@ps.uni-sb.de \
    /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).