List Info

Thread: "ocaml_beginners"::[] The type of Map.Make




"ocaml_beginners"::[] The type of Map.Make
user name
2006-06-09 16:24:34
2006/6/9, darioteixeira <darioteixeirayahoo.com>:
> Hi,
[...]
> The sample.ml file could be something like this:
>
>
------------------------------------------------------------
> module Mymap = Map.Make (struct type t = string let
compare =
> Pervasives.compare end)
> let create_dict pair = Mymap.add (fst pair) (snd pair)
Mymap.empty
>
------------------------------------------------------------
> Now, I want to create also the corresponding mli file. 
The compiler
> can indeed give me a hand with that:
[...]
> But here's my question: is there a simpler way of
specifying the signature
> of Mymap?  I thought of something like the code below,
but the problem is
> that the fact that the key must be of type string is
lost.  How do I
> explicitly tell the compiler that Mymap is a mapping
from string to int?

module Mymap : Map.S with type key = string
val create_dict : string * 'a -> 'a Mymap.t


------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Get to your groups with one click. Know instantly when new
email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )