[erlang-questions] Tricky Dialyzer type

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Mon Jul 20 15:19:02 CEST 2015


On Mon, Jul 20, 2015 at 11:49 AM, Raimo Niskanen <
raimo+erlang-questions@REDACTED> wrote:

> That's a pity.  For me it is just about two different kinds of wrappers.
> Obviously I am not a type expert.
>

The reason it is somewhat uncommon to want a list in a programming language
with type systems is that you can't get it to compile if the type check
fails. So in such a language, you would have been forced into the product
type with a tuple {uint8(), [ty()]} as the only way to represent this. The
wrong program would never have existed. Hence it would not be a problem.

Digging further, you eventually hit granite in the sense that you do need a
heterogenous list type. When that happens you are either out of luck, or
the type system is expressive enough to let you model it.

It is, generally, hard to graft a type system unto old code. You may have
to fall back to say that your data is [any()]. It is unsatisfactory, but at
least it is correct. I think that if you ask the 'typer' program, you get
the most specific type in the type lattice which dialyzer can figure out
from looking at the code base. If you use this type, you are at least not
incorrect, and you are at the limit of what the dialyzer understands,
currently.




-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150720/968fe898/attachment.htm>


More information about the erlang-questions mailing list