Reputation: 21
First I've defined
module StringMap = Map.Make(String);;
and I have a list generated by StringMap.bindings, the types in the list are (StringMap.key × int).I want to use the key as a string so that I can compare them, how could I change its the type of the list?
Upvotes: 1
Views: 682
Reputation: 66818
Your type StringMap.key
is a synonym for string
. There is no need to convert, they are the same type.
# let mymap = StringMap.singleton "abc" 14;;
val mymap : int StringMap.t = <abstr>
# StringMap.bindings mymap;;
- : (StringMap.key * int) list = [("abc", 14)]
# fst (List.hd (StringMap.bindings mymap)) = "abc";;
- : bool = true
Upvotes: 3