-export(
[ pipe/2
, lift_exn/1
+ , lift_exn/2
]).
{error, {Class, Reason}}
end
end.
+
+-spec lift_exn(F, Label) -> G
+ when F :: fun((A)-> B)
+ , G :: fun((A)-> t(B, {Label, {Class, Reason :: any()}}))
+ , Class :: error
+ | exit
+ | throw
+ .
+lift_exn(F, Label) when is_function(F, 1) ->
+ fun(X) ->
+ try
+ {ok, F(X)}
+ catch Class:Reason ->
+ {error, {Label, {Class, Reason}}}
+ end
+ end.