[erlang-questions] specs for fixed length lists
Sat Jul 7 21:53:25 CEST 2012
On 2012-07-07 13:57, Tony Rogvall wrote:
> Try this:
> -type buttons() :: [boolean() | [boolean() | [boolean() |
> [boolean() | ]]]].
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.
More information about the erlang-questions