caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* modules local to functions.
@ 1996-01-08 12:07 Andrew Conway
  1996-01-09  8:04 ` Christian Boos
  1996-01-10 15:27 ` Xavier Leroy
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Conway @ 1996-01-08 12:07 UTC (permalink / raw)
  To: caml-list



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.








^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1996-02-16 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-01-08 12:07 modules local to functions Andrew Conway
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

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).