I’m trying to do some associative stuff.
But there are different types possible.
- association-lists
- maps
- hash-tables
- associative-arrays
What are the ocaml API’s to do this ?
I know there is Jane-Streeth, but it looks a waste of time. Because you need a community to go somewhere.
Hi, modules for all of the above are in the OCaml standard library. Have you tried there?
What does that even mean?
Jane Street base has a convenient List.Assoc
module to deal with association list. That’s often the most convienient way to interop with a lot of associative APIs since that’s what libraries like e.g. Yojson return.
Maps vs Hashtables is a question of whether you want the data structure to be mutable or not. There’s cases for both, but most of the time I would go with a map, especially if returning some data to a consumer. For the common case that the key is a string
, Base has String.Map
and String.Table
so you don’t need to write your own functor, which is somewhat conventient.
3 Likes
If you are interested to associate string
with something, you should take look on art which has better performances than Hashtbl

2 Likes