Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Multiparameter functors?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-12-22 (23:44)
From: Julien Demouth <julien.demouth@f...>
Subject: Re: [Caml-list] Multiparameter functors?

Brian Hurt wrote:
> Is it possible to do multi-parameter functors?  What I want to be able to 
> so is something like:
> module Make(Key: Map.OrderedType, Pri: Map.OrderedType) = struct
> 	type key = Key.t;;
> 	type pri = Pri.t;;
> 	...
> end;;

Of course it's possible but you mustn't use the comma. A functor is just 
a function. The only difference is that it deals with structure whereas 
"normal" functions deal with values. Consider the following example:

module type M = sig type t end

module type N = sig type t end

module type R = sig type u and v end

module Make (U:M) (V:N) : R with type u = U.t and type v = V.t

> Am I being stupid and just missing something obvious, or is there some 
> subtle reason why I shouldn't be doing this?

Every question is good to be asked ;)



To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: