Version française
Home     About     Download     Resources     Contact us    
Browse thread
A second functor question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <debian00@t...>
Subject: Re: [Caml-list] A second functor question
On Fri, 19 Nov 2004, "John F. Hughes" <jfh@cs.brown.edu> wrote:
> 
> I'd like to write a signature like this:
> 
> module type P = 
>   sig
>      type t
>      val foo : t -> t
>      val z:int
>   end;;
>
> I now want to apply a functor to those two modules...but a functor
> wants a single module,

Just like functions want a single argument.

> module type COMBINE =

This is unnecessary.

> I'd like a way to promise to the type system that A.t and B.t are
> always the same.

Does this fit your needs:

module F(A : P) (B : P with type t = A.t) =
struct
  let f x = A.foo(B.foo x)
  (* ... *)
end

ChriS