Currently, Erg doesn't have homogenous dict types.
dic: {Int: Str, Str: Float} = {1: "a", "b": 1.0}
A dictionary with Str as keys and Int as values is simply of type {Str: Int}.
We can write key/values of different types, but sometimes this spec is too elastic (especially for mutable Dict types).
Therefore, we propose to introduce homogenous dict types Dict(K, V)/Dict!(K, V).
dic: Dict(Str, Int) = {"a": 1, "b": 2}
The current heterogeneous dict types are kinds of structural types, just like record types, and are subtypes of the homogenous dict types. For example, {K1: V1, K2: V2} is a subtype of Dict(K1 or V1, K2 or V2).
Currently, Erg doesn't have homogenous dict types.
A dictionary with
Str
as keys andInt
as values is simply of type{Str: Int}
.We can write key/values of different types, but sometimes this spec is too elastic (especially for mutable Dict types).
Therefore, we propose to introduce homogenous dict types
Dict(K, V)/Dict!(K, V)
.The current heterogeneous dict types are kinds of structural types, just like record types, and are subtypes of the homogenous dict types. For example,
{K1: V1, K2: V2}
is a subtype ofDict(K1 or V1, K2 or V2)
.