diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/function.gleam | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gleam/function.gleam b/src/gleam/function.gleam index 5aebb76..007eded 100644 --- a/src/gleam/function.gleam +++ b/src/gleam/function.gleam @@ -52,9 +52,18 @@ pub fn identity(x: a) -> a { x } -/// A function that takes a single argument and returns a new function that +/// Takes a single argument and returns a new function that /// ignores its argument and always returns the input value. /// pub fn constant(value: a) -> fn(b) -> a { fn(_) { value } } + +/// Takes a function with a single argument +/// calls that function with that argument +/// and returns that argument instead of the function return value. +/// Useful for running synchronous side effects in a pipeline. +pub fn tap (arg, effect: fn (a) -> b) -> a { + effect(arg) + arg +} |