Add specs.
[hope.git] / src / hope_result.erl
1 -module(hope_result).
2
3
4 -export_type(
5 [ t/2
6 ]).
7
8 -export(
9 [ pipe/2
10 ]).
11
12
13 -type t(A, B) ::
14 {ok, A}
15 | {error, B}
16 .
17
18
19 -spec pipe([F], X) ->
20 t(Ok, Error)
21 when X :: any()
22 , Ok :: any()
23 , Error :: any()
24 , F :: fun((X) -> t(Ok, Error))
25 .
26 pipe([] , X) -> X;
27 pipe([F|Fs], X) ->
28 case F(X)
29 of {error, _}=E -> E
30 ; {ok, Y} -> pipe(Fs, Y)
31 end.
This page took 0.046022 seconds and 4 git commands to generate.