Current section
Files
Jump to
Current section
Files
src/glemplate@result.erl
-module(glemplate@result).
-compile([no_auto_import, nowarn_unused_vars]).
-export([fold/3]).
-spec fold(list(GGU), GGW, fun((GGW, GGU) -> {ok, GGW} | {error, GGX})) -> {ok,
GGW} |
{error, GGX}.
fold(Items, Init, Folder) ->
gleam@list:fold_until(
Items,
{ok, Init},
fun(Acc, Item) ->
{ok, Acc@1} = case Acc of
{ok, _} -> Acc;
_assert_fail ->
erlang:error(#{gleam_error => assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"glemplate/result"/utf8>>,
function => <<"fold"/utf8>>,
line => 15})
end,
Res = Folder(Acc@1, Item),
case Res of
{ok, Next_acc} ->
{continue, {ok, Next_acc}};
{error, Error} ->
{stop, {error, Error}}
end
end
).