[erlang-questions] Is it possible to have nested parametrised types when the base type is opaque?

James Aimonetti james@REDACTED
Thu Dec 18 19:53:49 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 2014-12-18 07:32, James Fish a écrit :
> Hi all,
> 
> I am never one to doubt that dialyzer is correct, and I am wrong.
> In this case I am perplexed by the warning generated with nested
> parametrised types. For example if a module defines the type:
> 
> -type myqueue(Item) :: {myqueue, queue:queue({integer(), Item})}.
> 
> And another module wishes to use myqueue/1:
> 
> -spec in(integer(), myqueue(integer()) -> myqueue(integer()).
> 
> Dialyzer will warn that success typing has the second argument and
> result of the form {myqueue, queue:queue({integer(), any()})}. What
> is the subtlety that I am missing?
> 
> You can find two sample modules attached. One module with a
> parametrised queue and another with a parametrised "parametrised"
> queue using the first module. Dialyzer has alot of fun with the
> second module. If queue:queue() was not opaque no warnings are
> generated and if myqueue:myqueue() is not opaque an extra warning
> is generated.
> 
> Thank you,
> 
> James
> 
> 
> 
> _______________________________________________ erlang-questions
> mailing list erlang-questions@REDACTED 
> http://erlang.org/mailman/listinfo/erlang-questions
> 

It seems, in the parameterized version, you are inserting Item only,
not a tuple.

Compare myqueue.erl:

    #myqueue{queue=queue:in({1, Item}, Q)}.

to myqueue_params.erl:

    P#myqueue_params{myqueue=myqueue:in(Item, Q)}.

The first is a tuple and the second is an integer.

That's my initial reading, anyway.

- -- 
James Aimonetti
Lead Systems Architect / Impressionable Scallywag
"I thought I fixed that"

2600Hz | http://2600hz.com
sip:james@REDACTED
tel:415.886.7905
irc:mc_ @ freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUkyK9AAoJENTKa+JPXCVgtpAIAJkSgQcA98T1VYyZeTEqhU9t
B5D+aBf964qXqcTcFPJuquEhEBp59ULEj6A96OYc+QLiN0D1Lk8SdHy4YHdCtuSQ
HrIA1sVsTz6Jj3EgyqjwtMjCVco25ZQiDs1cT7jhGUKCi2OUIpjpgi6Vb+UwASfw
GVry3XJhobgNaH3xfDdx9h8S766k0B/JqtykK6fVbjoIJVxfnQ6yqz6w5604tjw1
VdIyPwml4oAxOndQe0gxiAP5A7P8AyjAs0TvpRMILOm7gtE3tj4JM2ouFgK7VjY4
aX8PGfoeKkazf4XJbuQSJXTODGikGLQSgnhmUz8Cd/MRKvnf4WCfaKl75JWPhl0=
=yQIn
-----END PGP SIGNATURE-----



More information about the erlang-questions mailing list