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 CC7427F72C for ; Sat, 20 Aug 2016 03:57:48 +0200 (CEST) IronPort-PHdr: 9a23:ascfehMDckm0jBqIgfIl6mtUPXoX/o7sNwtQ0KIMzox0Kfz4rarrMEGX3/hxlliBBdydsKMdzbCJ+P26ESxYuNDa4ShEKMQNHzY+yuwu1zQ6B8CEDUCpZNXLVAcdWPp4aVl+4nugOlJUEsutL3fbo3m18CJAUk6nbVk9GO35F8bogtit0KjqotuIMlwO3mX2POk6bE3v616A7o9O2coqA51y4yOBmmFPdeVSyDEgDnOotDG42P2N+oV++T9bofMr+p0Ie6z7e6MlUe4QV2x+YCgdrffmvhjbTAaJ+mBUEiBPykIJUED560TTWprhvzqym+V6wi6EdZn7Sb0/RS6v4I9vSQT0zj0aYW0X6mbS3+55h7tGrQnpiBVl2Y/bfYzdYPV3ZLnccs4XbW9IQsYXUSVOBZK1KpZJBuFHP/4O/Nq1nEcHsRbrXVrkP+jo0DIdwyauhaA= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@mailhost.math.nagoya-u.ac.jp Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ADAAAkuLdXlwWCBoVehBp8t3OBfQEjhT86AoIeFAIBAQEBAQEBARIBAQEBAQgWB0iCMgQBEwGCFAEFJxMGAwE1AQEOBQYOChwSVwYkiB8Pqh6FLAcCh0Qag0kBAQEBAQEBAQEBAQEBAQEBAQEBAQETAQMFiCOCVYRAgyyCL4Y+B4hTijSGIIh/Co9CjD6DeB6CWYFmYQWHKQEBAQ X-IPAS-Result: A0ADAAAkuLdXlwWCBoVehBp8t3OBfQEjhT86AoIeFAIBAQEBAQEBARIBAQEBAQgWB0iCMgQBEwGCFAEFJxMGAwE1AQEOBQYOChwSVwYkiB8Pqh6FLAcCh0Qag0kBAQEBAQEBAQEBAQEBAQEBAQEBAQETAQMFiCOCVYRAgyyCL4Y+B4hTijSGIIh/Co9CjD6DeB6CWYFmYQWHKQEBAQ X-IronPort-AV: E=Sophos;i="5.28,547,1464645600"; d="scan'208";a="233338671" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Aug 2016 03:57:47 +0200 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 53D126398 for ; Sat, 20 Aug 2016 10:57:44 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (rabbit-172.math.nagoya-u.ac.jp [172.16.254.254]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 5774F2532; Sat, 20 Aug 2016 10:57:43 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=sSkn75BAFvAu4SDk55zxmGT1Axc=; b=FYtd8U6xb/C2jEUKKuXcPTf1AfR4 e4uXbZpQAK5wBce1MKpxAvFYGOxpOo9QUP/wEQ17qvEc1NhqGLIEtbxLlThQbrXp hD4Hgs1HeoiRHgUNXZVuU1YBScPONWlwG0zE4Lg813LNe9z+6mngjs9PAC6PHCpU QhlbHizMUl7KeDo= DomainKey-Signature: a=rsa-sha1; h=Received:Subject:Mime-Version:Content-Type:From:X-Priority:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=2McbThOZ6m4H9hogBSGv5UyByz2GftK3La1q7RcQWgw9c1lZAHA+/yJedmwA6bful044U7fDVEFUqwiTPr2z0FZBhaq5OCSmW6leQR81epD9QtIelZ/tUFSGOsQlGMUwcGdyo2s7bKcDxcCe34fiPV6EGABNwrwLGCMfY4QuDck=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 187841E7A; Sat, 20 Aug 2016 10:52:58 +0900 (JST) Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=us-ascii From: Jacques Garrigue X-Priority: 3 (Normal) In-Reply-To: <1471651332.586948056@f325.i.mail.ru> Date: Sat, 20 Aug 2016 10:57:42 +0900 Cc: OCaML List Mailing Content-Transfer-Encoding: quoted-printable Message-Id: References: <1471651332.586948056@f325.i.mail.ru> To: Alexey Egorov X-Mailer: Apple Mail (2.3124) Subject: Re: [Caml-list] CPS converting existential data type On 2016/08/20 09:02, Alexey Egorov wrote: >=20 > Hello, >=20 > in haskell it's possible to convert some data type to it CPS'ed form usin= g rank-N polymorphism. >=20 > I'm trying to do the same in ocaml using objects with polymorphic methods= (instead of GHC RankNTypes extension), and it works well unless I'm using = data type with existential type variables. >=20 > Example - https://gist.github.com/anonymous/57262e4e1009e658b97e8986a2d03= d40=20 > Haskell version compiles, while ocaml version gives type error about univ= ersal variable escaping it's scope. >=20 > What is the right way to do this? Is it possible at all? The problem is that type annotations are not propagated to the body of obje= cts, so you need to annotate the method explicitly, or to annotate the type= of self. The following annotated version works: let uncps : type a . a cps_t -> a t =3D fun p -> p # get Nil (object method get : 'e . (a, 'e) d -> ('e -> a) -> a t =3D fun d f -> Cons (d,= f) end) Thank you for this interesting example. Jacques Garrigue=