<div dir="ltr"><div><br></div><div><br></div><div>According this document: <a href="http://erlang.org/doc/reference_manual/typespec.html">http://erlang.org/doc/reference_manual/typespec.html</a></div><div><br></div><div>I can define a map type like this:</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">-type my_type() :: #{integer() := string()}.</blockquote><div><br></div><div>I have a map called State, it's type is `my_type`, key type is integer, value type is string.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">-spec find_value(atom(), my_type()) -> string().<br>find_value(Key, State) when is_atom(Key) -><br> #{Key := Value} = State,<br> Value.</blockquote><div><br></div><div><br></div><div>Using dialyzer analysis the file. nothing happens.</div><div>dialyzer say there is no error for this file.</div><div><br></div><div><br></div><div>I know maps are dynamic, my_type() just meas this map must have a integer key associated with a string value.</div><div>But not limit to add other type key and value in the map.</div><div><br></div><div><br></div><div>My question is that Is it possible limit the map types of key and value ?</div><div>So dialyzer can find the match error in my program.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">My GitHub<br><a href="https://github.com/yueyoum" target="_blank">https://github.com/yueyoum</a><br><br></div></div>
</div>