Last active
August 4, 2016 13:50
-
-
Save dmitriid/e2f2cade18bc15176ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start() -> | |
case chain([ fun some_fun/1 | |
, fun some_fun/2 | |
.... | |
], SomeData) of | |
{error, _} = E -> E; | |
{ok, Output} -> Output | |
end. | |
some_fun1(Input0) -> | |
Input = modify_input(Input0), | |
{ok, Input}. | |
some_fun2(Input0) -> | |
try | |
{ok, weird_stuff(Input0)} | |
catch | |
_:Reason -> {error, Reason} | |
end. | |
chain([], Output) -> {ok, Output}; | |
chain([F|T], Input) -> | |
case F(Input) of | |
{ok, Output} -> chain(T, Output); | |
{error, _} = E -> E | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment