Commit | Line | Data |
---|---|---|
6731749b SK |
1 | -module(hope_result). |
2 | ||
3 | -export_type([ t/2 | |
4 | ]). | |
5 | ||
6 | -export([ pipe/2 | |
7 | ]). | |
8 | ||
9 | ||
10 | -type t(A, B) :: {ok, A} | {error, B}. | |
11 | ||
12 | ||
13 | pipe([] , X) -> X; | |
14 | pipe([F|Fs], X) -> | |
15 | case F(X) | |
16 | of {error, _}=E -> E | |
17 | ; {ok, Y} -> pipe(Fs, Y) | |
18 | end. |