Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christophe TROESTLER <debian00@tiscali.be>
To: jfh@cs.brown.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] A second functor question
Date: Sat, 20 Nov 2004 15:19:10 +0100 (CET)	[thread overview]
Message-ID: <20041120.151910.94589743.debian00@tiscali.be> (raw)
In-Reply-To: <20041120041446.JDEC13256.lakermmtao10.cox.net@SPIKESHOMEPC>

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


  parent reply	other threads:[~2004-11-20 20:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-20  4:14 John F. Hughes
2004-11-20  7:45 ` [Caml-list] " Alain Frisch
2004-11-20 14:19 ` Christophe TROESTLER [this message]
2004-11-20 14:48 ` Andreas Rossberg

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=20041120.151910.94589743.debian00@tiscali.be \
    --to=debian00@tiscali.be \
    --cc=caml-list@inria.fr \
    --cc=jfh@cs.brown.edu \
    /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