[erlang-questions] Tricky Dialyzer type

Raimo Niskanen raimo+erlang-questions@REDACTED
Mon Jul 20 09:21:13 CEST 2015

Hi all.

I need to specify a tricky type for Dialyzer (because all other options as
far as I can see are exhausted): a list with a type tag as first element,
and then the rest of the elements of one specific type.  Something like
this where I use the atom 'uint8' as type tag for the type uint8():

-type uint8() :: 0..255.
-type tagged_list_uint8() :: cons('uint8', [uint8()]).

But there is no cons() type in the type language what I can see.  I have
tried with "list('uint8', uint8())", "[uint8, uint8()]" and those are also
syntactically invalid.  I find no support for this in the type language
reference.  The closest I have come is:

-type tagged_list_uint8() :: nonempty_improper_list('uint8', [uint8()]).

But that would as I understand it allow for any number >= 1 of tag atoms
followed by uint8() elements.  I want to allow exactly one tag atom!

Ideas, anyone?

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list