[erlang-patches] Add a proplist() type

Ryan Zezeski <>
Tue May 24 15:40:58 CEST 2011

On Tue, May 24, 2011 at 4:38 AM, Richard Carlsson <
> wrote:

> On 05/23/2011 09:37 PM, Ryan Zezeski wrote:
>> Richard, I think specifying it as [property()] makes more sense because
>> [any()] is just a list, and at that point why are you using a proplist?
> The main use of the proplists module is to allow humans to specify a list
> of options to a function, in a readable way. The idea, when I wrote it, was
> that if a program wants to allow other things in its option list - for
> example, a naked integer might make sense in some cases - it should still be
> able to use the proplists module for most of its normal options, so the
> proplists functions should not crash on unexpected elements. As long as this
> is allowed, Dialyzer should not complain about arbitrary lists as input.
> On the other hand, if you constrain the input type to [property()], it's
> fairly simple to work around the Dialyzer warning by doing an initial pass
> over the list and convert the naked values to valid properties, e.g.,
> mapping integers to {some_tag, N}, before you pass the list to the proplists
> module.
>   Said another way, if the type was [any()] then I don't really see much
>> of a benefit of typing it at all.
> Knowing that it must be a (proper) list is obviously better than not
> knowing anything at all.
>   /Richard

Richard, yes, having an alias is better than nothing at all.  I spoke too
quickly there.

I guess everywhere I've seen proplists used it's as a map.  If it's type is
really just an alias for 'list()' then a function that returns 'proplist()'
could return a string and that seems counterintuitive to me.  My main use of
proplists was actually as a slightly more succinct option to lists:keyfind,
so take that as you may.  I could use the dict module (and I have plenty of
times before) but it's pretty print form is horrible/impossible to read.

Regardless, I think adding a proplist() type is a good step and we seem to
all agree there.  If you want to change the type to be an alias of list()
then that's fine, it would actually be more correct given what proplists
documentation says.  But, personally, I'd prefer it to be more restrictive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20110524/b0793a5c/attachment.html>

More information about the erlang-patches mailing list