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 q1EAAQP2016027 for ; Tue, 14 Feb 2012 11:10:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As8BAFoyOk9KfVK2kGdsb2JhbABDnyiQfAgiAQEBAQkJDQcUBCOBcgEBAQQSAhMZARsSCwEDDAYFCw0NISIBEQEFAQoSBhMIChCHY5wsCotxgnCFKT+IcwIFC4wGDgsDBgUHBgMDBQcXAwKEKwQDCQiDMQSVMo4lPYQD X-IronPort-AV: E=Sophos;i="4.73,416,1325458800"; d="scan'208";a="144151321" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Feb 2012 11:10:27 +0100 Received: by werm13 with SMTP id m13so6971288wer.27 for ; Tue, 14 Feb 2012 02:10:27 -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=DPfqpbJYVDKOyk/50lSSGqGnI8L72FAFPNT1pnVpVe4=; b=a3OQVfAxqyinzfN8QpspvMx2nkpR68x4APs/hGn4pMEYH4ouO3uIHAmUpcqR+Lv0El UE5TnMO+BdHUpv/mfmiQAl/+pxjr5p0KplAh4Jl9jixs5zVR6buzJHqIcsgDcDxL57R3 W/8nmpCPtouH/BxTtB7PlHc961DnKJq5UFvDA= Received: by 10.180.86.9 with SMTP id l9mr29679103wiz.15.1329214226282; Tue, 14 Feb 2012 02:10:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.61.7 with HTTP; Tue, 14 Feb 2012 02:09:46 -0800 (PST) In-Reply-To: <1329213575.13129.0.camel@andre> References: <4F399DD5.3000507@digirati.com.br> <1329213575.13129.0.camel@andre> From: Gabriel Scherer Date: Tue, 14 Feb 2012 11:09:46 +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 q1EAAQP2016027 Subject: Re: [Caml-list] What am I reinventing here? 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. module type OPS = sig type bar type foo val bar_of_foo : foo -> bar val foo_of_bar : bar -> foo end module Make (O : OPS) = struct let foo = O.bar_of_foo let bar = O.foo_of_bar end module Op1 = struct type foo = A | B type bar = C | D let bar_of_foo = function A -> C | B -> D let foo_of_bar = function C -> A | D -> B end let () = let module M = Make(Op1) in (* you may want to open Op1 locally here *) match M.foo Op1.A with | Op1.C -> () | Op1.D -> () On Tue, Feb 14, 2012 at 10:59 AM, Andre Nathan wrote: > On Tue, 2012-02-14 at 08:03 +0100, Arnaud Spiwack wrote: >> You're probably trying to use functors >> ( http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html#toc15 ). >> Though your example code isn't doing anything in particular. > > Can you give me an example? How can I retain the possibility of > pattern-matching on the types of the resulting module? > > Thanks, > Andre >> > > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >