Return k/v list itself from validate_unique_presence. 3.0.0
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 22 Apr 2015 16:23:14 +0000 (12:23 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 22 Apr 2015 16:23:14 +0000 (12:23 -0400)
Being that the main use-case is as part of a pipeline that manipulates said k/v
list.

src/hope.app.src
src/hope_kv_list.erl
test/hope_kv_list_SUITE.erl

index b16a643..9d0ece1 100644 (file)
@@ -1,7 +1,7 @@
 {application, hope,
  [
   {description, "Higher Order Programming in Erlang"},
-  {vsn, "2.5.0"},
+  {vsn, "3.0.0"},
   {registered, []},
   {applications, [
                   kernel,
index 2000098..7b25797 100644 (file)
@@ -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.
index 3ae5290..b986039 100644 (file)
@@ -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     = []
This page took 0.020914 seconds and 4 git commands to generate.