, compose/1 % alias for compose_right/1
, compose_right/1
, compose_left/1
+ , thread/2
]).
-spec id(A) ->
compose_left(Fs) ->
compose_given_fold(Fs, fun lists:foldl/3).
+-spec thread([fun((A) -> B)], A) ->
+ B.
+thread(Fs, X) ->
+ F = compose_left(Fs),
+ F(X).
+
%% ============================================================================
[ t_specs/1
, t_id/1
, t_curry/1
- , t_compose/1
+ , t_compose_and_thread/1
]).
[ t_specs
, t_id
, t_curry
- , t_compose
+ , t_compose_and_thread
],
Properties = [parallel],
[ {?GROUP, Properties, Tests}
H = H2(b),
{a, b, c} = H(c).
-t_compose(_Cfg) ->
+t_compose_and_thread(_Cfg) ->
A2B = fun (a) -> b end,
B2C = fun (b) -> c end,
C2D = fun (c) -> d end,
Fs = [C2D, B2C, A2B],
d = (hope_fun:compose ( Fs ))(a),
d = (hope_fun:compose_right ( Fs ))(a),
- d = (hope_fun:compose_left (lists:reverse(Fs) ))(a).
+ d = (hope_fun:compose_left (lists:reverse(Fs) ))(a),
+ d = hope_fun:thread (lists:reverse(Fs), a).