Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] newbie type problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-24 (13:21)
From: Remi Vanicat <vanicat@l...>
Subject: Re: [Caml-list] newbie type problem
Andrew Lenharth <> writes:

>> 	Yeah, but I still couldn't figure out how to make a Map, assuming 
>> that's what I really wanted in the first place.  A hash table that 
>> iterates in key sorted order would make my app faster and reduce 
>> complexity.  I want to see it actually work first, though.  :)
> Yes, making a map is non-obvious.  One first has to figure out the 
> module system, with no examples.  Here is a hint:
> module StringSet = Set.Make(struct type t = string let compare x y = 
> compare x y end)
> then you can do things like
> StringSet.mem n1 set;;
> StringSet.union s1 s2;;
> StringSet.add x StringSet.empty;;
> BTW: I am sure you can do the compare without the x y by 
> compare=compare.

Yes you can.

In recent caml you might even do :

module StringSet = Set.Make (String)

It work because in the stdlib's String module there is a type t equal to
string, and a compare function.

Rémi Vanicat

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: