Skip to content

Commit c5d0ede

Browse files
committed
Remove deprecated
1 parent ced490f commit c5d0ede

File tree

9 files changed

+6
-253
lines changed

9 files changed

+6
-253
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Unreleased
44

55
- Improved the precision of `float.to_precision`.
6+
- The deprecated `function.compose`, `function.constant`, `function.apply*`,
7+
`function.curry*`, `result.nil_error`, `list.concat`, `bool.compare`, and
8+
`bool.to_int` functions have been removed.
69

710
## v0.51.0 - 2024-12-22
811

src/gleam/bool.gleam

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//// field consider having a `role: SchoolRole` field where `SchoolRole` is a custom
77
//// type that can be either `Student` or `Teacher`.
88

9-
import gleam/order.{type Order}
10-
119
/// Returns the and of two bools, but it evaluates both arguments.
1210
///
1311
/// It's the function equivalent of the `&&` operator.
@@ -192,24 +190,6 @@ pub fn exclusive_nor(a: Bool, b: Bool) -> Bool {
192190
a == b
193191
}
194192

195-
@deprecated("Please use a case expression to get the behaviour you desire")
196-
pub fn compare(a: Bool, with b: Bool) -> Order {
197-
case a, b {
198-
True, True -> order.Eq
199-
True, False -> order.Gt
200-
False, False -> order.Eq
201-
False, True -> order.Lt
202-
}
203-
}
204-
205-
@deprecated("Please use a case expression to get the behaviour you desire")
206-
pub fn to_int(bool: Bool) -> Int {
207-
case bool {
208-
False -> 0
209-
True -> 1
210-
}
211-
}
212-
213193
/// Returns a string representation of the given bool.
214194
///
215195
/// ## Examples

src/gleam/function.gleam

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
@deprecated("Use a fn literal instead, it is easier to understand")
2-
pub fn compose(fun1: fn(a) -> b, fun2: fn(b) -> c) -> fn(a) -> c {
3-
fn(a) { fun2(fun1(a)) }
4-
}
5-
6-
@deprecated("Use the anonymous function syntax instead")
7-
pub fn curry2(fun: fn(a, b) -> value) {
8-
fn(a) { fn(b) { fun(a, b) } }
9-
}
10-
11-
@deprecated("Use the anonymous function syntax instead")
12-
pub fn curry3(fun: fn(a, b, c) -> value) {
13-
fn(a) { fn(b) { fn(c) { fun(a, b, c) } } }
14-
}
15-
16-
@deprecated("Use the anonymous function syntax instead")
17-
pub fn curry4(fun: fn(a, b, c, d) -> value) {
18-
fn(a) { fn(b) { fn(c) { fn(d) { fun(a, b, c, d) } } } }
19-
}
20-
21-
@deprecated("Use the anonymous function syntax instead")
22-
pub fn curry5(fun: fn(a, b, c, d, e) -> value) {
23-
fn(a) { fn(b) { fn(c) { fn(d) { fn(e) { fun(a, b, c, d, e) } } } } }
24-
}
25-
26-
@deprecated("Use the anonymous function syntax instead")
27-
pub fn curry6(fun: fn(a, b, c, d, e, f) -> value) {
28-
fn(a) {
29-
fn(b) { fn(c) { fn(d) { fn(e) { fn(f) { fun(a, b, c, d, e, f) } } } } }
30-
}
31-
}
32-
331
/// Takes a function that takes two arguments and returns a new function that
342
/// takes the same two arguments, but in reverse order.
353
///
@@ -43,11 +11,6 @@ pub fn identity(x: a) -> a {
4311
x
4412
}
4513

46-
@deprecated("Use a fn literal instead, it is easier to understand")
47-
pub fn constant(value: a) -> fn(b) -> a {
48-
fn(_) { value }
49-
}
50-
5114
/// Takes an argument and a single function,
5215
/// calls that function with that argument
5316
/// and returns that argument instead of the function return value.
@@ -57,18 +20,3 @@ pub fn tap(arg: a, effect: fn(a) -> b) -> a {
5720
effect(arg)
5821
arg
5922
}
60-
61-
@deprecated("Use a fn literal instead, it is easier to understand")
62-
pub fn apply1(fun: fn(a) -> value, arg1: a) -> value {
63-
fun(arg1)
64-
}
65-
66-
@deprecated("Use a fn literal instead, it is easier to understand")
67-
pub fn apply2(fun: fn(a, b) -> value, arg1: a, arg2: b) -> value {
68-
fun(arg1, arg2)
69-
}
70-
71-
@deprecated("Use a fn literal instead, it is easier to understand")
72-
pub fn apply3(fun: fn(a, b, c) -> value, arg1: a, arg2: b, arg3: c) -> value {
73-
fun(arg1, arg2, arg3)
74-
}

