home
/
code
/
hope.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e492ea1
)
Add result type module and define pipe.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 10 Nov 2013 16:44:38 +0000
(11:44 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 10 Nov 2013 16:44:38 +0000
(11:44 -0500)
src/hope_result.erl
[new file with mode: 0644]
patch
|
blob
diff --git a/src/hope_result.erl
b/src/hope_result.erl
new file mode 100644
(file)
index 0000000..
405f2e0
--- /dev/null
+++ b/
src/hope_result.erl
@@ -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.