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 CBC76BB84 for ; Wed, 28 Jun 2006 18:47:32 +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 k5SGlXaY019676 for ; Wed, 28 Jun 2006 18:47:33 +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 SAA22264 for ; Wed, 28 Jun 2006 18:47:31 +0200 (MET DST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.193]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k5SGlUbf012771 for ; Wed, 28 Jun 2006 18:47:31 +0200 Received: by nz-out-0102.google.com with SMTP id 34so512289nzf for ; Wed, 28 Jun 2006 09:47:29 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EPQXOv6Qg2enRjEbsrKxMwY0mip06zVxGo5+OcYb3201O5KGnW2IBq346YbvXt35pPYkCIcot9YKnpfu88kTo0ceXQEwk2YkJrD1/GFPSmZoSA2nYRVu8DdnBf6eOBbgNX0PLGLZ/+a6jg2+ZoBJFZv2DaBTjaNqjEqZs6tiN68= Received: by 10.36.24.20 with SMTP id 20mr744877nzx; Wed, 28 Jun 2006 09:47:29 -0700 (PDT) Received: by 10.36.101.10 with HTTP; Wed, 28 Jun 2006 09:47:29 -0700 (PDT) Message-ID: Date: Thu, 29 Jun 2006 04:47:29 +1200 From: "Jonathan Roewen" To: "Seth J. Fogarty" Subject: Re: [Caml-list] Question on Variant Types Cc: caml-list In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-j-chkmail-Score: MSGID : 44A2B2A2.004 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44A2B2A5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44A2B2A2.004 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; foo:01 foo:01 ocaml:01 val:01 caml-list:01 int:01 variant:02 tree:02 tree:02 types:02 let:03 let:03 docs:05 nil:06 nil:06 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 > type foo = [`Nil | `Tree of foo] > type bar = [`Nil | `Leaf of int | `Tree of bar] > > let f x : foo = x > let g x : bar = x > let a = `Tree (`Nil) > let b = `Tree (a) > let c = `Tree (f a) > let d = `Tree (`Leaf 1) > > As is proper, I can run f on a, b, and c, but not on d. D is not a valid > foo. > But I cannot run g on c. This makes sense, as I have said 'a tree of bars > contains a bars.' But I want to somehow note that a tree of bars MIGHT > contain foo's. Is there any way to annotate this? >>From the ocaml reference docs: # let bar_of_foo t = (t : foo :> bar);; val bar_of_foo : foo -> bar = # g (bar_of_foo c);; - : bar = `Tree (`Tree `Nil) Jonathan