From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 78F8DBC37 for ; Tue, 26 May 2009 15:35:09 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtACAB+NG0qLEwExe2dsb2JhbACCIy+VHAEBFiIFpmmPQgSECw X-IronPort-AV: E=Sophos;i="4.41,251,1241388000"; d="scan'208,217";a="28333766" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 26 May 2009 15:35:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Cc:Message-Id:From:To: In-Reply-To:Content-Type:Subject:Mime-Version:Date:References; bh=s79ReAWw/Ki8gh2xPjmTCxjvYn8951iy+NXf+hV+9RM=; b=XrsaWzGZzt/p6 XLUZFge8dgRnPGZH0LWK52pwXYWvKpyqdKUaZihQpKe2qOCYhBCDbEcfylJRdQxu JYdWCVn4Q6ovdnUB2TNwjaai1o1S/cHnrP4SyuY14R/vhNFSvWU674XE904fuXQH 8FS7HizetnsGPPxkgciBEcKrmTBjZ8= Received: from infao0710.mpi-sb.mpg.de ([139.19.1.28]:57811 helo=newzak.mpi-sb.mpg.de) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1M8wo5-0004Ck-4U; Tue, 26 May 2009 15:35:08 +0200 Received: from srbk-4db7f47c.pool.einsundeins.de ([77.183.244.124]:57810 helo=[192.168.178.20]) by newzak.mpi-sb.mpg.de with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.63) (envelope-from ) id 1M8wo4-0003Hq-Ec; Tue, 26 May 2009 15:35:04 +0200 Cc: Pietro Abate , caml list Message-Id: From: Andreas Rossberg To: Julien Signoles In-Reply-To: <4A1BE27E.8030908@cea.fr> Content-Type: multipart/alternative; boundary=Apple-Mail-1-897214859 Subject: Re: [Caml-list] small typing problem with modules ... Mime-Version: 1.0 (Apple Message framework v935.3) Date: Tue, 26 May 2009 15:35:03 +0200 References: <20090526093727.GA28741@uranium.pps.jussieu.fr> <4A1BE27E.8030908@cea.fr> X-Mailer: Apple Mail (2.935.3) X-Spam: no; 0.00; rossberg:01 rossberg:01 signoles:01 functor:01 mli:01 mli:01 sig:01 functor:01 parametrized:01 sig:01 val:01 parametrize:01 val:01 struct:01 struct:01 --Apple-Mail-1-897214859 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On May 26, 2009, at 14.37 h, Julien Signoles wrote: > >> My problem here is that I'd like to have a module type T for the >> functor >> Make in b.ml and to avoid the signature duplication in b.mli ... >> ideally >> I'd like to write in b.mli something like : >> module type T = sig ???? end >> module Make : functor (Extra : A.Extra) -> functor (A : A.T with >> type extra = Extra.t) -> T with ... >> include T with ... >> It's clear that I cannot write a module type as follows because the >> the "open A" will consider the default type of A and not it's >> parametrized version ... >> module type T = sig >> open A >> val f : extra -> unit >> end >> how can I parametrize this signature ? I can write something like : >> module type T = functor (A : A.T) -> sig >> open A >> val f : extra -> unit end ;; >> but then I'm a bit lost putting all this together ... I know I'm >> close ... a small hint ? > > Hum, module types cannot be parameterized. Actually, they can. You just have to put them into a functor. For example: # module TF (A : sig type t end) = struct module type T = sig open A val x : t end end;; module TF : functor (A : sig type t end) -> sig module type T = sig val x : A.t end end # module I = struct type t = int end;; module I : sig type t = int end # module M : TF(I).T = struct let x = 9 end;; module M : TF(I).T - Andreas --Apple-Mail-1-897214859 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable
On May 26, 2009, at = 14.37 h, Julien Signoles wrote:

My problem here is that I'd like to have a module type T = for the functor
Make in b.ml = and to avoid the signature duplication in b.mli ... = ideally
I'd like to write in = b.mli something like :
module = type T =3D sig ???? end
module = Make : functor (Extra : A.Extra) -> functor (A : A.T with type extra =  =3D Extra.t) -> T with ...
include T with ...
It's clear that I cannot write a module type as follows = because the the "open A" will consider the default type of A and not = it's
parametrized version = ...
module type T =3D = sig
 open = A
 val f : extra -> = unit
end
how can I = parametrize this signature ? I can write something like = :
module type T =3D functor (A = : A.T) ->   sig
=    open A
=    val f : extra -> unit end = ;;
but then I'm a bit lost = putting all this together ... I know I'm close ... a small hint = ?

Hum, module types cannot be = parameterized.

Actually, they can. = You just have to put them into a functor. For = example:

# module TF (A : sig type t end) = =3D
  struct
    module = type T =3D sig open A val x : t = end
  end;;
module TF = :
  functor (A : sig type t end) -> sig module = type T =3D sig val x : A.t end end
# module I =3D struct type = t =3D int end;;
module I : sig type t =3D int end
# = module M : TF(I).T =3D struct let x =3D 9 end;;
module M : = TF(I).T

- = Andreas

= --Apple-Mail-1-897214859--