diff options
-rw-r--r-- | src/gleam/list.gleam | 8 | ||||
-rw-r--r-- | src/gleam/uri.gleam | 2 | ||||
-rw-r--r-- | test/gleam/function_test.gleam | 8 | ||||
-rw-r--r-- | test/gleam/list_test.gleam | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index a019653..e4063cd 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -163,16 +163,16 @@ pub fn contains(list: List(a), any elem: a) -> Bool { /// /// ## Examples /// -/// > head([]) +/// > first([]) /// Error(Nil) /// -/// > head([0]) +/// > first([0]) /// Ok(0) /// -/// > head([1, 2]) +/// > first([1, 2]) /// Ok(1) /// -pub fn head(list: List(a)) -> Result(a, Nil) { +pub fn first(list: List(a)) -> Result(a, Nil) { case list { [] -> Error(Nil) [x, .._] -> Ok(x) diff --git a/src/gleam/uri.gleam b/src/gleam/uri.gleam index 86e0c3a..b1d5ed1 100644 --- a/src/gleam/uri.gleam +++ b/src/gleam/uri.gleam @@ -116,7 +116,7 @@ if javascript { |> regex.compile(regex.Options(case_insensitive: True, multi_line: False)) |> result.nil_error |> result.map(regex.scan(_, string)) - |> result.then(list.head) + |> result.then(list.first) |> result.map(fn(m: regex.Match) { m.submatches }) |> result.unwrap([]) } diff --git a/test/gleam/function_test.gleam b/test/gleam/function_test.gleam index 0b3bd8c..e86beb3 100644 --- a/test/gleam/function_test.gleam +++ b/test/gleam/function_test.gleam @@ -18,17 +18,17 @@ pub fn compose_test() { // Takes a list of ints and returns the head as a string (if there is one, or // else "0" if there is not) - let head_to_string = - list.head + let first_to_string = + list.first |> function.compose(result.unwrap(_, 0)) |> function.compose(int.to_string) [1] - |> head_to_string + |> first_to_string |> should.equal("1") [] - |> head_to_string + |> first_to_string |> should.equal("0") } diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index b0d81c3..d505ddc 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -49,11 +49,11 @@ pub fn contains_test() { |> should.be_false } -pub fn head_test() { - list.head([0, 4, 5, 7]) +pub fn first_test() { + list.first([0, 4, 5, 7]) |> should.equal(Ok(0)) - list.head([]) + list.first([]) |> should.equal(Error(Nil)) } |