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 F3B64BB9C for ; Thu, 15 Sep 2005 08:31:33 +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 j8F6VWxJ013100 for ; Thu, 15 Sep 2005 08:31: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 IAA14744 for ; Thu, 15 Sep 2005 08:31:32 +0200 (MET DST) Received: from kraid.nerim.net (smtp-104-thursday.nerim.net [62.4.16.104]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8F6VWC3013773 for ; Thu, 15 Sep 2005 08:31:32 +0200 Received: from karryall.dnsalias.org (karryall.dnsalias.org [213.41.180.99]) by kraid.nerim.net (Postfix) with ESMTP id D4B0E40F67; Thu, 15 Sep 2005 08:31:31 +0200 (CEST) Received: by karryall.dnsalias.org (Postfix, from userid 500) id 72402596F8F; Thu, 15 Sep 2005 08:31:31 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17193.5442.928760.693881@karryall.dnsalias.org> Date: Thu, 15 Sep 2005 08:31:30 +0200 From: Olivier Andrieu To: Jacques Garrigue Cc: ibormuth@efil.de, caml-list@inria.fr Subject: Re: [Caml-list] Reference to polymorphic function ? In-Reply-To: <20050915.084814.127622622.garrigue@math.nagoya-u.ac.jp> References: <20050913123843.GA9640@kruemel> <20050915.084814.127622622.garrigue@math.nagoya-u.ac.jp> X-Mailer: VM 7.19 under Emacs 21.4.1 X-Miltered: at concorde with ID 43291544.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43291544.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 andrieu:01 ijm:01 caml-list:01 val:01 resolving:01 ingo:98 efil:98 polymorphic:01 polymorphic:01 expression:01 jussieu:01 define:01 explicitly:01 int:01 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 Jacques Garrigue [Thursday 15 September 2005] : > > From: Ingo Bormuth > > > Nevertheless, if I store the polymorphic function in a reference > > to create a closure for all kinds of output methodeis, any > > attemps to use that function are thwarted by the type interferer. > > > > # let put = ref put_to_screen ;; > > val put : ('_a -> unit) ref = {contents = } > > > > # !put "test" ;; > > %%%%%%test- : unit = () > > > > # !put 5 ;; > > This expression has type int but is here used with type string > > > > How can I keep the interferer from explicitly resolving the type of v ? > > You cannot: this would be unsound. > Actually, this is the opposite: you want to tell in advance the > inferer that put is polymorphic, and that only polymorphic values > should be accepeted. The simplest way to do this is to define a new > type: > > type put = {put: 'a -> unit} ;; > let put = {put = put_to_screen} ;; > put.put "test";; > put.put 5;; did you mean : type put = {put: 'a. 'a -> unit} ;; or is the explicit polymorphic parameter not required anymore (like polymorphic methods in class types) ? -- Olivier