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 CEC778239C for ; Thu, 23 Nov 2017 14:14:50 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=SoftFail smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@vrout30.yaziba.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=185.56.204.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: SoftFail (mail2-smtp-roc.national.inria.fr: domain of nicolas.ojeda.bar@lexifi.com is inclined to not designate 185.56.204.33 as permitted sender) identity=mailfrom; client-ip=185.56.204.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.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@vrout30.yaziba.net) identity=helo; client-ip=185.56.204.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@vrout30.yaziba.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AlSazOxYj+KjPKEimgIwbQdP/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZpcyybnLW6fgltlLVR4KTs6sC0LWG9f24EUU7or+/81k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i76xXcoFx7+LQt4?= =?us-ascii?q?IPjuUs6X1pzvlrP6x5qGWAhSizf1WrJsLxKo5VHKrdFQhJFzI7sZxR7Ao38OcO?= =?us-ascii?q?NTkzBGP1WWyjD97cC0dYVU1CZdt/sW3UJaGfH8fq8/SbVDSjMkPmw8osfirzHH?= =?us-ascii?q?QBuO6HpaWWITxEkbSzPZ5Q33C8+i+hDxsfBwjWzDZZX7?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DPAQCnyBZahyHMOLlcHAEBAQQBAQoBA?= =?us-ascii?q?YUQJweDeIE2l3+BfRSIT44JEIIBCoU7AoROB0AXAQEBAQEBAQEBARIBAQEKCwk?= =?us-ascii?q?IKC+COAUBHgEFgj4BAgIBIwRSBQsJAgQHAzQCAiEBEgEFARwGEwiKAgMNCAQBi?= =?us-ascii?q?nqRG0CMEIFtOoc0DYM/AQEIAQEBASSDOoIHhmmCa4F5g02CYwWKPoc4kBM9kBO?= =?us-ascii?q?EeYQSjzyNMYh1FAUfgRQCIAGCB29OMgaBcYJigXR2ig+BWAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0DPAQCnyBZahyHMOLlcHAEBAQQBAQoBAYUQJweDeIE2l3+?= =?us-ascii?q?BfRSIT44JEIIBCoU7AoROB0AXAQEBAQEBAQEBARIBAQEKCwkIKC+COAUBHgEFg?= =?us-ascii?q?j4BAgIBIwRSBQsJAgQHAzQCAiEBEgEFARwGEwiKAgMNCAQBinqRG0CMEIFtOoc?= =?us-ascii?q?0DYM/AQEIAQEBASSDOoIHhmmCa4F5g02CYwWKPoc4kBM9kBOEeYQSjzyNMYh1F?= =?us-ascii?q?AUfgRQCIAGCB29OMgaBcYJigXR2ig+BWAEBAQ?= X-IronPort-AV: E=Sophos;i="5.44,441,1505772000"; d="scan'208,217";a="302198619" Received: from vrout30.yaziba.net ([185.56.204.33]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 23 Nov 2017 14:14:48 +0100 Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 52970521FA for ; Thu, 23 Nov 2017 14:14:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 54338160542 for ; Thu, 23 Nov 2017 14:14:46 +0100 (CET) X-Virus-Scanned: amavisd-new at mtaout20.int.yaziba.net Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qP0ltVmHozQ9 for ; Thu, 23 Nov 2017 14:14:46 +0100 (CET) Received: from mail-qt0-f173.google.com (mail-qt0-f173.google.com [209.85.216.173]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 11B241601ED for ; Thu, 23 Nov 2017 14:14:46 +0100 (CET) Received: by mail-qt0-f173.google.com with SMTP id u42so27813608qte.7 for ; Thu, 23 Nov 2017 05:14:46 -0800 (PST) X-Gm-Message-State: AJaThX6hJ4FjNY6YBmZuYsrNX/bZ+Ljht1SCV+C4X4kx7uQZJD7uxazW yRtmDijRTWIGNofcuCeRWDzQUez/0K+ImWPT99w= X-Google-Smtp-Source: AGs4zMYA4MYCRU/l9H1zai+OVoEyNzFqSbGXxTZGwYscUaaq7MihHYSY5K0aOWO8MBVBLNpko/VQkYki9poY6Me8Jsc= X-Received: by 10.237.35.37 with SMTP id h34mr39538746qtc.9.1511442885043; Thu, 23 Nov 2017 05:14:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.24.163 with HTTP; Thu, 23 Nov 2017 05:14:24 -0800 (PST) In-Reply-To: References: From: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Date: Thu, 23 Nov 2017 14:14:24 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Serge Sivkov Cc: OCaml Mailing List Content-Type: multipart/alternative; boundary="001a113e431842e997055ea638c0" X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrledtgdefudcutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepjghfhfffkffuvfgtsegrtderredttdejnecuhfhrohhmpefpihgtohhljohspgfqjhgvuggrpgeumohruceonhhitgholhgrshdrohhjvggurgdrsggrrheslhgvgihifhhirdgtohhmqeenucfkphepvddtledrkeehrddvudeirddujeefnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] module and it's types as function parameters --001a113e431842e997055ea638c0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 > --001a113e431842e997055ea638c0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Serge,

If I understand correctly w= hat you are asking, then you can make it work by wrapping the definition of= topicf in an existential:

=C2=A0 module R =3D str= uct
=C2=A0 =C2=A0 type topicf =3D TF : ((module I with type m= essage =3D 'a) -> 'a -> 'a) -> topicf
=C2=A0= =C2=A0 and topic =3D { func: topicf; 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 wis= hes,
Nicol=C3=A1s


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

is there way t= o define module with similar interface:

module R =3D struct
=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 a= nd 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 message =3D = message') (v: message') : message' =3D ...

Bu= t how should I create such type in module?

WBR, ssp

--001a113e431842e997055ea638c0--