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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id C55E08239C for ; Fri, 24 Nov 2017 06:27:04 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=ssp.mryau@gmail.com; spf=Pass smtp.mailfrom=ssp.mryau@gmail.com; spf=None smtp.helo=postmaster@mail-qk0-f171.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of ssp.mryau@gmail.com) identity=pra; client-ip=209.85.220.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="ssp.mryau@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of ssp.mryau@gmail.com designates 209.85.220.171 as permitted sender) identity=mailfrom; client-ip=209.85.220.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="ssp.mryau@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qk0-f171.google.com) identity=helo; client-ip=209.85.220.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="postmaster@mail-qk0-f171.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AWgHSBhVN0It8jcC4zUtAIuGcEb/V8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZhSPt8tkgFKBZ4jH8fUM07OQ6P+wHzFYqb+681k8M7V0Hycfjs?= =?us-ascii?q?sXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aMlzFOAF0?= =?us-ascii?q?PuX4HJLJx4Tyjrjqus6bXwIdoju2Zrf7NyKRrwjdv/48DZEqfqAwwRzNq2AOfO?= =?us-ascii?q?ZbyWouL1uJtxLx9sa+/dho9CEG6Nw78MsVaqjgcKlwdr1GDzM4ezQu/9WtsAPS?= =?us-ascii?q?RBan6X4VU2FQmR1NVVuWpCrmV4v853Op/tF23zOXaIivFeg5?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CZAADjrBdah6vcVdFbHAEBAQQBAQoBA?= =?us-ascii?q?YUQJweDeIE2l35EAQEGgTGWfIIBCoU7AoRPB0IVAQEBAQEBAQEBARIBAQEIDQk?= =?us-ascii?q?IKC+COAUBHgEFgj0BAQEBAgEjBBkBGx0BAwELBgMCBAcNKgICIQEBEQEFARwGE?= =?us-ascii?q?4oJAQMIBQiKeJEbQIwQgW0YBQEcgwoFg1gKGScNWIJnAQEBAQEFAQEBAQEbAgY?= =?us-ascii?q?SgyiCB4EOhVuCa4F5g02CYwWKPoc4gROPAD2QE4R5hBKPPI0xiHUUBR+BFjWBc?= =?us-ascii?q?zIaI04ygXeCQx+Bejo2AYkkgVgBAQE?= X-IPAS-Result: =?us-ascii?q?A0CZAADjrBdah6vcVdFbHAEBAQQBAQoBAYUQJweDeIE2l35?= =?us-ascii?q?EAQEGgTGWfIIBCoU7AoRPB0IVAQEBAQEBAQEBARIBAQEIDQkIKC+COAUBHgEFg?= =?us-ascii?q?j0BAQEBAgEjBBkBGx0BAwELBgMCBAcNKgICIQEBEQEFARwGE4oJAQMIBQiKeJE?= =?us-ascii?q?bQIwQgW0YBQEcgwoFg1gKGScNWIJnAQEBAQEFAQEBAQEbAgYSgyiCB4EOhVuCa?= =?us-ascii?q?4F5g02CYwWKPoc4gROPAD2QE4R5hBKPPI0xiHUUBR+BFjWBczIaI04ygXeCQx+?= =?us-ascii?q?Bejo2AYkkgVgBAQE?= X-IronPort-AV: E=Sophos;i="5.44,444,1505772000"; d="scan'208,217";a="302289395" Received: from mail-qk0-f171.google.com ([209.85.220.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 24 Nov 2017 06:27:03 +0100 Received: by mail-qk0-f171.google.com with SMTP id 78so23257789qkz.0 for ; Thu, 23 Nov 2017 21:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=va/VoDQZj5p/vhekmIFVh6y2RdxYABxHIKZGRbIBGaU=; b=Cd4AstWMPTOYgeUkeeIjClhoJVfAiYHDXQsYXOdBHY41GJ0LJn8IUiXdk9T+ld2g98 XBsFv5rj1qmPdCHzZQXGHzKg/XaXdfl4GnGJH+nk278qh79ea7WAZGbyT3pV/5d4GLvo 24Di5nzMsK1pWkR6WUzbM4GzaZZOWsqnNHD1HtDHsBpjx+cGm5OceJ0Wpc6cUEvdeuya oyZubTLFV6HSSzrOLKpVWWSp7opbeK/Fr4Fj01GmoAxqFL8AVifycO5XdEDEg3J0kLFp 3iBYccIZPgjBzbH7IGXOfasnf5jOdbbrCMZaib2HhDVtiiqGOUb4EjWXxnqOXMsNekc+ 231A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=va/VoDQZj5p/vhekmIFVh6y2RdxYABxHIKZGRbIBGaU=; b=KPluwkiuw3rf5p2g8njjUI6/VC9sV+lF/gyBf83+LVQAP1eXo3CkQDnVJmfPLkOyGs AG8vw898F1ClG4RUOIAKHK4IRaGv5LeBcr1MPGYpWjGoO1OO00JnUOtMdyY5DpzGC0Ml ORvzkLtN//Ul8+m0WW5AAdbioCEc0BqDE6sAmngUk/9+HNQW/IsPFw6ZLqXgQ6bHjW7Y 2lKgDiXQIde81gpSDe/kjLCXwO1rp9aa05MKCImp8rJtkfHVAe+sZet+6azCYlQKHp+W PYhmxmnMQsSTE8Gq9aNEukHetOHFE7stymhNIk9RZqvE5KavMucTm+pgvREJtdmxJNya WgFQ== X-Gm-Message-State: AJaThX7e7ixnWPHWktfauVw/nOlt9rNT3iGnAHW5Nwa6mEGD1t0KRxfv smqTiAKU1tAHT0mt9SsSk0t4Sa9y3huryO65ajL1yA== X-Google-Smtp-Source: AGs4zMbEV+/rYyOWLANxte5/2szzcr2H8IFhbTA2bo4jpgpR72cu6TY8sXDo/uOHz23QPGojTdsUwzn7OisGSWOUuR8= X-Received: by 10.55.207.151 with SMTP id v23mr37396381qkl.81.1511501222648; Thu, 23 Nov 2017 21:27:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.40.209 with HTTP; Thu, 23 Nov 2017 21:27:02 -0800 (PST) In-Reply-To: References: From: Serge Sivkov Date: Fri, 24 Nov 2017 10:27:02 +0500 Message-ID: To: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Cc: OCaml Mailing List Content-Type: multipart/alternative; boundary="001a1145b888742632055eb3cd34" Subject: Re: [Caml-list] module and it's types as function parameters --001a1145b888742632055eb3cd34 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Nicol=C3=A1s, thank you very match, it works as I wish :) WBR, ssp 2017-11-23 18:14 GMT+05:00 Nicol=C3=A1s Ojeda B=C3=A4r : > Dear Serge, > > If I understand correctly what you are asking, then you can make it work > by wrapping the definition of topicf in an existential: > > module R =3D struct > type topicf =3D TF : ((module I with type message =3D 'a) -> 'a -> 'a= ) -> > topicf > and topic =3D { func: topicf; name: string } > ... > end > > then, given test, you can create an R.topic by doing > > { R.func =3D TF test; name =3D "test" } > > Best wishes, > Nicol=C3=A1s > > > On Thu, Nov 23, 2017 at 1:52 PM, Serge Sivkov wrote: > >> Hello, >> >> is there way to define module with similar interface: >> >> module R =3D struct >> type topicf =3D (module F : I) -> F.message -> F.message >> and topic =3D { func: topicf; name: string } >> ... >> end >> >> it is possible in case I want to define function with similar signature I >> can declare used types by: >> let test (type message') (module M : I with type message =3D message') (= v: >> message') : message' =3D ... >> >> But how should I create such type in module? >> >> WBR, ssp >> > > --001a1145b888742632055eb3cd34 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Nicol=C3=A1s,

thank you very match, it works as I= wish :)

