Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wolfgang Lux <lux@heidelbg.ibm.com>
To: Emmanuel Engel <Emmanuel.Engel@lri.fr>
Cc: caml-list@inria.fr
Subject: Re: Some cosmetics problems with ocaml
Date: Tue, 19 Nov 96 17:35:38 +0100	[thread overview]
Message-ID: <9611191635.AA60112@idse.heidelbg.ibm.com> (raw)
In-Reply-To: (Your message of Mon, 18 Nov 96 16:23:50 N.) <32907F85.15BC@lri.fr>

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





      reply	other threads:[~1996-11-19 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-18 15:23 Emmanuel Engel
1996-11-19 16:35 ` Wolfgang Lux [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=9611191635.AA60112@idse.heidelbg.ibm.com \
    --to=lux@heidelbg.ibm.com \
    --cc=Emmanuel.Engel@lri.fr \
    --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