-module(go_over@util@util). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([iff/3, iff_nil/2, throwaway/2, hard_fail/2, has_flag/2, freeze1/2, freeze2/3]). -spec iff(boolean(), fun(() -> LEU), LEU) -> LEU. iff(V, F, Default) -> case V of true -> F(); _ -> Default end. -spec iff_nil(boolean(), fun(() -> nil)) -> nil. iff_nil(V, F) -> iff(V, F, nil). -spec throwaway(boolean(), fun(() -> {ok, any()} | {error, any()})) -> nil. throwaway(V, F) -> case V of true -> _ = F(), nil; _ -> nil end. -spec hard_fail({ok, LEZ} | {error, any()}, binary()) -> LEZ. hard_fail(Res, Msg) -> case Res of {ok, Val} -> Val; _ -> go_over@util@print:warning(<<"Error: "/utf8, Msg/binary>>), shellout_ffi:os_exit(1), erlang:error(#{gleam_error => panic, message => <<"unreachable"/utf8>>, module => <<"go_over/util/util"/utf8>>, function => <<"hard_fail"/utf8>>, line => 33}) end. -spec has_flag(list(binary()), binary()) -> boolean(). has_flag(Args, Name) -> gleam@list:any(Args, fun(Arg) -> Arg =:= (<<"--"/utf8, Name/binary>>) end). -spec freeze1(fun((LFE) -> LFF), LFE) -> fun(() -> LFF). freeze1(F, Arg1) -> fun() -> F(Arg1) end. -spec freeze2(fun((LFG, LFH) -> LFI), LFG, LFH) -> fun(() -> LFI). freeze2(F, Arg1, Arg2) -> fun() -> F(Arg1, Arg2) end.