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 907C37F75C for ; Sun, 24 Aug 2014 18:24:23 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.152; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.152; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-52.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.152; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-52.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmgGAPYQ+lODbwiYf2dsb2JhbABZg2BXgnysIQadHYdRAYEIFhABAQsLCggUKYQEAQMBASMEUgULCxoCBSECAg8BBEkuiB8IBAmtGI9phEsXgSyEUIkdMweCeYFTBZxJmGtrAYJOAQEB X-IPAS-Result: AmgGAPYQ+lODbwiYf2dsb2JhbABZg2BXgnysIQadHYdRAYEIFhABAQsLCggUKYQEAQMBASMEUgULCxoCBSECAg8BBEkuiB8IBAmtGI9phEsXgSyEUIkdMweCeYFTBZxJmGtrAYJOAQEB X-IronPort-AV: E=Sophos;i="5.04,391,1406584800"; d="scan'208";a="91117831" Received: from ppsw-52.csi.cam.ac.uk ([131.111.8.152]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Aug 2014 18:24:23 +0200 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from host86-144-7-20.range86-144.btcentralplus.com ([86.144.7.20]:47700 helo=study.localdomain) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:AES128-GCM-SHA256:128) id 1XLaac-0002Ev-D6 (Exim 4.82_3-c0e5623) (return-path ); Sun, 24 Aug 2014 17:24:22 +0100 From: Leo White To: Dario Teixeira Cc: OCaml mailing-list References: <1408559896.43780.YahooMailNeo@web121705.mail.ne1.yahoo.com> X-Face: "XWxb[u_Z\PA_Y?9@|IA!!+jTb(/290-*ea/Un$I0B98.$n%eL.;2w*,z]WR#T:,p[ NBd++M7l]#7zj7!{~iw $W-"/=|dVjhT[D{4~gE}gK<2`.6fs!;uqqud]vs2N/3^m7{aS1V, Date: Sun, 24 Aug 2014 17:39:10 +0100 In-Reply-To: <1408559896.43780.YahooMailNeo@web121705.mail.ne1.yahoo.com> (Dario Teixeira's message of "Wed, 20 Aug 2014 11:38:16 -0700") Message-ID: <8738cl6dw1.fsf@study.localdomain> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Locally abstract type with type parameters Hi Dario, > To avoid type-escaping-its-scope errors, we need to define a locally abst= ract > type in the implementation of 'actually_process'.=C2=A0 Something like th= is: > > let actually_process (type u) (module Logger: LOGGER with type 'a Monad= .t =3D 'a u) x =3D > let open Logger in > let (>>=3D) t f =3D Monad.bind t f in > Logger.log () >>=3D fun () -> > Monad.return x > This function relies on higher-kinded polymorphism (i.e. it is polymorphic in type `u` which has type parameters). Since OCaml's core language does not provide direct support for higher-kinded polymorphism the usual solution is to make `actually_process` into a functor. A possible alternative solution, which may suit your use case, is outlined in the paper "Lightweight higher-kinded polymorphism" [1] using the "higher" library available on OPAM. Regards, Leo [1] Lightweight higher-kinded polymorphism Jeremy Yallop and Leo White =E2=80=82 FLOPS 2014 http://www.lpw25.net/flops2014.pdf