WBR, ssp

2017-11-23 18:14 GMT+05:00 Nicol=C3=A1s Ojeda B=C3= =A4r <nicolas.ojeda.bar@lexifi.com>:
Dear Serge,

If I = understand correctly what you are asking, then you can make it work by wrap= ping the definition of topicf in an existential:

= =C2=A0 module R =3D struct
=C2=A0 =C2=A0 type topicf =3D TF := ((module I with type message =3D 'a) -> 'a -> 'a) -> = topicf
=C2=A0 =C2=A0 and topic =3D { func: topic= f; name: string }
=C2=A0 =C2=A0 ...
=C2=A0 end

then, given test, you can create an R.topic by = doing

=C2=A0 { R.func =3D TF test; name =3D "= test" }

Best wishes,
Nicol=C3=A1s


On Thu, Nov 23, 2017 at 1:5= 2 PM, Serge Sivkov <ssp.mryau@gmail.com> wrote:
Hello,

is t= here way to define module with similar interface:

module R =3D struc= t
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 type topicf =3D (module F := I) -> F.message -> F.message
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 and topic =3D { func: topicf; name: string }
=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ...
end

it is possible = in case I want to define function with similar signature I can declare used= types by:
let test (type message') (module M : I with type mes= sage =3D message') (v: message') : message' =3D ...

But how should I create such type in module?

WBR, = ssp


--001a1145b888742632055eb3cd34--