'Univ_map Equivilant

I'm currently writing a project in OCaml, that requires the functionality provided by Univ_map; here's an example. A brief explanation goes as follows: there is a module Type_equal.Id which allows you to create unique identifiers with an associated type. For example, we can have:

# let name = Type_equal.Id.create ~name:"name" sexp_of_string;;
val name : Core_kernel__.Import.string Core.Type_equal.Id.t = <abstr>

Notably, name has the type String.t associated with it, which the compiler knows b/c of the type of sexp_of_string. You would then be able to then use name as an identifier to a Univ_map.t, where the data stored with name is a String.t. Critically, you could also store bindings with different Type_equal.Id.t values that are parameterized over different types, allowing full type safety as well as the ability to store different types of data in the same map.

I'm wondering if there are any other statically typed languages with this ability?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source