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 909CABB84 for ; Fri, 4 Aug 2006 04:42:25 +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 k742gOnE002561 for ; Fri, 4 Aug 2006 04:42:25 +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 EAA10370 for ; Fri, 4 Aug 2006 04:42:24 +0200 (MET DST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k742gMXr001430 for ; Fri, 4 Aug 2006 04:42:23 +0200 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k742gJ6k010948; Fri, 4 Aug 2006 11:42:19 +0900 (JST) Date: Fri, 04 Aug 2006 11:42:39 +0900 (JST) Message-Id: <20060804.114239.193683263.garrigue@math.nagoya-u.ac.jp> To: colanderman@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Unexpected '_a problem From: Jacques Garrigue In-Reply-To: <875c7e070608021057rfb89914x1d6b9c6e7e4d7ce0@mail.gmail.com> References: <6b8a91420608011509s696233cew8d499f315aa0cba9@mail.gmail.com> <44D04D83.5020503@inria.fr> <875c7e070608021057rfb89914x1d6b9c6e7e4d7ce0@mail.gmail.com> X-Mailer: Mew version 4.0.69 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 44D2B410.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44D2B40E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe's:01 polymorphism:01 compiler:01 caml-list:01 output:02 garrigue:03 garrigue:03 seems:03 seems:03 unexpected:03 module:03 unit:03 unit:03 jacques:03 jacques: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=none autolearn=disabled version=3.0.3 From: "Chris King" > Okay, that (and Christophe's explanation) explains why hiding > everything in a module works. Thanks everyone for your help! It > seems I will have to use Obj.magic to get the type I want but at least > its use in this situation seems both safe and warranted. There are no "safe" uses of Obj.magic. It just happens to work in some cases, but it is strongly discouraged to use it to get around the type system, particularly when there are other ways to reach the same result. type 'a bar_t = Bar of unit) -> unit> ;; let create_bar () = Bar (object method bar (_: 'a) = () end);; let b = create_bar ();; let Bar b = b;; Note that you need two definitions, as mixing the application with the extraction would loose the polymorphism. If you still want to use Obj.magic, remember to put complete type annotions on both its input and output, as the lack of type information may break the compiler. Jacques Garrigue