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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id D2846BBAF for ; Tue, 23 Mar 2010 03:53:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiMDAK/Jp0vRVdzXi2dsb2JhbACREooPCBUBAQEKCwoHEQUfrGqBY4UpLohLAQEDBYR4BA X-IronPort-AV: E=Sophos;i="4.51,291,1267398000"; d="scan'208";a="47313095" Received: from mail-fx0-f215.google.com ([209.85.220.215]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Mar 2010 03:53:12 +0100 Received: by fxm7 with SMTP id 7so2237913fxm.17 for ; Mon, 22 Mar 2010 19:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type :content-transfer-encoding:subject:date:message-id:to:mime-version :x-mailer; bh=CBPbpAB4HiKNHVhDJphWEZQm/5D7XfoKZ70RemFmrYw=; b=T7bxsNhFvOZQdmFh4S+pgAmv01gLL3DEC5gA9qWOJYYO9ewjKRhEv1KiwKuREu8qkm caoPaP1TuOMjWzweJM805O2QDYb7olU/1rmc3SQ6Ol9fCQYWXhylqPcF7Vz1xUqWmWVd 5ofomP1efhRwWUT1KxtF6Xly8TZMZmPTLyC+A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=YXq4QCcSdTzMawjvjgP22n47PBJYQfW8OoXs0yyTQnvgzFcteRJ/8jFCl6iAml1Y9x QpjUW/Q2HNBWkCcgljGlEWONFrAOaEp0yZcvHIlA8BCIskbFQpSAa3qDQI3CrUeL4U0o R+iDdOBfS1Uk4/5K7GuaaQ9YSvcZO1fgfuyYA= Received: by 10.223.4.211 with SMTP id 19mr4052027fas.72.1269312792120; Mon, 22 Mar 2010 19:53:12 -0700 (PDT) Received: from [192.168.2.6] (77-57-172-115.dclient.hispeed.ch [77.57.172.115]) by mx.google.com with ESMTPS id 12sm9369749fks.20.2010.03.22.19.53.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 22 Mar 2010 19:53:11 -0700 (PDT) From: Kaspar Rohrer Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Functions over polymorphic variants Date: Tue, 23 Mar 2010 03:53:10 +0100 Message-Id: To: caml-list@inria.fr Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) X-Spam: no; 0.00; variants:01 variants:01 trivial:01 ocaml:01 polymorphic:01 polymorphic:01 rec:01 functions:01 implemented:02 match:02 let:03 let:03 stream:04 stream:04 transform:05 I am tinkering with streams of polymorphic variants at the moment. One = thing that I would like to do is to write a stream transformer (not sure = this is the correct terminology) that simply drops certain values of an = open polymorphic type, and have the type of the function reflect this. This is trivial with a closed polymorphic type: type abc =3D [`a | `b | `c] let transform (stream : [< `x | abc] Stream.t) : [> abc] Stream.t =3D let rec fold () =3D match Stream.next stream with | `x -> Stream.slazy fold | #abc as x -> Stream.icons x (Stream.slazy fold) with Stream.Failure -> Stream.sempty in fold () However, I fail to see how the same function could be implemented so it = accepts an open polymorphic type as it's input. I.e. is there a way to express something like this (which is not valid = OCaml) let transform : [> `x | 'a] Stream.t -> [> 'a] Stream.t Does this even make sense? ---- Kaspar Rohrer kaspar.rohrer@bluewin.ch