From e8bbdbcb15731c2963144880cb20120d45350a01 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Thu, 13 Dec 2012 16:07:09 +0100 Subject: Clean up some specs It is actually wrong to be using the same variable name to denote arguments and return values which have possibly different types. This patch corrects this. --- lib/stdlib/src/proplists.erl | 48 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'lib/stdlib/src/proplists.erl') diff --git a/lib/stdlib/src/proplists.erl b/lib/stdlib/src/proplists.erl index e3eda5d932..4df4669291 100644 --- a/lib/stdlib/src/proplists.erl +++ b/lib/stdlib/src/proplists.erl @@ -51,7 +51,7 @@ -export_type([property/0, proplist/0]). --type property() :: atom() | tuple(). +-type property() :: atom() | tuple(). -type proplist() :: [property()]. %% --------------------------------------------------------------------- @@ -63,8 +63,9 @@ %% %% @see property/2 --spec property(Property) -> Property when - Property :: property(). +-spec property(PropertyIn) -> PropertyOut when + PropertyIn :: property(), + PropertyOut :: property(). property({Key, true}) when is_atom(Key) -> Key; @@ -97,8 +98,9 @@ property(Key, Value) -> %% %% @see compact/1 --spec unfold(List) -> List when - List :: [term()]. +-spec unfold(ListIn) -> ListOut when + ListIn :: [term()], + ListOut :: [term()]. unfold([P | Ps]) -> if is_atom(P) -> @@ -115,8 +117,9 @@ unfold([]) -> %% @see unfold/1 %% @see property/1 --spec compact(List) -> List when - List :: [property()]. +-spec compact(ListIn) -> ListOut when + ListIn :: [property()], + ListOut :: [property()]. compact(List) -> [property(P) || P <- List]. @@ -199,7 +202,7 @@ is_defined(_Key, []) -> -spec get_value(Key, List) -> term() when Key :: term(), - List :: List::[term()]. + List :: [term()]. get_value(Key, List) -> get_value(Key, List, undefined). @@ -272,9 +275,10 @@ get_all_values(_Key, []) -> %% %% @see get_all_values/2 --spec append_values(Key, List) -> List when +-spec append_values(Key, ListIn) -> ListOut when Key :: term(), - List :: [term()]. + ListIn :: [term()], + ListOut :: [term()]. append_values(Key, [P | Ps]) -> if is_atom(P), P =:= Key -> @@ -357,7 +361,7 @@ get_keys([], Keys) -> -spec delete(Key, List) -> List when Key :: term(), - List::[term()]. + List :: [term()]. delete(Key, [P | Ps]) -> if is_atom(P), P =:= Key -> @@ -388,10 +392,11 @@ delete(_, []) -> %% @see substitute_negations/2 %% @see normalize/2 --spec substitute_aliases(Aliases, List) -> List when +-spec substitute_aliases(Aliases, ListIn) -> ListOut when Aliases :: [{Key, Key}], Key :: term(), - List::[term()]. + ListIn :: [term()], + ListOut :: [term()]. substitute_aliases(As, Props) -> [substitute_aliases_1(As, P) || P <- Props]. @@ -431,10 +436,11 @@ substitute_aliases_1([], P) -> %% @see substitute_aliases/2 %% @see normalize/2 --spec substitute_negations(Negations, List) -> List when +-spec substitute_negations(Negations, ListIn) -> ListOut when Negations :: [{Key, Key}], Key :: term(), - List :: [term()]. + ListIn :: [term()], + ListOut :: [term()]. substitute_negations(As, Props) -> [substitute_negations_1(As, P) || P <- Props]. @@ -497,9 +503,10 @@ substitute_negations_1([], P) -> %% %% @see normalize/2 --spec expand(Expansions, List) -> List when +-spec expand(Expansions, ListIn) -> ListOut when Expansions :: [{Property :: property(), Expansion :: [term()]}], - List :: [term()]. + ListIn :: [term()], + ListOut :: [term()]. expand(Es, Ps) when is_list(Ps) -> Es1 = [{property(P), V} || {P, V} <- Es], @@ -599,15 +606,16 @@ flatten([]) -> %% @see expand/2 %% @see compact/1 --spec normalize(List, Stages) -> List when - List :: [term()], +-spec normalize(ListIn, Stages) -> ListOut when + ListIn :: [term()], Stages :: [Operation], Operation :: {'aliases', Aliases} | {'negations', Negations} | {'expand', Expansions}, Aliases :: [{Key, Key}], Negations :: [{Key, Key}], - Expansions :: [{Property :: property(), Expansion :: [term()]}]. + Expansions :: [{Property :: property(), Expansion :: [term()]}], + ListOut :: [term()]. normalize(L, [{aliases, As} | Xs]) -> normalize(substitute_aliases(As, L), Xs); -- cgit v1.2.3 From 90b3eb809e0c399593c741b2281d89498e87b147 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Mon, 17 Dec 2012 11:09:15 +0100 Subject: Ensure that edocumentation and the xml file are in sync --- lib/stdlib/src/proplists.erl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/stdlib/src/proplists.erl') diff --git a/lib/stdlib/src/proplists.erl b/lib/stdlib/src/proplists.erl index 4df4669291..204f8e128c 100644 --- a/lib/stdlib/src/proplists.erl +++ b/lib/stdlib/src/proplists.erl @@ -57,9 +57,9 @@ %% --------------------------------------------------------------------- %% @doc Creates a normal form (minimal) representation of a property. If -%% P is {Key, true} where Key is -%% an atom, this returns Key, otherwise the whole term -%% P is returned. +%% PropertyIn is {Key, true} where +%% Key is an atom, this returns Key, otherwise +%% the whole term PropertyIn is returned. %% %% @see property/2 @@ -93,7 +93,7 @@ property(Key, Value) -> %% --------------------------------------------------------------------- -%% @doc Unfolds all occurences of atoms in List to tuples +%% @doc Unfolds all occurences of atoms in ListIn to tuples %% {Atom, true}. %% %% @see compact/1 @@ -112,7 +112,7 @@ unfold([]) -> []. %% @doc Minimizes the representation of all entries in the list. This is -%% equivalent to [property(P) || P <- List]. +%% equivalent to [property(P) || P <- ListIn]. %% %% @see unfold/1 %% @see property/1 @@ -121,8 +121,8 @@ unfold([]) -> ListIn :: [property()], ListOut :: [property()]. -compact(List) -> - [property(P) || P <- List]. +compact(ListIn) -> + [property(P) || P <- ListIn]. %% --------------------------------------------------------------------- @@ -378,7 +378,7 @@ delete(_, []) -> %% --------------------------------------------------------------------- %% @doc Substitutes keys of properties. For each entry in -%% List, if it is associated with some key K1 +%% ListIn, if it is associated with some key K1 %% such that {K1, K2} occurs in Aliases, the %% key of the entry is changed to Key2. If the same %% K1 occurs more than once in Aliases, only @@ -416,13 +416,13 @@ substitute_aliases_1([], P) -> %% --------------------------------------------------------------------- %% @doc Substitutes keys of boolean-valued properties and simultaneously -%% negates their values. For each entry in List, if it is +%% negates their values. For each entry in ListIn, if it is %% associated with some key K1 such that {K1, %% K2} occurs in Negations, then if the entry was %% {K1, true} it will be replaced with {K2, %% false}, otherwise it will be replaced with {K2, %% true}, thus changing the name of the option and simultaneously -%% negating the value given by get_bool(List). If the same +%% negating the value given by get_bool(ListIn). If the same %% K1 occurs more than once in Negations, only %% the first occurrence is used. %% @@ -472,11 +472,11 @@ substitute_negations_1([], P) -> %% @doc Expands particular properties to corresponding sets of %% properties (or other terms). For each pair {Property, %% Expansion} in Expansions, if E is -%% the first entry in List with the same key as +%% the first entry in ListIn with the same key as %% Property, and E and Property %% have equivalent normal forms, then E is replaced with %% the terms in Expansion, and any following entries with -%% the same key are deleted from List. +%% the same key are deleted from ListIn. %% %%

For example, the following expressions all return [fie, bar, %% baz, fum]: -- cgit v1.2.3