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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 5BA51BB83 for ; Fri, 5 May 2006 02:01:35 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4501YeR004499 for ; Fri, 5 May 2006 02:01:34 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA19793 for ; Fri, 5 May 2006 02:01:34 +0200 (MET DST) Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net [69.17.117.5]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4501VNm018378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 5 May 2006 02:01:33 +0200 Received: (qmail 28601 invoked from network); 5 May 2006 00:01:31 -0000 Received: from shell3.sea5.speakeasy.net ([69.17.116.4]) (envelope-sender ) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 5 May 2006 00:01:31 -0000 Date: Thu, 4 May 2006 17:01:30 -0700 (PDT) From: brogoff To: Jeremy Yallop Cc: caml-list@inria.fr Subject: Re: [Caml-list] Oddness with recursive polymorphic variants In-Reply-To: <445A4ED7.9080900@sms.ed.ac.uk> Message-ID: References: <445A23BF.4030001@sms.ed.ac.uk> <20060504171010.GB23421@yquem.inria.fr> <445A4ED7.9080900@sms.ed.ac.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 445A95DE.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 445A95DC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 variants:01 behaves:01 mismatch:01 coerced:01 wrote:01 polymorphic:01 caml-list:01 speakeasy:01 coercion:01 coercion:01 'g':01 match:02 output:02 types: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.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 4 May 2006, Jeremy Yallop wrote: > Thanks for the reply. That doesn't seem to be what I want, though. The > input to k should have type 'f'. The output should have type 'g'. Your > 'k' can be called with values that don't match type 'f': > > # k `C;; > - : g = `C > > The following does what I want: > > let k (#f as x:f) = (x:g) > > I'd like to understand why it behaves differently from the following: > > let k (x:f) = (x:g) Right, others have shown that you can do what you want with a coercion. The problem is that you are using exact types ("[" rather than "[>" ) and there is a mismatch of exact types. ":" is not a coercion, it just tells the type that should be there. ":>" coerces. x is not of type g, but it can be coerced to g. -- Brian