aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiacomo Cavalieri <giacomo.cavalieri@icloud.com>2023-12-31 21:46:42 +0100
committerLouis Pilfold <louis@lpil.uk>2024-01-02 17:08:28 +0000
commit9300af1e6bee2459606bc45b781d129649c85ecb (patch)
treebab5e9699cdfa31291191502b3a4a7922c16a9de /src
parent2b206fe7accc9f391e39b773506a005146f11b60 (diff)
downloadgleam_stdlib-9300af1e6bee2459606bc45b781d129649c85ecb.tar.gz
gleam_stdlib-9300af1e6bee2459606bc45b781d129649c85ecb.zip
function doc examples
Diffstat (limited to 'src')
-rw-r--r--src/gleam/function.gleam27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/gleam/function.gleam b/src/gleam/function.gleam
index daa997d..7a438a3 100644
--- a/src/gleam/function.gleam
+++ b/src/gleam/function.gleam
@@ -18,24 +18,24 @@ pub fn compose(fun1: fn(a) -> b, fun2: fn(b) -> c) -> fn(a) -> c {
/// and producing a sequence of `n` single-argument functions. Given:
///
/// ```gleam
-/// > fn my_fun(i: Int, s: String) -> String { ... }
+/// fn my_fun(i: Int, s: String) -> String { ... }
/// ```
///
/// …calling `curry2(my_fun)` would return the curried equivalent, like so:
///
/// ```gleam
-/// > curry2(my_fun)
-/// fn(Int) -> fn(String) -> String
+/// curry2(my_fun)
+/// // fn(Int) -> fn(String) -> String
/// ```
///
/// Currying is useful when you want to partially apply a function with
/// some arguments and then pass it somewhere else, for example:
///
/// ```gleam
-/// > import gleam/list
-/// > let multiply = curry2(fn(x, y) { x * y })
-/// > let doubles = list.map([1, 2, 3], multiply(2))
-/// [2, 4, 6]
+/// import gleam/list
+/// let multiply = curry2(fn(x, y) { x * y })
+/// list.map([1, 2, 3], multiply(2))
+/// // -> [2, 4, 6]
/// ```
///
pub fn curry2(fun: fn(a, b) -> value) {
@@ -128,13 +128,12 @@ pub fn tap(arg: a, effect: fn(a) -> b) -> a {
/// ## Example
///
/// ```gleam
-/// > let doubler = fn() {
-/// > fn(x: Int) { x * 2 }
-/// > }
-/// >
-/// > doubler()
-/// > |> apply1(2)
-/// 4
+/// let doubler = fn() {
+/// fn(x: Int) { x * 2 }
+/// }
+///
+/// doubler() |> apply1(2)
+/// // -> 4
/// ```
///
pub fn apply1(fun: fn(a) -> value, arg1: a) -> value {