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: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] symbol table containing symbol tables
Ooh, that's clever. An actual use case for recursive modules that's
also simple :-)

On 1/3/07, Jon Harrop <jon@ffconsultancy.com> wrote:
> 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
>
> _______________________________________________
> 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
>