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:
ed9905a
)
Add result:lift_exn/1
author
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 15 Jul 2014 01:08:20 +0000
(21:08 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 15 Jul 2014 01:08:20 +0000
(21:08 -0400)
src/hope_result.erl
patch
|
blob
|
blame
|
history
diff --git
a/src/hope_result.erl
b/src/hope_result.erl
index
5d0ea7e
..
1b217f8
100644
(file)
--- a/
src/hope_result.erl
+++ b/
src/hope_result.erl
@@
-7,6
+7,7
@@
-export(
[ pipe/2
+ , lift_exn/1
]).
@@
-29,3
+30,19
@@
pipe([F|Fs], X) ->
of {error, _}=E -> E
; {ok, Y} -> pipe(Fs, Y)
end.
+
+-spec lift_exn(F) -> G
+ when F :: fun((A)-> B)
+ , G :: fun((A)-> t(B, {Class, Reason :: any()}))
+ , Class :: error
+ | exit
+ | throw
+ .
+lift_exn(F) when is_function(F, 1) ->
+ fun(X) ->
+ try
+ {ok, F(X)}
+ catch Class:Reason ->
+ {error, {Class, Reason}}
+ end
+ end.
This page took
0.032183 seconds
and
4
git commands to generate.