Add result type module and define pipe.
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 10 Nov 2013 16:44:38 +0000 (11:44 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 10 Nov 2013 16:44:38 +0000 (11:44 -0500)
src/hope_result.erl [new file with mode: 0644]

diff --git a/src/hope_result.erl b/src/hope_result.erl
new file mode 100644 (file)
index 0000000..405f2e0
--- /dev/null
@@ -0,0 +1,18 @@
+-module(hope_result).
+
+-export_type([ t/2
+             ]).
+
+-export([ pipe/2
+        ]).
+
+
+-type t(A, B) :: {ok, A} | {error, B}.
+
+
+pipe([]    , X) -> X;
+pipe([F|Fs], X) ->
+    case F(X)
+    of  {error, _}=E -> E
+    ;   {ok, Y}      -> pipe(Fs, Y)
+    end.
This page took 0.03071 seconds and 4 git commands to generate.