src/gleam/list.gleam

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -679,27 +679,11 @@ fn reverse_and_prepend(list prefix: List(a), to suffix: List(a)) -> List(a) {
679679
}
680680
}
681681

682-
/// Joins a list of lists into a single list.
683-
///
684-
/// This function traverses all elements twice.
685-
///
686-
/// ## Examples
687-
///
688-
/// ```gleam
689-
/// concat([[1], [2, 3], []])
690-
/// // -> [1, 2, 3]
691-
/// ```
692-
///
693-
@deprecated("Use `list.flatten` instead.")
694-
pub fn concat(lists: List(List(a))) -> List(a) {
695-
concat_loop(lists, [])
696-
}
697-
698-
fn concat_loop(lists: List(List(a)), acc: List(a)) -> List(a) {
682+
fn flatten_loop(lists: List(List(a)), acc: List(a)) -> List(a) {
699683
case lists {
700684
[] -> reverse(acc)
701685
[list, ..further_lists] ->
702-
concat_loop(further_lists, reverse_and_prepend(list: list, to: acc))
686+
flatten_loop(further_lists, reverse_and_prepend(list: list, to: acc))
703687
}
704688
}
705689

@@ -716,7 +700,7 @@ fn concat_loop(lists: List(List(a)), acc: List(a)) -> List(a) {
716700
/// ```
717701
///
718702
pub fn flatten(lists: List(List(a))) -> List(a) {
719-
concat_loop(lists, [])
703+
flatten_loop(lists, [])
720704
}
721705

722706
/// Maps the list with the given function into a list of lists, and then flattens it.

src/gleam/result.gleam

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,6 @@ pub fn unwrap_both(result: Result(a, a)) -> a {
262262
}
263263
}
264264

265-
/// Transforms any error into `Error(Nil)`.
266-
///
267-
/// ## Examples
268-
///
269-
/// ```gleam
270-
/// nil_error(Error(1))
271-
/// // -> Error(Nil)
272-
/// ```
273-
///
274-
/// ```gleam
275-
/// nil_error(Ok(1))
276-
/// // -> Ok(1)
277-
/// ```
278-
///
279-
@deprecated("Use `result.replace_error` with the `Nil` value instead")
280-
pub fn nil_error(result: Result(a, e)) -> Result(a, Nil) {
281-
replace_error(result, Nil)
282-
}
283-
284265
/// Returns the first value if it is `Ok`, otherwise returns the second value.
285266
///
286267
/// ## Examples

test/gleam/bool_test.gleam

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import gleam/bool
2-
import gleam/order
32
import gleam/should
43

54
pub fn and_test() {
@@ -98,28 +97,6 @@ pub fn exclusive_nor_test() {
9897
|> should.be_true
9998
}
10099

101-
pub fn compare_test() {
102-
bool.compare(True, True)
103-
|> should.equal(order.Eq)
104-
105-
bool.compare(True, False)
106-
|> should.equal(order.Gt)
107-
108-
bool.compare(False, False)
109-
|> should.equal(order.Eq)
110-
111-
bool.compare(False, True)
112-
|> should.equal(order.Lt)
113-
}
114-
115-
pub fn to_int_test() {
116-
bool.to_int(True)
117-
|> should.equal(1)
118-
119-
bool.to_int(False)
120-
|> should.equal(0)
121-
}
122-
123100
pub fn to_string_test() {
124101
bool.to_string(True)
125102
|> should.equal("True")

test/gleam/function_test.gleam

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,6 @@ import gleam/int
33
import gleam/should
44
import gleam/string
55

6-
pub fn curry2_test() {
7-
let fun = fn(a, b) { a + b }
8-
let curried = function.curry2(fun)
9-
10-
curried(1)(2)
11-
|> should.equal(3)
12-
}
13-
14-
pub fn curry3_test() {
15-
let fun = fn(a, b, c) { a + b + c }
16-
let curried = function.curry3(fun)
17-
18-
curried(1)(2)(4)
19-
|> should.equal(7)
20-
}
21-
22-
pub fn curry4_test() {
23-
let fun = fn(a, b, c, d) { a + b + c + d }
24-
let curried = function.curry4(fun)
25-
26-
curried(1)(2)(4)(8)
27-
|> should.equal(15)
28-
}
29-
30-
pub fn curry5_test() {
31-
let fun = fn(a, b, c, d, e) { a + b + c + d + e }
32-
let curried = function.curry5(fun)
33-
34-
curried(1)(2)(4)(8)(16)
35-
|> should.equal(31)
36-
}
37-
38-
pub fn curry6_test() {
39-
let fun = fn(a, b, c, d, e, f) { a + b + c + d + e + f }
40-
let curried = function.curry6(fun)
41-
42-
curried(1)(2)(4)(8)(16)(32)
43-
|> should.equal(63)
44-
}
45-
466
pub fn flip_test() {
477
let fun = fn(s: String, i: Int) {
488
s
@@ -87,48 +47,3 @@ pub fn tap_test() {
8747
})
8848
|> should.equal("Thanks Joe & Louis")
8949
}
90-
91-
pub fn apply1_test() {
92-
let fun = fn(x1) { x1 }
93-
94-
fun
95-
|> function.apply1(1)
96-
|> should.equal(1)
97-
}
98-
99-
pub fn apply2_test() {
100-
let fun = fn(x1, x2) { x1 + x2 }
101-
102-
fun
103-
|> function.apply2(1, 2)
104-
|> should.equal(3)
105-
}
106-
107-
pub fn apply3_test() {
108-
let fun = fn(x1, x2, x3) { x1 + x2 + x3 }
109-
110-
fun
111-
|> function.apply3(1, 2, 3)
112-
|> should.equal(6)
113-
}
114-
115-
pub fn apply3_maintains_arguments_orders_test() {
116-
let first = "first"
117-
let second = "second"
118-
let third = "third"
119-
let fun = fn(x1, x2, x3) {
120-
should.equal(x1, first)
121-
should.equal(x2, second)
122-
should.equal(x3, third)
123-
}
124-
125-
function.apply3(fun, first, second, third)
126-
}
127-
128-
pub fn apply3_supports_arguments_of_different_types() {
129-
let fun = fn(x1, _x2, _x3) { x1 }
130-
131-
fun
132-
|> function.apply3(1, 0.5, "3")
133-
|> should.equal(1)
134-
}

test/gleam/list_test.gleam

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -322,27 +322,6 @@ pub fn append_test() {
322322
|> list.append([1])
323323
}
324324

325-
pub fn concat_test() {
326-
list.concat([])
327-
|> should.equal([])
328-
329-
list.concat([[]])
330-
|> should.equal([])
331-
332-
list.concat([[], [], []])
333-
|> should.equal([])
334-
335-
list.concat([[1, 2], [], [3, 4]])
336-
|> should.equal([1, 2, 3, 4])
337-
// // TCO test
338-
// case recursion_test_cycles > 2 {
339-
// True ->
340-
// list.repeat([[1]], recursion_test_cycles / 50)
341-
// |> list.concat()
342-
// False -> []
343-
// }
344-
}
345-
346325
pub fn flatten_test() {
347326
list.flatten([])
348327
|> should.equal([])

test/gleam/result_test.gleam

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,6 @@ pub fn lazy_unwrap_test() {
136136
|> should.equal(50)
137137
}
138138

139-
pub fn nil_error_test() {
140-
Error("error_string")
141-
|> result.nil_error
142-
|> should.equal(Error(Nil))
143-
144-
Error(123)
145-
|> result.nil_error
146-
|> should.equal(Error(Nil))
147-
148-
Ok(1)
149-
|> result.nil_error
150-
|> should.equal(Ok(1))
151-
}
152-
153139
pub fn or_test() {
154140
Ok(1)
155141
|> result.or(Ok(2))

0 commit comments

Comments
 (0)