From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 83C377EE51 for ; Sat, 4 May 2013 14:40:00 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.51 as permitted sender) identity=mailfrom; client-ip=209.85.214.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-bk0-f51.google.com) identity=helo; client-ip=209.85.214.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-bk0-f51.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkICACwBhVHRVdYzk2dsb2JhbABQgz6tKJIbdAgWDgEBAQEHCwsJFAQkgh8BAQUnGQEbEgsBAwwGBQsNDSEiAREBBQEKEgYTEodnAQMPDKR2jDuCfoQlChknAwpYhyoBBQyOcjMHg1MDlyyBJo4nFimENTo X-IPAS-Result: AkICACwBhVHRVdYzk2dsb2JhbABQgz6tKJIbdAgWDgEBAQEHCwsJFAQkgh8BAQUnGQEbEgsBAwwGBQsNDSEiAREBBQEKEgYTEodnAQMPDKR2jDuCfoQlChknAwpYhyoBBQyOcjMHg1MDlyyBJo4nFimENTo X-IronPort-AV: E=Sophos;i="4.87,611,1363129200"; d="scan'208";a="13194057" Received: from mail-bk0-f51.google.com ([209.85.214.51]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 May 2013 14:39:59 +0200 Received: by mail-bk0-f51.google.com with SMTP id ji2so1062364bkc.10 for ; Sat, 04 May 2013 05:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=joj1TurPmP417nujxciHykRQ/BpUXWqKbP8vScSK/M8=; b=r3jo8laLbTsN0pzhwc8cb5oVkihHv8DbaZEsOyNTXGziN2kXd48tveRQhucPun7u2Q Fw9e2frUeDGcGujlKhAomjZ3N/B1RnyIpkCkpjABAiL/3/TZf+E+2KWbfE19a9ZJDuqD w4dYfHqs+wW1KjM7i9zdWpbzc73z2bukn78c2aUeb1HHAbkGHGvTAWZ5vqEQ2UFmIdDy d2+0RSfhbg+d89wRJVxNc4flp0iLSOnzN4oRb6zZ9sgLhsCk9v16857/wb48phDXJYnT OqoLilFFBsi+3rP+mDEl5uES/pMwJsXjeD1BfgWvMYr4P+72YvABb+/bVzDYoLWTQcmk 5WCA== X-Received: by 10.204.61.71 with SMTP id s7mr5175887bkh.74.1367671199235; Sat, 04 May 2013 05:39:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.205.83.144 with HTTP; Sat, 4 May 2013 05:39:19 -0700 (PDT) In-Reply-To: <5184FDB0.30406@inria.fr> References: <5184FDB0.30406@inria.fr> From: Gabriel Scherer Date: Sat, 4 May 2013 14:39:19 +0200 Message-ID: To: =?ISO-8859-1?Q?Micha=EBl_Lienhardt?= Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] recursive module type I did not need such form of self-reference to build converter from a set to another. (* binary converter functor *) module SetConverter (S1 : Set.S) (S2 : Set.S) : sig val convert : (S1.elt -> S2.elt) -> (S1.t -> S2.t) end =3D struct let convert f s1 =3D S1.fold (fun e s2 -> S2.add (f e) s2) s1 S2.empty end (* currified version as a Set.S overlay *) module SetWithConverter (E : Set.OrderedType) : sig include Set.S module Converter (S2 : Set.S) : sig val convert : (elt -> S2.elt) -> (t -> S2.t) end end =3D struct module S1 =3D Set.Make(E) include S1 module Converter (S2:Set.S) =3D SetConverter(S1)(S2) end On Sat, May 4, 2013 at 2:23 PM, Micha=EBl Lienhardt wrote: > Hello, > > I would like to define some recursive module type in caml, like > module type S =3D sig > ... > module Toto(M : S) : sig > ... > end > end > > More precisely, I'd like to extend the Set module available in the ocaml > distribution with a function that convert a set into another set. > Intuitively, I came up with the following signature S, which is not accep= ted > by ocaml (Error: Unbound module type S): > > module type S =3D sig > > include Set.S > > module Convert : functor(SetTarget : S) -> sig > val convert : (elt -> SetTarget.elt) -> t -> SetTarget.t > end > end > > Is there a way to define such a module type in ocaml, and if not, is ther= e a > theoretical reason for this not being possible? > > Thanks, > Michael Lienhardt > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs