Current section

Files

Jump to
gleam_stdlib src gleam@function.erl
Raw

src/gleam@function.erl

-module(gleam@function).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([flip/1, identity/1, tap/2]).
-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("/Users/louis/src/gleam/stdlib/src/gleam/function.gleam", 4).
?DOC(
" Takes a function that takes two arguments and returns a new function that\n"
" takes the same two arguments, but in reverse order.\n"
).
-spec flip(fun((EEF, EEG) -> EEH)) -> fun((EEG, EEF) -> EEH).
flip(Fun) ->
fun(B, A) -> Fun(A, B) end.
-file("/Users/louis/src/gleam/stdlib/src/gleam/function.gleam", 10).
?DOC(" Takes a single argument and always returns its input value.\n").
-spec identity(EEI) -> EEI.
identity(X) ->
X.
-file("/Users/louis/src/gleam/stdlib/src/gleam/function.gleam", 19).
?DOC(
" Takes an argument and a single function,\n"
" calls that function with that argument\n"
" and returns that argument instead of the function return value.\n"
" Useful for running synchronous side effects in a pipeline.\n"
).
-spec tap(EEJ, fun((EEJ) -> any())) -> EEJ.
tap(Arg, Effect) ->
Effect(Arg),
Arg.