Define explicit map_ok as implementation of map 2.4.1
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 25 Mar 2015 14:15:21 +0000 (10:15 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 25 Mar 2015 14:16:55 +0000 (10:16 -0400)
in hope_result.

src/hope.app.src
src/hope_result.erl

index 78dd5bd..fee89b3 100644 (file)
@@ -1,7 +1,7 @@
 {application, hope,
  [
   {description, "Higher Order Programming in Erlang"},
-  {vsn, "2.4.0"},
+  {vsn, "2.4.1"},
   {registered, []},
   {applications, [
                   kernel,
index 930f2e0..0f9fb05 100644 (file)
@@ -10,7 +10,8 @@
 
 -export(
     [ return/1
-    , map/2
+    , map/2        % map/2 is alias for map_ok/2
+    , map_ok/2
     , map_error/2
     , tag_error/2
     , pipe/2
@@ -41,9 +42,14 @@ return(X) ->
 
 -spec map(t(A, Error), fun((A) -> (B))) ->
     t(B, Error).
-map({ok, X}, F) ->
+map({_, _}=T, F) ->
+    map_ok(T, F).
+
+-spec map_ok(t(A, Error), fun((A) -> (B))) ->
+    t(B, Error).
+map_ok({ok, X}, F) ->
     {ok, F(X)};
-map({error, _}=Error, _) ->
+map_ok({error, _}=Error, _) ->
     Error.
 
 -spec map_error(t(A, B), fun((B) -> (C))) ->
@@ -109,7 +115,7 @@ lift_map_exn(F, MapOk, MapError) when is_function(F, 1) ->
         % Applying maps separately as to not unintentionally catch an exception
         % raised in a map.
         case Result
-        of  {ok   , _}=Ok    -> map      (Ok   , MapOk)
+        of  {ok   , _}=Ok    -> map_ok   (Ok   , MapOk)
         ;   {error, _}=Error -> map_error(Error, MapError)
         end
     end.
This page took 0.025288 seconds and 4 git commands to generate.