From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id C6C15BC0A for ; Mon, 14 May 2007 12:52:05 +0200 (CEST) Received: from orion.metastack.com (no-dns-yet.demon.co.uk [80.177.38.218] (may be forged)) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4EAq4LR006402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 14 May 2007 12:52:05 +0200 Received: from treble (cpc2-cmbg6-0-0-cust535.cmbg.cable.ntl.com [81.107.34.24]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id l4EApAO9026005 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 14 May 2007 11:51:11 +0100 From: "David Allsopp" To: References: <20070514100005.459F6BC70@yquem.inria.fr> Subject: Re: [Caml-list] Polymorphic variant difference... Date: Mon, 14 May 2007 11:52:04 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <002c01c79615$e9750b30$6a7ba8c0@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AceWDpjDSFglzDWLQFCsYyEnZzow2wAAROWQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: <20070514100005.459F6BC70@yquem.inria.fr> X-Miltered: at discorde with ID 46483F54.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; subtraction:01 syntax:01 constructors:01 camlp:01 polymorphic:01 polymorphic:01 caml-list:01 variant:02 variant:02 coerce:02 match:02 match:02 types:03 let:03 let:03 > Given a polymorphic variant type t with a label `B how does one build > the type corresponding to t without the label `B. So that you could write something like: type t = [ `A | `B | `C ] let f x = match x with `B -> (* x has type t *) | #(t minus [ `B ]) as x -> (* x has type [ `A | `C ] *) I end up having to write lots of tedious extra types to achieve that normally... I'd find a subtraction syntax very handy too. On a similar subject, am I the only person who finds I often need to take a fixed polymorphic variant value and coerce it so that it can just accept more constructors e.g. (seriously contrived example)... type t = [ `A | `B | `C ] let f (x : t) = match x with `A -> `D | _ -> (x : t :> [> t ]) Something more concise than (x : t :> [> t ]) would be nice: e.g. (x ::> t) But perhaps that really is a job for camlp4! David