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 4DDA1BB84 for ; Tue, 1 Aug 2006 22:47:23 +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 k71KlM8n030726 for ; Tue, 1 Aug 2006 22:47:22 +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 WAA01242 for ; Tue, 1 Aug 2006 22:47:22 +0200 (MET DST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.179]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k71KlLJv030712 for ; Tue, 1 Aug 2006 22:47:21 +0200 Received: by py-out-1112.google.com with SMTP id f25so1192287pyf for ; Tue, 01 Aug 2006 13:47:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=So6wrUd9G6K9LVfIMyb4RB6KtmT4FFu25fa+JAj3f7HhmBYtXqHl28CblfDsq5+zca4PJduswM3gNGT9aRQxaqHbyRv9T9wxBjwdYT0lSKsR4SrvRH1CVeCFo8wj5QTk+u7ZGsGcE1eKAtm6j1C4Lr/olKjpDAlcNpcBTleA06U= Received: by 10.35.22.17 with SMTP id z17mr99804pyi; Tue, 01 Aug 2006 13:47:21 -0700 (PDT) Received: by 10.35.130.17 with HTTP; Tue, 1 Aug 2006 13:47:21 -0700 (PDT) Message-ID: <875c7e070608011347y62d2dd21lc55390cd4ffd00a1@mail.gmail.com> Date: Tue, 1 Aug 2006 16:47:21 -0400 From: "Chris King" To: "O'Caml Mailing List" Subject: Unexpected '_a problem MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 44CFBDD9.001 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44CFBDDA.004 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44CFBDD9.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; foo:01 foo:01 val:01 val:01 compiler:01 compiler:01 polymorphic:01 abstract:01 monomorphic:01 monomorphic:01 restrict:02 covariant:02 unexpected:03 module:03 unit:03 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 Given this code: # let create_foo () = object method foo (_: 'a) = () end;; val create_foo : unit -> < foo : 'a -> unit > = # let a = create_foo ();; val a : < bar : '_a -> unit > = the compiler determines a is monomorphic, since 'a is in a contravariant position. But why, when 'a is placed in a covariant position: # let create_bar () = object method bar (_: 'a) = () end;; val create_bar : unit -> < bar : ('a -> unit) -> unit > = # let b = create_bar ();; val b : < bar : ('_a -> unit) -> unit > = does the compiler restrict b to be monomorphic? If I wrap everything up in a module and abstract the type returned by create_bar (), create_bar () works as expected and returns a polymorphic value. Thanks, Chris King