From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 09309BC48 for ; Fri, 1 Apr 2005 04:28:41 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j312SeLp006596 for ; Fri, 1 Apr 2005 04:28:40 +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 EAA21258 for ; Fri, 1 Apr 2005 04:28:40 +0200 (MET DST) Received: from woodstock.1969.ws (64-215-156-42.eosinc.net [64.215.156.42]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id j312ScBO006593 for ; Fri, 1 Apr 2005 04:28:39 +0200 Received: (qmail 6614 invoked from network); 1 Apr 2005 02:28:37 -0000 Received: from karl.1969.ws (HELO ?10.3.2.15?) (10.3.2.15) by woodstock.1969.ws with SMTP; 1 Apr 2005 02:28:37 -0000 Message-ID: <424CB2B5.1060309@1969.ws> Date: Thu, 31 Mar 2005 18:32:21 -0800 From: Karl Zilles Organization: 1969 Communications, Inc. User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: yminsky@cs.cornell.edu Cc: Caml Mailing List Subject: Re: [Caml-list] Another polymorphism puzzle References: <891bd339050331180214df95db@mail.gmail.com> In-Reply-To: <891bd339050331180214df95db@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 424CB1D8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 424CB1D6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 polymorphism:01 yaron:01 minsky:01 foo:01 foo:01 val:01 unification:01 val:01 wrote:01 typing:01 int:01 int:01 variant:02 types:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Yaron Minsky wrote: > The last example I posted about had to do with variant types. Here's > another interseting little typing surprise having to do with record > types: > > # type 'a t = { foo: 'a };; > type 'a t = { foo : 'a; } > # let f x = { x with foo = 3 };; > val f : 'a -> int t = > > I can kind of see how this happened, since after all, the result of (f > x) does not depend in any way on x. And yet, it seems like the > unification rules should force f to have time ('a t -> int t). Wow. This is pretty cool. Also # type 'a t = { foo: 'a; bar: int };; type 'a t = { foo : 'a; bar : int; } # let f x = { x with foo = 3 };; val f : 'a t -> int t = (now the domain is limited to 'a t) # f { foo= "blah"; bar=100 };; - : int t' = {foo = 3; bar = 100}