From 00ad62800f31b30dd6fd0c2d1972b69ae01a9a5d Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 17 Aug 2024 11:29:39 +0100 Subject: [PATCH] :recycle: Remove type annotations from lambdas. --- src/gleam_community/maths/arithmetics.gleam | 24 ++-- src/gleam_community/maths/combinatorics.gleam | 107 ++++++++---------- src/gleam_community/maths/metrics.gleam | 47 ++++---- src/gleam_community/maths/piecewise.gleam | 20 ++-- src/gleam_community/maths/predicates.gleam | 10 +- src/gleam_community/maths/sequences.gleam | 6 +- src/gleam_community/maths/special.gleam | 2 +- .../maths/predicates_test.gleam | 4 +- 8 files changed, 101 insertions(+), 119 deletions(-) diff --git a/src/gleam_community/maths/arithmetics.gleam b/src/gleam_community/maths/arithmetics.gleam index ab8eb12..540ba0d 100644 --- a/src/gleam_community/maths/arithmetics.gleam +++ b/src/gleam_community/maths/arithmetics.gleam @@ -244,7 +244,7 @@ fn find_divisors(n: Int) -> List(Int) { let assert Ok(sqrt_result) = elementary.square_root(nabs) let max = conversion.float_to_int(sqrt_result) + 1 list.range(2, max) - |> list.fold([1, n], fn(acc: List(Int), i: Int) -> List(Int) { + |> list.fold([1, n], fn(acc, i) { case n % i == 0 { True -> [i, n / i, ..acc] False -> acc @@ -340,10 +340,10 @@ pub fn float_sum(arr: List(Float), weights: option.Option(List(Float))) -> Float [], _ -> 0.0 _, option.None -> arr - |> list.fold(0.0, fn(acc: Float, a: Float) -> Float { a +. acc }) + |> list.fold(0.0, fn(acc, a) { a +. acc }) _, option.Some(warr) -> { list.zip(arr, warr) - |> list.fold(0.0, fn(acc: Float, a: #(Float, Float)) -> Float { + |> list.fold(0.0, fn(acc: Float, a) { pair.first(a) *. pair.second(a) +. acc }) } @@ -395,7 +395,7 @@ pub fn int_sum(arr: List(Int)) -> Int { [] -> 0 _ -> arr - |> list.fold(0, fn(acc: Int, a: Int) -> Int { a + acc }) + |> list.fold(0, fn(acc, a) { a + acc }) } } @@ -451,12 +451,12 @@ pub fn float_product( |> Ok _, option.None -> arr - |> list.fold(1.0, fn(acc: Float, a: Float) -> Float { a *. acc }) + |> list.fold(1.0, fn(acc, a) { a *. acc }) |> Ok _, option.Some(warr) -> { let results = list.zip(arr, warr) - |> list.map(fn(a: #(Float, Float)) -> Result(Float, String) { + |> list.map(fn(a) { pair.first(a) |> elementary.power(pair.second(a)) }) @@ -464,7 +464,7 @@ pub fn float_product( case results { Ok(prods) -> prods - |> list.fold(1.0, fn(acc: Float, a: Float) -> Float { a *. acc }) + |> list.fold(1.0, fn(acc, a) { a *. acc }) |> Ok Error(msg) -> msg @@ -519,7 +519,7 @@ pub fn int_product(arr: List(Int)) -> Int { [] -> 1 _ -> arr - |> list.fold(1, fn(acc: Int, a: Int) -> Int { a * acc }) + |> list.fold(1, fn(acc, a) { a * acc }) } } @@ -569,7 +569,7 @@ pub fn float_cumulative_sum(arr: List(Float)) -> List(Float) { [] -> [] _ -> arr - |> list.scan(0.0, fn(acc: Float, a: Float) -> Float { a +. acc }) + |> list.scan(0.0, fn(acc, a) { a +. acc }) } } @@ -619,7 +619,7 @@ pub fn int_cumulative_sum(arr: List(Int)) -> List(Int) { [] -> [] _ -> arr - |> list.scan(0, fn(acc: Int, a: Int) -> Int { a + acc }) + |> list.scan(0, fn(acc, a) { a + acc }) } } @@ -671,7 +671,7 @@ pub fn float_cumulative_product(arr: List(Float)) -> List(Float) { [] -> [] _ -> arr - |> list.scan(1.0, fn(acc: Float, a: Float) -> Float { a *. acc }) + |> list.scan(1.0, fn(acc, a) { a *. acc }) } } @@ -723,6 +723,6 @@ pub fn int_cumulative_product(arr: List(Int)) -> List(Int) { [] -> [] _ -> arr - |> list.scan(1, fn(acc: Int, a: Int) -> Int { a * acc }) + |> list.scan(1, fn(acc, a) { a * acc }) } } diff --git a/src/gleam_community/maths/combinatorics.gleam b/src/gleam_community/maths/combinatorics.gleam index b026c4d..b6a6606 100644 --- a/src/gleam_community/maths/combinatorics.gleam +++ b/src/gleam_community/maths/combinatorics.gleam @@ -20,12 +20,12 @@ //// -//// +//// //// --- -//// -//// Combinatorics: A module that offers mathematical functions related to counting, arrangements, -//// and permutations/combinations. -//// +//// +//// Combinatorics: A module that offers mathematical functions related to counting, arrangements, +//// and permutations/combinations. +//// //// * **Combinatorial functions** //// * [`combination`](#combination) //// * [`factorial`](#factorial) @@ -33,7 +33,7 @@ //// * [`list_combination`](#list_combination) //// * [`list_permutation`](#list_permutation) //// * [`cartesian_product`](#cartesian_product) -//// +//// import gleam/iterator import gleam/list @@ -70,26 +70,26 @@ pub type CombinatoricsMode { /// Also known as the "stars and bars" problem in combinatorics. /// /// The implementation uses an efficient iterative multiplicative formula for computing the result. -/// +/// ///
/// Details -/// -/// A \\(k\\)-combination is a sequence of \\(k\\) elements selected from \\(n\\) elements where -/// the order of selection does not matter. For example, consider selecting 2 elements from a list +/// +/// A \\(k\\)-combination is a sequence of \\(k\\) elements selected from \\(n\\) elements where +/// the order of selection does not matter. For example, consider selecting 2 elements from a list /// of 3 elements: `["A", "B", "C"]`: -/// -/// - For \\(k\\)-combinations (without repetitions), where order does not matter, the possible +/// +/// - For \\(k\\)-combinations (without repetitions), where order does not matter, the possible /// selections are: /// - `["A", "B"]` /// - `["A", "C"]` /// - `["B", "C"]` /// -/// - For \\(k\\)-combinations (with repetitions), where order does not matter but elements can +/// - For \\(k\\)-combinations (with repetitions), where order does not matter but elements can /// repeat, the possible selections are: /// - `["A", "A"], ["A", "B"], ["A", "C"]` /// - `["B", "B"], ["B", "C"], ["C", "C"]` /// -/// - On the contrary, for \\(k\\)-permutations (without repetitions), the order matters, so the +/// - On the contrary, for \\(k\\)-permutations (without repetitions), the order matters, so the /// possible selections are: /// - `["A", "B"], ["B", "A"]` /// - `["A", "C"], ["C", "A"]` @@ -106,15 +106,15 @@ pub type CombinatoricsMode { /// // Invalid input gives an error /// combinatorics.combination(-1, 1, option.None) /// |> should.be_error() -/// +/// /// // Valid input: n = 4 and k = 0 /// combinatorics.combination(4, 0, option.Some(combinatorics.WithoutRepetitions)) /// |> should.equal(Ok(1)) -/// +/// /// // Valid input: k = n (n = 4, k = 4) /// combinatorics.combination(4, 4, option.Some(combinatorics.WithoutRepetitions)) /// |> should.equal(Ok(1)) -/// +/// /// // Valid input: combinations with repetition (n = 2, k = 3) /// combinatorics.combination(2, 3, option.Some(combinatorics.WithRepetitions)) /// |> should.equal(Ok(4)) @@ -125,7 +125,7 @@ pub type CombinatoricsMode { /// Back to top ↑ /// /// -/// +/// pub fn combination( n: Int, k: Int, @@ -161,7 +161,7 @@ fn combination_without_repetitions(n: Int, k: Int) -> Result(Int, String) { False -> n - k } list.range(1, min) - |> list.fold(1, fn(acc: Int, x: Int) -> Int { acc * { n + 1 - x } / x }) + |> list.fold(1, fn(acc, x) { acc * { n + 1 - x } / x }) |> Ok } } @@ -215,7 +215,7 @@ pub fn factorial(n) -> Result(Int, String) { |> Ok _ -> list.range(1, n) - |> list.fold(1, fn(acc: Int, x: Int) -> Int { acc * x }) + |> list.fold(1, fn(acc, x) { acc * x }) |> Ok } } @@ -227,50 +227,50 @@ pub fn factorial(n) -> Result(Int, String) { /// /// /// A combinatorial function for computing the number of \\(k\\)-permutations. -/// +/// /// **Without** repetitions: /// /// \\[ /// P(n, k) = \binom{n}{k} \cdot k! = \frac{n!}{(n - k)!} /// \\] -/// +/// /// **With** repetitions: -/// +/// /// \\[ /// P^*(n, k) = n^k /// \\] -/// +/// /// The implementation uses an efficient iterative multiplicative formula for computing the result. -/// +/// ///
/// Details -/// +/// /// A \\(k\\)-permutation (without repetitions) is a sequence of \\(k\\) elements selected from \ -/// \\(n\\) elements where the order of selection matters. For example, consider selecting 2 +/// \\(n\\) elements where the order of selection matters. For example, consider selecting 2 /// elements from a list of 3 elements: `["A", "B", "C"]`: -/// -/// - For \\(k\\)-permutations (without repetitions), the order matters, so the possible selections +/// +/// - For \\(k\\)-permutations (without repetitions), the order matters, so the possible selections /// are: /// - `["A", "B"], ["B", "A"]` /// - `["A", "C"], ["C", "A"]` /// - `["B", "C"], ["C", "B"]` -/// -/// - For \\(k\\)-permutations (with repetitions), the order also matters, but we have repeated +/// +/// - For \\(k\\)-permutations (with repetitions), the order also matters, but we have repeated /// selections: /// - `["A", "A"], ["A", "B"], ["A", "C"]` /// - `["B", "A"], ["B", "B"], ["B", "C"]` /// - `["C", "A"], ["C", "B"], ["C", "C"]` /// -/// - On the contrary, for \\(k\\)-combinations (without repetitions), where order does not matter, +/// - On the contrary, for \\(k\\)-combinations (without repetitions), where order does not matter, /// the possible selections are: /// - `["A", "B"]` /// - `["A", "C"]` /// - `["B", "C"]` ///
-/// +/// ///
/// Example: -/// +/// /// import gleam/option /// import gleeunit/should /// import gleam_community/maths/combinatorics @@ -325,7 +325,7 @@ fn permutation_without_repetitions(n: Int, k: Int) -> Result(Int, String) { } _, _ -> list.range(0, k - 1) - |> list.fold(1, fn(acc: Int, x: Int) -> Int { acc * { n - x } }) + |> list.fold(1, fn(acc, x) { acc * { n - x } }) |> Ok } } @@ -346,11 +346,11 @@ fn permutation_with_repetitions(n: Int, k: Int) -> Result(Int, String) { /// /// /// -/// Generates all possible combinations of \\(k\\) elements selected from a given list of size +/// Generates all possible combinations of \\(k\\) elements selected from a given list of size /// \\(n\\). /// -/// The function can handle cases with and without repetitions -/// (see more details [here](#combination)). Also, note that repeated elements are treated as +/// The function can handle cases with and without repetitions +/// (see more details [here](#combination)). Also, note that repeated elements are treated as /// distinct. /// ///
@@ -370,7 +370,7 @@ fn permutation_with_repetitions(n: Int, k: Int) -> Result(Int, String) { /// 3, /// option.Some(combinatorics.WithoutRepetitions), /// ) -/// +/// /// result /// |> iterator.to_list() /// |> set.from_list() @@ -476,11 +476,11 @@ fn do_list_combination_with_repetitions( /// /// /// -/// Generates all possible permutations of \\(k\\) elements selected from a given list of size +/// Generates all possible permutations of \\(k\\) elements selected from a given list of size /// \\(n\\). /// -/// The function can handle cases with and without repetitions -/// (see more details [here](#permutation)). Also, note that repeated elements are treated as +/// The function can handle cases with and without repetitions +/// (see more details [here](#permutation)). Also, note that repeated elements are treated as /// distinct. /// ///
@@ -500,7 +500,7 @@ fn do_list_combination_with_repetitions( /// 3, /// option.Some(combinatorics.WithoutRepetitions), /// ) -/// +/// /// result /// |> iterator.to_list() /// |> set.from_list() @@ -523,7 +523,7 @@ fn do_list_combination_with_repetitions( /// /// /// -/// +/// pub fn list_permutation( arr: List(a), k: Int, @@ -636,7 +636,7 @@ fn do_list_permutation_with_repetitions( /// set.from_list([]) /// |> combinatorics.cartesian_product(set.from_list([])) /// |> should.equal(set.from_list([])) -/// +/// /// // Cartesian product of two sets with numeric values /// set.from_list([1.0, 10.0]) /// |> combinatorics.cartesian_product(set.from_list([1.0, 2.0])) @@ -654,16 +654,9 @@ fn do_list_permutation_with_repetitions( /// pub fn cartesian_product(xset: set.Set(a), yset: set.Set(a)) -> set.Set(#(a, a)) { xset - |> set.fold( - set.new(), - fn(accumulator0: set.Set(#(a, a)), member0: a) -> set.Set(#(a, a)) { - set.fold( - yset, - accumulator0, - fn(accumulator1: set.Set(#(a, a)), member1: a) -> set.Set(#(a, a)) { - set.insert(accumulator1, #(member0, member1)) - }, - ) - }, - ) + |> set.fold(set.new(), fn(accumulator0: set.Set(#(a, a)), member0: a) { + set.fold(yset, accumulator0, fn(accumulator1: set.Set(#(a, a)), member1: a) { + set.insert(accumulator1, #(member0, member1)) + }) + }) } diff --git a/src/gleam_community/maths/metrics.gleam b/src/gleam_community/maths/metrics.gleam index 7f550c3..dd4dd7a 100644 --- a/src/gleam_community/maths/metrics.gleam +++ b/src/gleam_community/maths/metrics.gleam @@ -182,7 +182,7 @@ pub fn norm( _, option.None -> { let aggregate = arr - |> list.fold(0.0, fn(accumulator: Float, element: Float) -> Float { + |> list.fold(0.0, fn(accumulator, element) { let assert Ok(result) = piecewise.float_absolute_value(element) |> elementary.power(p) @@ -202,19 +202,16 @@ pub fn norm( let tuples = list.zip(arr, warr) let aggregate = tuples - |> list.fold( - 0.0, - fn(accumulator: Float, tuple: #(Float, Float)) -> Float { - let first_element = pair.first(tuple) - let second_element = pair.second(tuple) - let assert Ok(result) = - elementary.power( - piecewise.float_absolute_value(first_element), - p, - ) - second_element *. result +. accumulator - }, - ) + |> list.fold(0.0, fn(accumulator, tuple) { + let first_element = pair.first(tuple) + let second_element = pair.second(tuple) + let assert Ok(result) = + elementary.power( + piecewise.float_absolute_value(first_element), + p, + ) + second_element *. result +. accumulator + }) let assert Ok(result) = elementary.power(aggregate, 1.0 /. p) result |> Ok @@ -370,9 +367,7 @@ pub fn minkowski_distance( False -> { let differences = list.zip(xarr, yarr) - |> list.map(fn(tuple: #(Float, Float)) -> Float { - pair.first(tuple) -. pair.second(tuple) - }) + |> list.map(fn(tuple) { pair.first(tuple) -. pair.second(tuple) }) let assert Ok(result) = norm(differences, p, weights) result @@ -496,7 +491,7 @@ pub fn chebyshev_distance( |> Error Ok(_) -> { list.zip(xarr, yarr) - |> list.map(fn(tuple: #(Float, Float)) -> Float { + |> list.map(fn(tuple) { { pair.first(tuple) -. pair.second(tuple) } |> piecewise.float_absolute_value() }) @@ -553,9 +548,7 @@ pub fn mean(arr: List(Float)) -> Result(Float, String) { _ -> arr |> arithmetics.float_sum(option.None) - |> fn(a: Float) -> Float { - a /. conversion.int_to_float(list.length(arr)) - } + |> fn(a) { a /. conversion.int_to_float(list.length(arr)) } |> Ok } } @@ -684,12 +677,12 @@ pub fn variance(arr: List(Float), ddof: Int) -> Result(Float, String) { False -> { let assert Ok(mean) = mean(arr) arr - |> list.map(fn(a: Float) -> Float { + |> list.map(fn(a) { let assert Ok(result) = elementary.power(a -. mean, 2.0) result }) |> arithmetics.float_sum(option.None) - |> fn(a: Float) -> Float { + |> fn(a) { a /. { conversion.int_to_float(list.length(arr)) @@ -1094,9 +1087,7 @@ pub fn cosine_similarity( let numerator_elements = zipped_arr - |> list.map(fn(tuple: #(Float, Float)) -> Float { - pair.first(tuple) *. pair.second(tuple) - }) + |> list.map(fn(tuple) { pair.first(tuple) *. pair.second(tuple) }) case weights { option.None -> { @@ -1284,14 +1275,14 @@ pub fn braycurtis_distance( let zipped_arr = list.zip(xarr, yarr) let numerator_elements = zipped_arr - |> list.map(fn(tuple: #(Float, Float)) -> Float { + |> list.map(fn(tuple) { piecewise.float_absolute_value({ pair.first(tuple) -. pair.second(tuple) }) }) let denominator_elements = zipped_arr - |> list.map(fn(tuple: #(Float, Float)) -> Float { + |> list.map(fn(tuple) { piecewise.float_absolute_value({ pair.first(tuple) +. pair.second(tuple) }) diff --git a/src/gleam_community/maths/piecewise.gleam b/src/gleam_community/maths/piecewise.gleam index d7e8a3c..fdfc4fb 100644 --- a/src/gleam_community/maths/piecewise.gleam +++ b/src/gleam_community/maths/piecewise.gleam @@ -823,7 +823,7 @@ pub fn int_flip_sign(x: Int) -> Int { /// /// /// -pub fn minimum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a { +pub fn minimum(x: a, y: a, compare: fn(a, a) -> order.Order) { case compare(x, y) { order.Lt -> x order.Eq -> x @@ -869,7 +869,7 @@ pub fn minimum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a { /// /// /// -pub fn maximum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a { +pub fn maximum(x: a, y: a, compare: fn(a, a) -> order.Order) { case compare(x, y) { order.Lt -> y order.Eq -> y @@ -909,7 +909,7 @@ pub fn maximum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a { /// /// /// -pub fn minmax(x: a, y: a, compare: fn(a, a) -> order.Order) -> #(a, a) { +pub fn minmax(x: a, y: a, compare: fn(a, a) -> order.Order) { #(minimum(x, y, compare), maximum(x, y, compare)) } @@ -956,7 +956,7 @@ pub fn list_minimum( |> Error [x, ..rest] -> Ok( - list.fold(rest, x, fn(acc: a, element: a) { + list.fold(rest, x, fn(acc, element) { case compare(element, acc) { order.Lt -> element _ -> acc @@ -1010,7 +1010,7 @@ pub fn list_maximum( |> Error [x, ..rest] -> Ok( - list.fold(rest, x, fn(acc: a, element: a) { + list.fold(rest, x, fn(acc, element) { case compare(acc, element) { order.Lt -> element _ -> acc @@ -1073,13 +1073,13 @@ pub fn arg_minimum( arr |> list_minimum(compare) arr - |> list.index_map(fn(element: a, index: Int) -> Int { + |> list.index_map(fn(element, index) { case compare(element, min) { order.Eq -> index _ -> -1 } }) - |> list.filter(fn(index: Int) -> Bool { + |> list.filter(fn(index) { case index { -1 -> False _ -> True @@ -1143,13 +1143,13 @@ pub fn arg_maximum( arr |> list_maximum(compare) arr - |> list.index_map(fn(element: a, index: Int) -> Int { + |> list.index_map(fn(element, index) { case compare(element, max) { order.Eq -> index _ -> -1 } }) - |> list.filter(fn(index: Int) -> Bool { + |> list.filter(fn(index) { case index { -1 -> False _ -> True @@ -1210,7 +1210,7 @@ pub fn extrema( |> Error [x, ..rest] -> Ok( - list.fold(rest, #(x, x), fn(acc: #(a, a), element: a) { + list.fold(rest, #(x, x), fn(acc, element) { let first = pair.first(acc) let second = pair.second(acc) case compare(element, first), compare(second, element) { diff --git a/src/gleam_community/maths/predicates.gleam b/src/gleam_community/maths/predicates.gleam index eca553e..4681e3b 100644 --- a/src/gleam_community/maths/predicates.gleam +++ b/src/gleam_community/maths/predicates.gleam @@ -135,11 +135,11 @@ fn float_absolute_difference(a: Float, b: Float) -> Float { /// let rtol = 0.01 /// let atol = 0.10 /// predicates.all_close(xarr, yarr, rtol, atol) -/// |> fn(zarr: Result(List(Bool), String)) -> Result(Bool, Nil) { +/// |> fn(zarr), String)) { /// case zarr { /// Ok(arr) -> /// arr -/// |> list.all(fn(a: Bool) -> Bool { a }) +/// |> list.all(fn(a) { a }) /// |> Ok /// _ -> Nil |> Error /// } @@ -168,9 +168,7 @@ pub fn all_close( |> Error True -> list.zip(xarr, yarr) - |> list.map(fn(z: #(Float, Float)) -> Bool { - is_close(pair.first(z), pair.second(z), rtol, atol) - }) + |> list.map(fn(z) { is_close(pair.first(z), pair.second(z), rtol, atol) }) |> Ok } } @@ -304,7 +302,7 @@ fn do_sum(arr: List(Int)) -> Int { [] -> 0 _ -> arr - |> list.fold(0, fn(acc: Int, a: Int) -> Int { a + acc }) + |> list.fold(0, fn(acc, a) { a + acc }) } } diff --git a/src/gleam_community/maths/sequences.gleam b/src/gleam_community/maths/sequences.gleam index 8385047..62c5301 100644 --- a/src/gleam_community/maths/sequences.gleam +++ b/src/gleam_community/maths/sequences.gleam @@ -102,7 +102,7 @@ pub fn arange( |> conversion.float_to_int() iterator.range(0, num - 1) - |> iterator.map(fn(i: Int) { + |> iterator.map(fn(i) { start +. conversion.int_to_float(i) *. step_abs *. direction }) } @@ -179,7 +179,7 @@ pub fn linear_space( case num > 0 { True -> { iterator.range(0, num - 1) - |> iterator.map(fn(i: Int) -> Float { + |> iterator.map(fn(i) { start +. conversion.int_to_float(i) *. increment *. direction }) |> Ok @@ -246,7 +246,7 @@ pub fn logarithmic_space( True -> { let assert Ok(linspace) = linear_space(start, stop, num, endpoint) linspace - |> iterator.map(fn(i: Float) -> Float { + |> iterator.map(fn(i) { let assert Ok(result) = elementary.power(base, i) result }) diff --git a/src/gleam_community/maths/special.gleam b/src/gleam_community/maths/special.gleam index 28b098c..a3f0136 100644 --- a/src/gleam_community/maths/special.gleam +++ b/src/gleam_community/maths/special.gleam @@ -132,7 +132,7 @@ fn gamma_lanczos(x: Float) -> Float { False -> { let z = x -. 1.0 let x = - list.index_fold(lanczos_p, 0.0, fn(acc: Float, v: Float, index: Int) { + list.index_fold(lanczos_p, 0.0, fn(acc, v, index) { case index > 0 { True -> acc +. v /. { z +. conversion.int_to_float(index) } False -> v diff --git a/test/gleam_community/maths/predicates_test.gleam b/test/gleam_community/maths/predicates_test.gleam index 0248fcf..c9e2c5f 100644 --- a/test/gleam_community/maths/predicates_test.gleam +++ b/test/gleam_community/maths/predicates_test.gleam @@ -23,11 +23,11 @@ pub fn float_list_all_close_test() { let rtol = 0.01 let atol = 0.1 predicates.all_close(xarr, yarr, rtol, atol) - |> fn(zarr: Result(List(Bool), String)) -> Result(Bool, Nil) { + |> fn(zarr) { case zarr { Ok(arr) -> arr - |> list.all(fn(a: Bool) -> Bool { a }) + |> list.all(fn(a) { a }) |> Ok _ -> Nil