I have a module StringMap built by the functor Map.Make given a type String:
module StringMap = Map.Make(String)
Besides the ordinary operations provided by Map, I would like to add more definitions in this module, for instance, my_own_function, such that I could call StringMap.my_own_function. Does anyone know where I should define this kind of functions and their signature?
You can use the
includekeyword inside a new module to add all the same functions. This was also extended to the signature in OCaml 3.12.If you want to access the structure of the map, you’ll have to add some
Obj.magicor the%identityspecial external function. The redefinition of the type must be exact since no type checking is happening,