[erlang-questions] How to specify a clear map type

月忧茗 <>
Thu Sep 22 18:39:59 CEST 2016

According this document:

I can define a map type like this:

-type my_type() ::  #{integer() := string()}.

I have a map called State, it's type is `my_type`,   key type is integer,
value type is string.

-spec find_value(atom(), my_type()) -> string().
> find_value(Key, State) when is_atom(Key) ->
>     #{Key := Value} = State,
>     Value.

Using dialyzer analysis the file.   nothing happens.
dialyzer say there is no error for this file.

I know maps are dynamic,  my_type() just meas this map must have a integer
key associated with a string value.
But not limit to add other type key and value in the map.

My question is that Is it possible limit the map types of key and value ?
So dialyzer can find the match error in my program.

My GitHub
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160923/ff61ccd8/attachment.html>

More information about the erlang-questions mailing list