From: Siraaj Khandkar Date: Wed, 22 Apr 2015 16:23:14 +0000 (-0400) Subject: Return k/v list itself from validate_unique_presence. X-Git-Tag: 3.0.0^0 X-Git-Url: https://git.xandkar.net/?p=hope.git;a=commitdiff_plain;h=99fd18ae3aa61238700208a5f2b2959c1b1a2d80 Return k/v list itself from validate_unique_presence. Being that the main use-case is as part of a pipeline that manipulates said k/v list. --- diff --git a/src/hope.app.src b/src/hope.app.src index b16a643..9d0ece1 100644 --- a/src/hope.app.src +++ b/src/hope.app.src @@ -1,7 +1,7 @@ {application, hope, [ {description, "Higher Order Programming in Erlang"}, - {vsn, "2.5.0"}, + {vsn, "3.0.0"}, {registered, []}, {applications, [ kernel, diff --git a/src/hope_kv_list.erl b/src/hope_kv_list.erl index 2000098..7b25797 100644 --- a/src/hope_kv_list.erl +++ b/src/hope_kv_list.erl @@ -131,14 +131,16 @@ of_kv_list(List) -> % TODO: Decide if validation is to be done here. Do so if yes. List. --spec validate_unique_presence(t(K, _V), [K]) -> - hope_result:t(ok, [presence_error(K)]). +-spec validate_unique_presence(T, [K]) -> + hope_result:t(T, [presence_error(K)]) + when T :: t(K, _V). validate_unique_presence(T, KeysRequired) -> KeysOptional = [], validate_unique_presence(T, KeysRequired, KeysOptional). -spec validate_unique_presence(t(K, _V), [K], [K]) -> - hope_result:t(ok, [presence_error(K)]). + hope_result:t(T, [presence_error(K)]) + when T :: t(K, _V). validate_unique_presence(T, KeysRequired, KeysOptional) -> case find_unique_presence_violations(T, KeysRequired, KeysOptional) of #hope_kv_list_presence_violations @@ -146,7 +148,7 @@ validate_unique_presence(T, KeysRequired, KeysOptional) -> , keys_duplicated = [] , keys_unsupported = [] } -> - {ok, ok} + {ok, T} ; #hope_kv_list_presence_violations{}=Violations -> {error, presence_violations_to_list(Violations)} end. diff --git a/test/hope_kv_list_SUITE.erl b/test/hope_kv_list_SUITE.erl index 3ae5290..b986039 100644 --- a/test/hope_kv_list_SUITE.erl +++ b/test/hope_kv_list_SUITE.erl @@ -43,7 +43,7 @@ t_validate_unique_presence(_Cfg) -> DictDups = [{a, 1}, {b, 2}, {c, 3}, {a, 4}], DictMissing = [{a, 1}, {b, 2}], - {ok, ok} = + {ok, DictOk} = hope_kv_list:validate_unique_presence(DictOk, KeysRequired), #hope_kv_list_presence_violations { keys_missing = []