Current section
Files
Jump to
Current section
Files
src/gxyz@function.erl
-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(() -> ENI), ENI) -> ENI.
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(ENN) -> fun(() -> ENN).
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((ENO) -> ENP), ENO) -> fun(() -> ENP).
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((ENR, ENS) -> ENT), ENR, ENS) -> fun(() -> ENT).
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((ENW, ENX, ENY) -> ENZ), ENW, ENX, ENY) -> fun(() -> ENZ).
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((EOD, EOE, EOF, EOG) -> EOH), EOD, EOE, EOF, EOG) -> fun(() -> EOH).
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((EOM, EON, EOO, EOP, EOQ) -> EOR), EOM, EON, EOO, EOP, EOQ) -> fun(() -> EOR).
freeze5(Fun, A, B, C, D, E) ->
fun() -> Fun(A, B, C, D, E) end.