From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id AF036BC37 for ; Thu, 11 Feb 2010 16:17:37 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgABAP6tc0uLEwExgGdsb2JhbACaehUBAQsLCgUVBR6wYgGNUwWEVg X-IronPort-AV: E=Sophos;i="4.49,453,1262559600"; d="scan'208";a="56885061" Received: from hera.mpi-sb.mpg.de ([139.19.1.49]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 11 Feb 2010 16:17:37 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Message-ID:In-Reply-To: References:Date:Subject:From:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=TKnfuQLiGp8ZSus70AzfSMjHHEm2Oh7Un/ HDOObawbA=; b=sEYqfueoK0UWenuFWyDJYMvvdnDC7IPNAJR/rsgrqvJuMMFWJV wQ7CSvLaoLma6jO1uHd6ZkmYkhGSosklr6I99cDsn/85AbKcTKf+QWO6j1N9slis iJWOXtprDG+s8RwOt5jdsqKVlVLPRfcITth0ZXd/rcKWxdL88eDh6V7lo= Received: from newzak.mpi-sb.mpg.de ([139.19.1.28]:52362) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1NfanN-0005p5-Et; Thu, 11 Feb 2010 16:17:36 +0100 Received: from www-data by newzak.mpi-sb.mpg.de with local (Exim 4.63) (envelope-from ) id 1NfanN-0004XN-3r; Thu, 11 Feb 2010 16:17:33 +0100 Received: from 80.146.185.83 (SquirrelMail authenticated user rossberg) by mail.mpi-sws.org with HTTP; Thu, 11 Feb 2010 16:17:33 +0100 (CET) Message-ID: <1c9307ccfe18231af34a047d2a654daf.squirrel@mail.mpi-sws.org> In-Reply-To: <4b39c80a1002110552w3d223293x5a2836bebcdf9e24@mail.gmail.com> References: <14cf844b1002081907y2900c313q97ae0cb6f4c92394@mail.gmail.com> <891bd3391002081959i4f9b70d4re1914ad7e439b5e3@mail.gmail.com> <4b39c80a1002110239i2fc1f555if642ed6a589d5b66@mail.gmail.com> <923d63e1a659ace0fee3550f81944e28.squirrel@mail.mpi-sws.org> <4b39c80a1002110552w3d223293x5a2836bebcdf9e24@mail.gmail.com> Date: Thu, 11 Feb 2010 16:17:33 +0100 (CET) Subject: Re: [Caml-list] Preventing values from escaping a context From: rossberg@mpi-sws.org To: "Alexey Rodriguez" Cc: caml-list@inria.fr User-Agent: SquirrelMail/1.4.15 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Spam: no; 0.00; rossberg:01 fwiw:01 ocaml:01 encodings:01 pointers:01 ocaml:01 byte:01 monads:01 polymorphic:01 polymorphic:01 wrote:01 encode:01 andreas:01 andreas:01 caml-list:01 "Alexey Rodriguez" wrote: > >>> But for this you need support from the type system (rank-2 universal >>> quantification). >> >> FWIW, OCaml can express that, but it doesn't help the problem. > > Andreas, I'd be interested in seeing such encodings. Any pointers? There are currently two ways to express that in OCaml, either through polymorphic record fields or through polymorphic object methods. For the former, consider: type f_arg = {it : 'a. 'a -> 'a} let f {it = g} = (g 5, g true) f {it = fun x -> x} One caveat is that the value restriction can byte you, especially if you try to encode s.th like monads, but that's a somewhat separate issue. /Andreas