diff options
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/gleam/bool.gleam | 20 | ||||
-rw-r--r-- | src/gleam/function.gleam | 52 | ||||
-rw-r--r-- | src/gleam/list.gleam | 22 | ||||
-rw-r--r-- | src/gleam/result.gleam | 19 | ||||
-rw-r--r-- | test/gleam/bool_test.gleam | 23 | ||||
-rw-r--r-- | test/gleam/function_test.gleam | 85 | ||||
-rw-r--r-- | test/gleam/list_test.gleam | 21 | ||||
-rw-r--r-- | test/gleam/result_test.gleam | 14 |
9 files changed, 6 insertions, 253 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 60a4d6f..60b92de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Unreleased - Improved the precision of `float.to_precision`. +- The deprecated `function.compose`, `function.constant`, `function.apply*`, + `function.curry*`, `result.nil_error`, `list.concat`, `bool.compare`, and + `bool.to_int` functions have been removed. ## v0.51.0 - 2024-12-22 diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam index 6c14d68..26a6ac4 100644 --- a/src/gleam/bool.gleam +++ b/src/gleam/bool.gleam @@ -6,8 +6,6 @@ //// field consider having a `role: SchoolRole` field where `SchoolRole` is a custom //// type that can be either `Student` or `Teacher`. -import gleam/order.{type Order} - /// Returns the and of two bools, but it evaluates both arguments. /// /// It's the function equivalent of the `&&` operator. @@ -192,24 +190,6 @@ pub fn exclusive_nor(a: Bool, b: Bool) -> Bool { a == b } -@deprecated("Please use a case expression to get the behaviour you desire") -pub fn compare(a: Bool, with b: Bool) -> Order { - case a, b { - True, True -> order.Eq - True, False -> order.Gt - False, False -> order.Eq - False, True -> order.Lt - } -} - -@deprecated("Please use a case expression to get the behaviour you desire") -pub fn to_int(bool: Bool) -> Int { - case bool { - False -> 0 - True -> 1 - } -} - /// Returns a string representation of the given bool. /// /// ## Examples diff --git a/src/gleam/function.gleam b/src/gleam/function.gleam index 824f373..8c2a571 100644 --- a/src/gleam/function.gleam +++ b/src/gleam/function.gleam @@ -1,35 +1,3 @@ -@deprecated("Use a fn literal instead, it is easier to understand") -pub fn compose(fun1: fn(a) -> b, fun2: fn(b) -> c) -> fn(a) -> c { - fn(a) { fun2(fun1(a)) } -} - -@deprecated("Use the anonymous function syntax instead") -pub fn curry2(fun: fn(a, b) -> value) { - fn(a) { fn(b) { fun(a, b) } } -} - -@deprecated("Use the anonymous function syntax instead") -pub fn curry3(fun: fn(a, b, c) -> value) { - fn(a) { fn(b) { fn(c) { fun(a, b, c) } } } -} - -@deprecated("Use the anonymous function syntax instead") -pub fn curry4(fun: fn(a, b, c, d) -> value) { - fn(a) { fn(b) { fn(c) { fn(d) { fun(a, b, c, d) } } } } -} - -@deprecated("Use the anonymous function syntax instead") -pub fn curry5(fun: fn(a, b, c, d, e) -> value) { - fn(a) { fn(b) { fn(c) { fn(d) { fn(e) { fun(a, b, c, d, e) } } } } } -} - -@deprecated("Use the anonymous function syntax instead") -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) } } } } } - } -} - /// Takes a function that takes two arguments and returns a new function that /// takes the same two arguments, but in reverse order. /// @@ -43,11 +11,6 @@ pub fn identity(x: a) -> a { x } -@deprecated("Use a fn literal instead, it is easier to understand") -pub fn constant(value: a) -> fn(b) -> a { - fn(_) { value } -} - /// Takes an argument and a single function, /// calls that function with that argument /// and returns that argument instead of the function return value. @@ -57,18 +20,3 @@ pub fn tap(arg: a, effect: fn(a) -> b) -> a { effect(arg) arg } - -@deprecated("Use a fn literal instead, it is easier to understand") -pub fn apply1(fun: fn(a) -> value, arg1: a) -> value { - fun(arg1) -} - -@deprecated("Use a fn literal instead, it is easier to understand") -pub fn apply2(fun: fn(a, b) -> value, arg1: a, arg2: b) -> value { - fun(arg1, arg2) -} - -@deprecated("Use a fn literal instead, it is easier to understand") -pub fn apply3(fun: fn(a, b, c) -> value, arg1: a, arg2: b, arg3: c) -> value { - fun(arg1, arg2, arg3) -} diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index c4211f8..b3ab350 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -679,27 +679,11 @@ fn reverse_and_prepend(list prefix: List(a), to suffix: List(a)) -> List(a) { } } -/// Joins a list of lists into a single list. -/// -/// This function traverses all elements twice. -/// -/// ## Examples -/// -/// ```gleam -/// concat([[1], [2, 3], []]) -/// // -> [1, 2, 3] -/// ``` -/// -@deprecated("Use `list.flatten` instead.") -pub fn concat(lists: List(List(a))) -> List(a) { - concat_loop(lists, []) -} - -fn concat_loop(lists: List(List(a)), acc: List(a)) -> List(a) { +fn flatten_loop(lists: List(List(a)), acc: List(a)) -> List(a) { case lists { [] -> reverse(acc) [list, ..further_lists] -> - concat_loop(further_lists, reverse_and_prepend(list: list, to: acc)) + flatten_loop(further_lists, reverse_and_prepend(list: list, to: acc)) } } @@ -716,7 +700,7 @@ fn concat_loop(lists: List(List(a)), acc: List(a)) -> List(a) { /// ``` /// pub fn flatten(lists: List(List(a))) -> List(a) { - concat_loop(lists, []) + flatten_loop(lists, []) } /// Maps the list with the given function into a list of lists, and then flattens it. diff --git a/src/gleam/result.gleam b/src/gleam/result.gleam index 0911f26..9e00082 100644 --- a/src/gleam/result.gleam +++ b/src/gleam/result.gleam @@ -262,25 +262,6 @@ pub fn unwrap_both(result: Result(a, a)) -> a { } } -/// Transforms any error into `Error(Nil)`. -/// -/// ## Examples -/// -/// ```gleam -/// nil_error(Error(1)) -/// // -> Error(Nil) -/// ``` -/// -/// ```gleam -/// nil_error(Ok(1)) -/// // -> Ok(1) -/// ``` -/// -@deprecated("Use `result.replace_error` with the `Nil` value instead") -pub fn nil_error(result: Result(a, e)) -> Result(a, Nil) { - replace_error(result, Nil) -} - /// Returns the first value if it is `Ok`, otherwise returns the second value. /// /// ## Examples diff --git a/test/gleam/bool_test.gleam b/test/gleam/bool_test.gleam index 03a3584..bd91eca 100644 --- a/test/gleam/bool_test.gleam +++ b/test/gleam/bool_test.gleam @@ -1,5 +1,4 @@ import gleam/bool -import gleam/order import gleam/should pub fn and_test() { @@ -98,28 +97,6 @@ pub fn exclusive_nor_test() { |> should.be_true } -pub fn compare_test() { - bool.compare(True, True) - |> should.equal(order.Eq) - - bool.compare(True, False) - |> should.equal(order.Gt) - - bool.compare(False, False) - |> should.equal(order.Eq) - - bool.compare(False, True) - |> should.equal(order.Lt) -} - -pub fn to_int_test() { - bool.to_int(True) - |> should.equal(1) - - bool.to_int(False) - |> should.equal(0) -} - pub fn to_string_test() { bool.to_string(True) |> should.equal("True") diff --git a/test/gleam/function_test.gleam b/test/gleam/function_test.gleam index 62c74bf..ecc5363 100644 --- a/test/gleam/function_test.gleam +++ b/test/gleam/function_test.gleam @@ -3,46 +3,6 @@ import gleam/int import gleam/should import gleam/string -pub fn curry2_test() { - let fun = fn(a, b) { a + b } - let curried = function.curry2(fun) - - curried(1)(2) - |> should.equal(3) -} - -pub fn curry3_test() { - let fun = fn(a, b, c) { a + b + c } - let curried = function.curry3(fun) - - curried(1)(2)(4) - |> should.equal(7) -} - -pub fn curry4_test() { - let fun = fn(a, b, c, d) { a + b + c + d } - let curried = function.curry4(fun) - - curried(1)(2)(4)(8) - |> should.equal(15) -} - -pub fn curry5_test() { - let fun = fn(a, b, c, d, e) { a + b + c + d + e } - let curried = function.curry5(fun) - - curried(1)(2)(4)(8)(16) - |> should.equal(31) -} - -pub fn curry6_test() { - let fun = fn(a, b, c, d, e, f) { a + b + c + d + e + f } - let curried = function.curry6(fun) - - curried(1)(2)(4)(8)(16)(32) - |> should.equal(63) -} - pub fn flip_test() { let fun = fn(s: String, i: Int) { s @@ -87,48 +47,3 @@ pub fn tap_test() { }) |> should.equal("Thanks Joe & Louis") } - -pub fn apply1_test() { - let fun = fn(x1) { x1 } - - fun - |> function.apply1(1) - |> should.equal(1) -} - -pub fn apply2_test() { - let fun = fn(x1, x2) { x1 + x2 } - - fun - |> function.apply2(1, 2) - |> should.equal(3) -} - -pub fn apply3_test() { - let fun = fn(x1, x2, x3) { x1 + x2 + x3 } - - fun - |> function.apply3(1, 2, 3) - |> should.equal(6) -} - -pub fn apply3_maintains_arguments_orders_test() { - let first = "first" - let second = "second" - let third = "third" - let fun = fn(x1, x2, x3) { - should.equal(x1, first) - should.equal(x2, second) - should.equal(x3, third) - } - - function.apply3(fun, first, second, third) -} - -pub fn apply3_supports_arguments_of_different_types() { - let fun = fn(x1, _x2, _x3) { x1 } - - fun - |> function.apply3(1, 0.5, "3") - |> should.equal(1) -} diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index e981a9d..14d02d7 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -322,27 +322,6 @@ pub fn append_test() { |> list.append([1]) } -pub fn concat_test() { - list.concat([]) - |> should.equal([]) - - list.concat([[]]) - |> should.equal([]) - - list.concat([[], [], []]) - |> should.equal([]) - - list.concat([[1, 2], [], [3, 4]]) - |> should.equal([1, 2, 3, 4]) - // // TCO test - // case recursion_test_cycles > 2 { - // True -> - // list.repeat([[1]], recursion_test_cycles / 50) - // |> list.concat() - // False -> [] - // } -} - pub fn flatten_test() { list.flatten([]) |> should.equal([]) diff --git a/test/gleam/result_test.gleam b/test/gleam/result_test.gleam index 8e4c831..4816fb6 100644 --- a/test/gleam/result_test.gleam +++ b/test/gleam/result_test.gleam @@ -136,20 +136,6 @@ pub fn lazy_unwrap_test() { |> should.equal(50) } -pub fn nil_error_test() { - Error("error_string") - |> result.nil_error - |> should.equal(Error(Nil)) - - Error(123) - |> result.nil_error - |> should.equal(Error(Nil)) - - Ok(1) - |> result.nil_error - |> should.equal(Ok(1)) -} - pub fn or_test() { Ok(1) |> result.or(Ok(2)) |