Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Andrew Conway <arc@labri.u-bordeaux.fr>
To: caml-list@pauillac.inria.fr
Subject: modules local to functions.
Date: Mon, 08 Jan 1996 13:07:25 +0100	[thread overview]
Message-ID: <9601081207.AA14189@waves.labri.u-bordeaux.fr> (raw)



Resume en tres pauvre Francais: je voudrais utiliser un "functor" au milleau
d'une fonctionne, en utilisant les parametres de la fonctionne dans le "sig".
Je ne peut pas le faire. Pourquoi pas?

---------------------------------

I have a functor such as follows:

  module type Specifyn = sig val n : int end;;

  module Makespecific(N:Specifyn) = struct
	type mytype = int
	let mirror () : mytype = N.n
  end;;

I can apply it at the main level like:

  module Fred = Makespecific(struct let n = 7 end);;

However, there are cases when I want to define a module in the middle
of a function (eg a functor of packed binary arrays where I want to 
determine the number of bits used at run time depending upon the 
arguement of the function). That is, I would like to be abe to do:

  let toto digits =
	module Fred = Makespecific(struct let n = digits end) in
	Fred.mirror ();;

which seems to be reasonably within the spirit and syntax of csl. 
Even if that is not possible, something else like:

   let toto digits =
	let u = Makespecific(struct let n = digits end).mirror () in
	u
   ;;

would also be useful although not an entirely satisfactory solution.

Is this plausible? I seem to remember a discussion something along this
line a while ago, but it may have been for sml.

Thanks for making csl available,

Andrew.








             reply	other threads:[~1996-01-08 18:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-01-08 12:07 Andrew Conway [this message]
1996-01-09  8:04 ` Christian Boos
1996-01-09  9:34   ` Andrew Conway
1996-01-10 15:27 ` Xavier Leroy
1996-01-10 16:22   ` Andrew Conway
1996-01-10 17:08   ` Error message format (was Re: modules local to functions.) Christian Boos
1996-02-16 10:12   ` modules local to functions. (again) Christian Boos

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=9601081207.AA14189@waves.labri.u-bordeaux.fr \
    --to=arc@labri.u-bordeaux.fr \
    --cc=caml-list@pauillac.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