Search code examples
dictionaryocaml

OCaml standard Map vs. Jane Street Core.std Map


So I'm using Jane Street's Core.std for certain things in my program but still want to use the standard OCaml Map. However, when I call functions like mem, it expects the signature of the Core.std version. How do I get past this hurdle?

open Core.Std
open Map

module PortTable = Map.Make(String)
let portTable = PortTable.empty 
let string_add = (Int64.to_string packet.dlDst) in 
PortTable.mem string_add portTable

This will not compile for me, as it's expecting Core.std's version of mem, not the standard one:

Error: This expression has type string but an expression was expected of type 'a PortTable.t = (string, 'a, PortTable.Key.comparator_witness) t

I just want to use the standard one. How can this be done?


Solution

  • The Core.Std library exposes the standard library via the Caml module, thus, you can access any value from the standard library by just prefixing its name with Caml. e.g.,

    module PortableMap = Caml.Map.Make(String)