-module(gxyz@function). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/gxyz/function.gleam"). -export([iff/3, iff_nil/2, ignore_result/2, freeze/1, freeze1/2, freeze2/3, freeze3/4, freeze4/5, freeze5/6]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -file("src/gxyz/function.gleam", 2). ?DOC(" calls an arity 0 function if the condition is True, otherwise returns the default value\n"). -spec iff(boolean(), fun(() -> EML), EML) -> EML. iff(Condition, F, Default) -> case Condition of true -> F(); _ -> Default end. -file("src/gxyz/function.gleam", 10). ?DOC(" calls an arity 0 function if the condition is True, and returns Nil\n"). -spec iff_nil(boolean(), fun(() -> nil)) -> nil. iff_nil(Condition, F) -> iff(Condition, F, nil). -file("src/gxyz/function.gleam", 15). ?DOC(" calls an arity 0 function if the condition is True, ignores the Result and returns Nil\n"). -spec ignore_result(boolean(), fun(() -> {ok, any()} | {error, any()})) -> nil. ignore_result(Condition, F) -> case Condition of true -> _ = F(), nil; _ -> nil end. -file("src/gxyz/function.gleam", 26). ?DOC(" freezes a value as an arity 0 function\n"). -spec freeze(EMQ) -> fun(() -> EMQ). freeze(Value) -> fun() -> Value end. -file("src/gxyz/function.gleam", 31). ?DOC(" freezes an arity 1 function and it's arg as an arity 0 function\n"). -spec freeze1(fun((EMR) -> EMS), EMR) -> fun(() -> EMS). freeze1(Fun, A) -> fun() -> Fun(A) end. -file("src/gxyz/function.gleam", 36). ?DOC(" freezes an arity 2 function and it's arg as an arity 0 function\n"). -spec freeze2(fun((EMU, EMV) -> EMW), EMU, EMV) -> fun(() -> EMW). freeze2(Fun, A, B) -> fun() -> Fun(A, B) end. -file("src/gxyz/function.gleam", 41). ?DOC(" freezes an arity 3 function and it's arg as an arity 0 function\n"). -spec freeze3(fun((EMZ, ENA, ENB) -> ENC), EMZ, ENA, ENB) -> fun(() -> ENC). freeze3(Fun, A, B, C) -> fun() -> Fun(A, B, C) end. -file("src/gxyz/function.gleam", 46). ?DOC(" freezes an arity 4 function and it's arg as an arity 0 function\n"). -spec freeze4(fun((ENG, ENH, ENI, ENJ) -> ENK), ENG, ENH, ENI, ENJ) -> fun(() -> ENK). freeze4(Fun, A, B, C, D) -> fun() -> Fun(A, B, C, D) end. -file("src/gxyz/function.gleam", 51). ?DOC(" freezes an arity 5 function and it's arg as an arity 0 function\n"). -spec freeze5(fun((ENP, ENQ, ENR, ENS, ENT) -> ENU), ENP, ENQ, ENR, ENS, ENT) -> fun(() -> ENU). freeze5(Fun, A, B, C, D, E) -> fun() -> Fun(A, B, C, D, E) end.