Version française
Home     About     Download     Resources     Contact us    
Browse thread
symbol table containing symbol tables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] symbol table containing symbol tables
On Wednesday 03 January 2007 01:59, William W Smith wrote:
> 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.

You need recursive modules, something like this:

# module rec StringMap : Map.S = Map.Make(String)
  and Symbols : sig
    type t =
      | IVal of int
      | StrVal of string
      | SymTableVal of t StringMap.t
  end = struct
    type t =
      | IVal of int
      | StrVal of string
      | SymTableVal of t StringMap.t
  end;;
module rec StringMap : Map.S
and Symbols :
  sig
    type t = IVal of int | StrVal of string | SymTableVal of t StringMap.t
  end

HTH.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists