<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi!<div><br><div><div>On 6 jul 2012, at 18:28, Daniel Goertzen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">While working with lists of fixed length, I noted that type specification for such lists are conspicuously missing.  For example, the following does not work...<div><br></div><div><div><font face="'courier new', monospace">-spec get_buttons() -> {ok, [boolean(), boolean(), boolean(), boolean()]}.</font></div>
</div><div><br></div></blockquote>Try this:</div><div><br></div><div><div>    -type buttons() :: [boolean() | [boolean() | [boolean() | [boolean() | []]]]].</div><div><br></div><div>    -spec get_buttons() -> {ok, buttons()}.</div><div><br></div><div><div>    get_buttons() -></div><div>       [true | [false | [true | [false | [] ] ] ] ].</div><div><br></div><div>Of course my formatting of the get_buttons return value is intensional. You could write it</div><div>as normal [true,false,true,false].</div><div><br></div><div>You can of course write it as:</div><div><br></div><div>-spec get_buttons() -> {ok,[boolean() | [boolean() | [boolean() | [boolean() | []]]]] }.</div><div><br></div><div>Regards</div><div><br></div><div>/Tony</div></div><div><br></div><div><div><br></div></div><blockquote type="cite"><div>Is there some sneaky way to make this go?  Now I know you would normally use a tuple in this situation, but I will be using the lists module to process this data so I want to stick with lists.</div>
<div><br></div><div>I would love to see something like this for list specification...</div><div><div><br></div><div><br></div><div><div><font face="'courier new', monospace">  List :: list(Type)                        %% Proper list ([]-terminated)</font></div>
<div><font face="'courier new', monospace">+       | list(Type, Length)                %% Proper list of fixed size</font></div><div><font face="'courier new', monospace">+       | tlist(TList)                      %% Proper list specified like a tuple</font></div>
<div><font face="'courier new', monospace">        | improper_list(Type1, Type2)       %% Type1=contents, Type2=termination</font></div><div><font face="'courier new', monospace">        | maybe_improper_list(Type1, Type2) %% Type1 and Type2 as above</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">  Tuple :: tuple()                          %% stands for a tuple of any size</font></div><div><font face="'courier new', monospace">        | {}</font></div>
<div><font face="'courier new', monospace">        | {TList}</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">  TList :: Type</font></div>
<div><font face="'courier new', monospace">        | Type, TList</font></div><div><br></div><div><br></div><div>Thanks,</div><div><span style="font-family:arial,helvetica,sans-serif">Dan.</span></div></div></div><div>
<span style="font-family:arial,helvetica,sans-serif"><br></span></div>
_______________________________________________<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></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>