I am going to practicing using Map in Ocaml.
I found that the usage of Map is quite different from List, Array, etc.
I understand it is applying functor which I haven't learnt yet. but it is fine.
Here is my IntMap
module IntMap = Map.Make(struct type t = int let compare = compare end)
So, now I can use IntMap to add by IntMap.add x y map, etc, right?
I have a few questions:
- How do I control the type of
valuein themap? - If I want a alias type for my
IntMap, what should I do? I can dotype 'a my_type = 'a list, but how to do formap? - I find that
IntMapis likeListand both of them are actuallymodules. ButListhas a type oflist, what about themap?