From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA09739; Thu, 26 Feb 2004 02:49:42 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 CAA09728 for ; Thu, 26 Feb 2004 02:49:41 +0100 (MET) Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i1Q1ngIq027050 for ; Thu, 26 Feb 2004 02:49:42 +0100 Received: from stratocaster.home (c-24-3-150-197.client.comcast.net[24.3.150.197]) by comcast.net (sccrmhc12) with ESMTP id <2004022601493801200f0to0e>; Thu, 26 Feb 2004 01:49:38 +0000 Received: from ecc by stratocaster.home with local (Exim 4.30) id 1AwAef-00014S-Tz; Wed, 25 Feb 2004 20:49:37 -0500 Date: Wed, 25 Feb 2004 20:49:37 -0500 To: caml-list@inria.fr Cc: ijtrotts@ucdavis.edu Subject: Re: [Caml-list] References to polymorphic variants Message-ID: <20040226014937.GB4099@localhost> Mail-Followup-To: caml-list@inria.fr, ijtrotts@ucdavis.edu References: <20040225224109.GC3578@localhost> <20040225230719.GA1148@manzanita> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040225230719.GA1148@manzanita> User-Agent: Mutt/1.5.5.1+cvs20040105i From: "Eric C. Cooper" X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 issac:01 trotts:01 foo:01 usr:01 ocamlc:01 foo:01 unspecified:01 implicitly:01 ocamlc:01 val:01 bin:01 variants:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Feb 25, 2004 at 03:07:19PM -0800, Issac Trotts wrote: > He's talking about compiling it, which is slightly different: > > $ cat foo.ml > let (x : ([> ] option) ref ) = ref None ;; > > $ /usr/bin/ocamlc -c foo.ml > File "foo.ml", line 1, characters 31-39: > The type of this expression, _[> ] option ref, > contains type variables that cannot be generalized > > The set of values that x can have is still unspecified, so there is > implicitly a type variable whose value needs to be nailed down before > the example can compile. Here's a way to work around it: > > type t = [ `bleh | `woof ];; > let x = ref (None : t option);; Or, he can just use x in the scope of that module, if that's sufficient for his application. $ cat foo.ml let (x : [> ] option ref) = ref None let () = x := Some `Apple; x := Some (`Pair (17, "foo")); x := Some `Cheese $ ocamlc -i -c foo.ml val x : _[> `Apple | `Cheese | `Pair of int * string ] option ref -- Eric C. Cooper e c c @ c m u . e d u ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners