From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q1EAeQVn017846 for ; Tue, 14 Feb 2012 11:40:26 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkBAF05Ok9KfVI0imdsb2JhbABDsBQIIgEBAQoJDQcSBiOBcgEBAQQSAhMZARsdAQMMBgULDS4iAREBBQEcBhMipCQKi3GCcIUkP4hzAgULjBULAwYFBwYDAwUHFwMChC8Dg0IElTKOJT2EAw X-IronPort-AV: E=Sophos;i="4.73,416,1325458800"; d="scan'208";a="144157116" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Feb 2012 11:40:22 +0100 Received: by wgbds10 with SMTP id ds10so6374861wgb.9 for ; Tue, 14 Feb 2012 02:40:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=xgEpRQsD+0b0hBwFJfSPVJDE8w8TUVIZO2gNZzeNdVM=; b=lEZwbu/wZPaniZmeYPjM7+pl/KiiUgcXyVrLJCivFTxrZy9maH1+U2bPBk+FC4Ogih Dhf7eEha9Z7j11pLXsY2LDWjgQ19dZLLvVOLn++6DBpdx+jI1jEAr0OaY07fUiRTY2NM ny5QG7GvqIinQcZPC13fpE+iHfZMJ+wRRnkUU= Received: by 10.180.85.105 with SMTP id g9mr2686854wiz.12.1329216022227; Tue, 14 Feb 2012 02:40:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.61.7 with HTTP; Tue, 14 Feb 2012 02:39:42 -0800 (PST) In-Reply-To: <1329215040.13129.3.camel@andre> References: <4F399DD5.3000507@digirati.com.br> <1329213575.13129.0.camel@andre> <1329215040.13129.3.camel@andre> From: Gabriel Scherer Date: Tue, 14 Feb 2012 11:39:42 +0100 Message-ID: To: Andre Nathan Cc: Arnaud Spiwack , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q1EAeQVn017846 Subject: Re: [Caml-list] What am I reinventing here? Yes it is, but you have to use judicious "with .." annotations to make the type non-abstract. Silly example that captures the problem I think you're thinking of: module type S = sig type t val v : t end type foo = A | B module M = struct type t = foo let v = A end let () = match M.v with A -> () | B -> () (* works *) module M2 = (M : S) let () = match M2.v with A -> () | B -> () (* Error: This pattern matches values of type foo but a pattern was expected which matches values of type M2.t *) module M3 = (M : S with type t = foo) let () = match M3.v with A -> () | B -> () (* works *) In your case, you should write (module Make(O : Ops) : S with type foo = ... and bar = ...). On Tue, Feb 14, 2012 at 11:24 AM, Andre Nathan wrote: > On Tue, 2012-02-14 at 11:09 +0100, Gabriel Scherer wrote: >> Here is an attempt at a functor translation. Note that's it's mostly a >> glorified way to do exactly the same thing. Passing a module or a >> record of operation is not very different; yet a module can carry >> types so you don't have to parametrize your operations explicitly. > > Thank you Gabriel. > >> module Make (O : OPS) = struct >>   let foo = O.bar_of_foo >>   let bar = O.foo_of_bar >> end > > Would it be correct to say that it isn't possible to specify a signature > S for the output module like > > module Make (O : OPS) : S = struct >  ... > end > > that would still make pattern-matching outside of the module possible? > > Thanks, > Andre >