Open module syntax error


#1

let abc: Hashtbl.t(string, string) = Hashtbl.create(5);

/* it’s ok */
abc->Hashtbl.add(“a1”, “value”);

/* it’s ok */
{
open Hashtbl;
add(abc, “c1”, “value”);
abc->add(“d1”, “value”);
}

/* it’s not ok */
Hashtbl.(
add(abc, “b1”, “b1v”);
abc->abc(“b1”, “b1v”);
);

why? you can see about this in


#2

There’s a typo in the last example - abc->abc(...) rather than abc->add(...). If that’s in the original code then that could be the issue.


#3

You need a code block after the local open:

Hashtbl.({
  add(abc, "b1", "b1v");
  abc->add("b1", "b1v");
}) 

#4

thank you! I see it.