From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 3D682BBD7 for ; Thu, 4 Aug 2005 22:07:58 +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 j74K7vVG032258 for ; Thu, 4 Aug 2005 22:07:57 +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 WAA26103 for ; Thu, 4 Aug 2005 22:07:57 +0200 (MET DST) Received: from mx4.ucdavis.edu (mx4.ucdavis.edu [169.237.104.14]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j74K7tGw007748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 4 Aug 2005 22:07:56 +0200 Received: from [169.237.7.95] (puck.cs.ucdavis.edu [169.237.7.95]) by mx4.ucdavis.edu (8.13.3/8.13.1/it-defang-5.4.0) with ESMTP id j74K7qx6020798; Thu, 4 Aug 2005 13:07:53 -0700 (PDT) Message-ID: <42F2752C.9070904@crans.org> Date: Thu, 04 Aug 2005 13:06:04 -0700 From: Stephane Glondu User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jtbryant@valdosta.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Marshal and Polymorphism References: <1123179836.3276.76.camel@starlight.valdosta.edu> In-Reply-To: <1123179836.3276.76.camel@starlight.valdosta.edu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.49 on 169.237.104.14 X-Miltered: at nez-perce with ID 42F2759D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42F2759B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 polymorphism:01 val:01 forall:01 ...:98 ...:98 wrote:01 polymorphic:01 marshal:01 marshal:01 explicitly:01 int:01 defined:01 string:03 string: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 Hi, Jonathan Bryant wrote: > If I make the module have > > type = ('a, 'b) t > > in the module definition, can I use > > (Marshal.from_string ... : 'a) > > and get whatever 'a was defined as in the definition. In the way I understood your message, you cannot. However, if you do something like : let get (table : ('a, 'b) t) index = (Marshal.from_string ... : 'a) The 'a type variable must be bound /inside/ a surrounding function (and (Marshal.from_string val : 'a) should be forbidden outside a function). > For example, if > it was a (string * int) t, would the function return a string? Now, yes. > Or would > this be redundant (since Marshal.from_string already returns 'a)? No! Actually, the return type of Marshal.from_string is [forall 'a. 'a], so it is different from any other 'a which could be already bound at this moment. Therefore, you must explicitly tell the return type of Marshall.from_string, even if it is polymorphic. I hope this is clear. Best regards, -- Stephane Glondu