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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 60182BB84 for ; Thu, 29 Jun 2006 01:44:22 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k5SNiMFh031756 for ; Thu, 29 Jun 2006 01:44:22 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA27971 for ; Thu, 29 Jun 2006 01:44:21 +0200 (MET DST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.200]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k5SNiKfT016975 for ; Thu, 29 Jun 2006 01:44:21 +0200 Received: by nz-out-0102.google.com with SMTP id q3so2155500nzb for ; Wed, 28 Jun 2006 16:44:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:subject:cc:in-reply-to:mime-version:content-type:references; b=egIevzMbCHX/fGhyRn/ESbO4g0JlYRLsh5/tcKs28OK8K8KPkqOf6nEuy9OszlW0NaAj4agAG0DukNV8y7ClJRr3PApi1lzmpTrtV8eNsguft6oiY7rNMXfkA+BwWAnHz+VOAw7hnv1mMZOEOMe4QmKb3Se+7qDAsaWpZqscdqA= Received: by 10.36.22.10 with SMTP id 10mr1896065nzv; Wed, 28 Jun 2006 16:44:19 -0700 (PDT) Received: by 10.36.57.20 with HTTP; Wed, 28 Jun 2006 16:44:19 -0700 (PDT) Message-ID: Date: Wed, 28 Jun 2006 18:44:19 -0500 From: "Seth J. Fogarty" Subject: Re: [Caml-list] Question on Variant Types Cc: caml-list In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2081_5009086.1151538259830" References: X-j-chkmail-Score: MSGID : 44A31454.002 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44A31456.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44A31454.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; followup:01 foo:01 foo:01 followup:01 W12:98 char:01 char:01 caml-list:01 int:01 int:01 variant:02 variant:02 match:02 match:02 coerce:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=HTML_20_30,HTML_MESSAGE, RCVD_BY_IP autolearn=disabled version=3.0.3 ------=_Part_2081_5009086.1151538259830 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Followup question: Given I have: type foo = [`A | `B of int | `C of char] type bar = [`B of int | `C of char| `D] and a function let f (x : foo) : bar = match x with `A -> `D |`B _ |`C _ -> (x : bar) Is there any way to properly coerce this using the restricted variant information of x? Or do I have to duplicate code and reconstruct x? -- Seth Fogarty sfogarty@[gmail.com|rice.edu|livejournal] Neep-neep at large AIM: Sorrath "I know there are people in this world who do not love their fellow human beings - and I hate people like that" --Tom Lehrer. ------=_Part_2081_5009086.1151538259830 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Followup question:
Given I have:
type foo = [`A | `B of int | `C of char]
type bar = [`B of int | `C  of char| `D]

and a function
let f (x : foo) : bar =
match x with
    `A -> `D
   |`B _
   |`C _ -> (x : bar)

Is there any way to properly coerce this using the restricted variant information of x? Or do I have to duplicate code and reconstruct x?

--
Seth Fogarty             sfogarty@[gmail.com|rice.edu|livejournal]
Neep-neep at large    AIM: Sorrath
"I know there are people in this world who do not love their fellow
human beings - and I hate people like that" --Tom Lehrer. ------=_Part_2081_5009086.1151538259830--