aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-04-05 12:52:39 +0200
committerLouis Pilfold <louis@lpil.uk>2022-04-06 10:58:14 +0100
commit9cc543b27b01740a4e9b6a9307ab0831992e08a2 (patch)
tree0a1205bf31e618d71d92a53a1de488f6558c3673 /src
parent3f036e797c7ac7cca7f3cde8095a2828e172976c (diff)
downloadgleam_stdlib-9cc543b27b01740a4e9b6a9307ab0831992e08a2.tar.gz
gleam_stdlib-9cc543b27b01740a4e9b6a9307ab0831992e08a2.zip
unify func doc style
Diffstat (limited to 'src')
-rw-r--r--src/gleam/function.gleam15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gleam/function.gleam b/src/gleam/function.gleam
index cda59fc..377518f 100644
--- a/src/gleam/function.gleam
+++ b/src/gleam/function.gleam
@@ -1,5 +1,5 @@
-/// Takes two functions and chains them together to form one function that takes
-/// the input from the first and returns the output of the second.
+/// Takes two functions and chains them together to form one function that
+/// takes the input from the first and returns the output of the second.
///
pub fn compose(fun1: fn(a) -> b, fun2: fn(b) -> c) -> fn(a) -> c {
fn(a) { fun2(fun1(a)) }
@@ -8,6 +8,7 @@ pub fn compose(fun1: fn(a) -> b, fun2: fn(b) -> c) -> fn(a) -> c {
/// Takes a function with arity two
/// and returns a curried equivalent.
/// `fn(a, b) -> c` becomes `fn(a) -> fn(b) -> c`.
+///
pub fn curry2(fun: fn(a, b) -> value) {
fn(a) { fn(b) { fun(a, b) } }
}
@@ -15,12 +16,14 @@ pub fn curry2(fun: fn(a, b) -> value) {
/// Takes a function with arity three
/// and returns a curried equivalent.
/// `fn(a, b, c) -> d` becomes `fn(a) -> fn(b) -> fn(c) -> d`.
+///
pub fn curry3(fun: fn(a, b, c) -> value) {
fn(a) { fn(b) { fn(c) { fun(a, b, c) } } }
}
/// Takes a function with arity four
/// and returns a curried equivalent.
+///
pub fn curry4(fun: fn(a, b, c, d) -> value) {
fn(a) { fn(b) { fn(c) { fn(d) { fun(a, b, c, d) } } } }
}
@@ -33,6 +36,7 @@ pub fn curry5(fun: fn(a, b, c, d, e) -> value) {
/// Takes a function with arity six
/// and returns a curried equivalent.
+///
pub fn curry6(fun: fn(a, b, c, d, e, f) -> value) {
fn(a) {
fn(b) { fn(c) { fn(d) { fn(e) { fn(f) { fun(a, b, c, d, e, f) } } } } }
@@ -46,7 +50,7 @@ pub fn flip(fun: fn(a, b) -> c) -> fn(b, a) -> c {
fn(b, a) { fun(a, b) }
}
-/// A function that always returns its input value.
+/// Takes a single argument and always returns its input value.
///
pub fn identity(x: a) -> a {
x
@@ -59,10 +63,11 @@ pub fn constant(value: a) -> fn(b) -> a {
fn(_) { value }
}
-/// Takes a function with a single argument
-/// calls that function with that argument
+/// Takes an argument and a single function,
+/// 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: a, effect: fn(a) -> b) -> a {
effect(arg)
arg