<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">While thinking about this problem I wrote the following spec:<div><br></div><div>-spec get_buttons() -></div><div><div>     {ok,{boolean(),{boolean(),{boolean(),{boolean(),[]}}}}}.</div><div><br></div><div>get_buttons() -></div><div>    {ok,{true,{true,{false,12}}}}.</div><div><br></div><div>This passed dialyzer!</div><div><br></div><div>The reason (I suppose) is that the analysis is limited to depth = 2 (or 3).</div><div>Running typer while commenting out the spec gives:</div><div><br></div><div>-spec get_buttons() -> {'ok',{'true',{'true',{_,_}}}}.</div><div><br></div><div>I guess this is the real reason why dialyzer can not handle fixed size lists (at least not a list with a length greater than 3)</div><div><br></div><div>/Tony</div><div><br></div><div><div>On 7 jul 2012, at 21:53, Richard Carlsson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 2012-07-07 13:57, Tony Rogvall wrote:<br><blockquote type="cite">Try this:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">     -type buttons() :: [boolean() | [boolean() | [boolean() |<br></blockquote><blockquote type="cite">[boolean() | []]]]].<br></blockquote><br>You certainly can _write_ it like that, just like you can write "1+1" instead of "2". To a tool like Dialyzer, it will still just be interpreted as a (nonempty) list of boolean(). The exact number of elements is not tracked. And if you for example try to say "[atom() | [integer() | []]]", it will just be the same as saying "nonempty list of atom()|integer()" - the order of occurrence of the element types is also not part of the list type.<br><br>    /Richard<br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></div></blockquote></div><br><div apple-content-edited="true">
<div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">"Installing applications can lead to corruption over time. </span><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; "><br></span></div><br class="Apple-interchange-newline">
</div>
<br></div></body></html>