From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q33Cf8Bv020653 for ; Tue, 3 Apr 2012 14:41:08 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYBAL7uek/RVaG2kGdsb2JhbABDpjaRPwgiAQEBAQkJDQcUBCOCCQEBAQQSAiwBGxILAQMMBgULAwoNISIBEQEFAQoSBhMSCQeHZwuhUQqMFoJxhRk/gQ4BBQuQWwSVY4ERjT89hAw X-IronPort-AV: E=Sophos;i="4.75,362,1330902000"; d="scan'208";a="138869197" Received: from mail-gx0-f182.google.com ([209.85.161.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 Apr 2012 14:41:02 +0200 Received: by ggnk4 with SMTP id k4so2529007ggn.27 for ; Tue, 03 Apr 2012 05:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=NDyQcxA+IvAG9uBxAXRESlZjsYBZmJ3ZSL24aVZ2h2w=; b=G1aTaQSx0OMWkeAgIcI6LgQB6HtIjQKSktcZDTLWh3GiS7ucNKwI3/Fl1RV3zji/Sx XGE+zlCxdE2Jnp9z0KntxKmdVmBwhXahXBZ9c473A9B+nNaMZ0DcwllHh2O2JKDRySZx 2T4N8w6Wd5szQ1m6Uu9A0uOF1j1IG9wHgMcoxV/RYUhEDJWtMCwhoNpB9QgVtNLXQWvg KnmekCzp6s/gIEpcoc6fxX+bMwAouUw1vf4gL4bATK3YdilfTmXdEan/lnHPChYV0ZCK VqJ8pwfEgs0Tb3UCXg1N6MSisg+KONZXPih3ouBrbj4rQrTFBLUE8+wbqqPRqZeoeQKQ 0Jlg== Received: by 10.50.219.199 with SMTP id pq7mr8560122igc.70.1333456861263; Tue, 03 Apr 2012 05:41:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.140.100 with HTTP; Tue, 3 Apr 2012 05:40:21 -0700 (PDT) In-Reply-To: <4F7ADDAF.2030201@wp.pl> References: <4F7ADDAF.2030201@wp.pl> From: Gabriel Scherer Date: Tue, 3 Apr 2012 14:40:21 +0200 Message-ID: To: Dawid Toton Cc: Caml 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 q33Cf8Bv020653 Subject: Re: [Caml-list] When functor yields many types - include a module with extra type equality? I learned a clever hack from Jacques Garrigue: recursive modules allow you to get a module corresponding to a module type. The "module of S" is module rec X : S = X Using this trick, one can write in c_sig.ml module type S = sig ... end the usual thing in .mli, and then module Make (B : B) = struct module rec S_mod : (Sig.S with type t = B.t) = S_mod include S_mod let not_much_code = assert false end On Tue, Apr 3, 2012 at 1:23 PM, Dawid Toton wrote: > Consider the following: > > --- a.mli > module type B = sig >  type t > end > > module type S = sig >  type t >  type other_lenghty_definitions >  val not_much_code : t > end > > module Make (B : B) : S >  with type t = B.t > --- > --- a.ml > module type B = sig >  type t > end > > module type S = sig >  type t >  type other_lenghty_definitions >  val not_much_code : t > end > > module Make (B : B) = struct >  type t = B.t >  type other_lenghty_definitions >  let not_much_code = assert false > end > --- > > So we have to keep 3 copies of other_lenghty_definitions. I can have it > isolated in a separate file and insert into a.ml and a.mli in an extra > preprocessing step. But I believe there should be some clean solution, > something like the following: > > --- c_sig.ml > module S = struct >  type t >  type other_lenghty_definitions > end > > module type S = sig >  include (module type of S) (* 1 *) >  val not_much_code : t > end > --- > --- c.mli > module type B = sig >  type t > end > > module Make (B : B) : C_sig.S >  with type t = B.t > --- > --- c.ml > module type B = sig >  type t > end > > module Make (B : B) = struct >  include C_sig.S >    with type t = B.t (* 2 *) > >  let not_much_code = assert false > end > --- > > How to do what I mark with (* 1 *) and (* 2 *) correctly? Would it help if I > upgrade my toolchain from 3.11.2 to some more recent version? > Dawid > > -- > 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 >