I assume the idea is to create a table mapping strings to integers. Then you want to write its type as (string, int) hash_table
(the type hash_table
is a type with two parameters, which are written like that in ML).
But you also need a hash function hash : string -> word
and an equality function eq : string * string -> bool
over strings to provide to mkTable
. For the latter, you can simply use op=
, for the former you can use HashString.hashString
from the respective module.
So,
val ht : (string, int) HashTable.hash_table = HashTable.mkTable(HashString.hashString, op=)(17, Domain)
should work.
I should note, however, that hash tables tend to be vastly overused, and more often than not they are the wrong data structure. This is especially true in functional programming, since they are a stateful data structure. Usually you are better off (and potentially even more efficient) using some tree-based map, e.g., the RedBlackMapFn
from the SML/NJ library.