From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id BA75CBC0A for ; Wed, 3 Jan 2007 03:29:28 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l032TSFw012022 for ; Wed, 3 Jan 2007 03:29:28 +0100 Received: by ug-out-1314.google.com with SMTP id q2so6155082uge for ; Tue, 02 Jan 2007 18:29:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=hOdFC3Sb9RZ452l910Lni+dULCUQiNi4cGG5sIp8CLPf6TgYepftUoXh/Hse9m61BXH7/2qBg1t9F7oL7ONHgumm013sMh+qG8Bh+dWUXU+J7WW4S4I6uK0e0CKPsPCR7h2PI5PTO9mPTTeZgfiijDunYqO1NP01pfP6pPy2VU8= Received: by 10.78.171.13 with SMTP id t13mr2099012hue.1167791368092; Tue, 02 Jan 2007 18:29:28 -0800 (PST) Received: by 10.78.159.17 with HTTP; Tue, 2 Jan 2007 18:29:28 -0800 (PST) Message-ID: Date: Wed, 3 Jan 2007 15:29:28 +1300 From: "Jonathan Roewen" To: "William W Smith" Subject: Re: [Caml-list] symbol table containing symbol tables Cc: caml-list@yquem.inria.fr In-Reply-To: <886949.65043.qm@web82112.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <886949.65043.qm@web82112.mail.mud.yahoo.com> X-j-chkmail-Score: MSGID : 459B1508.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 459B1508.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hashtbl:01 val:01 symtable:01 symtable:01 hashtbl:01 ocaml:01 recursive:01 syntax:01 ocaml:01 beginner's:01 bug:01 sbcglobal:98 beginners:01 wrote:01 caml-list:01 I don't believe you can eliminate the type variable (for the values associated with the keys) from Map's signature. I would personally just use a Hashtbl instead. type complicated = Val of int | StrVal of string | SymTableVal of symTable and symTable = (string, complicated) Hashtbl.t Jonathan On 1/3/07, William W Smith wrote: > In pidgin OCaml I'd like to write something like > > type complicated = > IVal of int > | StrVa, of string > | SymTableVal of symTable > and > symTable = Map(string -> complicated) > > I tried many variations on using the Map module to implement a recursive > data structure like this. I failed miserably. (The above wasn't the syntax > I ever used, but it gets the idea across.) > > However, when I create an object > class [ 'key, 'content ] table : ('key -> 'key -> int) -> > object > ,,, > end > > I can successfully declare > type complicated = > IVal of int > | StrVal of string > | SymTableVal of (string, complicated) table > that does what I want. Ithis isn't the whole declaration of complicated, > but I believe once I get this declaration working, the more quirky > variations work too. > > Do I need one of the more advanced features of OCaml that I don't currently > understand to use Map the way that I want without writing a whole table > class? I don't even see how I can use Map from inside the table class to do > what I want which would also be acceptable. > > I don't want to have to break open the Map module to modify it and thus > change the licensing of my final program. > > Thanks > > Bill > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: > http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > >