Skip to content

Commit fa71fd6

Browse files
JosephTLyonslpil
authored andcommitted
Consistently use pipes in existing pipe chains
1 parent cc3c4dd commit fa71fd6

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

src/gleam/bit_array.gleam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ fn decode64(a: String) -> Result(BitArray, Nil)
138138
/// with zero bits prior to being encoded.
139139
///
140140
pub fn base64_url_encode(input: BitArray, padding: Bool) -> String {
141-
base64_encode(input, padding)
141+
input
142+
|> base64_encode(padding)
142143
|> string.replace("+", "-")
143144
|> string.replace("/", "_")
144145
}

src/gleam/dynamic/decode.gleam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ fn index(
409409
) -> #(b, List(DecodeError)) {
410410
case path {
411411
[] -> {
412-
inner(data)
412+
data
413+
|> inner
413414
|> push_path(list.reverse(position))
414415
}
415416

src/gleam/int.gleam

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ pub fn absolute_value(x: Int) -> Int {
6565
/// ```
6666
///
6767
pub fn power(base: Int, of exponent: Float) -> Result(Float, Nil) {
68-
to_float(base)
68+
base
69+
|> to_float
6970
|> float.power(exponent)
7071
}
7172

@@ -84,7 +85,8 @@ pub fn power(base: Int, of exponent: Float) -> Result(Float, Nil) {
8485
/// ```
8586
///
8687
pub fn square_root(x: Int) -> Result(Float, Nil) {
87-
to_float(x)
88+
x
89+
|> to_float
8890
|> float.square_root()
8991
}
9092

src/gleam/list.gleam

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,8 @@ pub fn combinations(items: List(a), by n: Int) -> List(List(a)) {
21632163
0, _ -> [[]]
21642164
_, [] -> []
21652165
_, [first, ..rest] ->
2166-
combinations(rest, n - 1)
2166+
rest
2167+
|> combinations(n - 1)
21672168
|> map(fn(combination) { [first, ..combination] })
21682169
|> reverse
21692170
|> fold(combinations(rest, n), fn(acc, c) { [c, ..acc] })
@@ -2204,7 +2205,8 @@ fn combination_pairs_loop(items: List(a), acc: List(#(a, a))) -> List(#(a, a)) {
22042205
/// ```
22052206
///
22062207
pub fn interleave(list: List(List(a))) -> List(a) {
2207-
transpose(list)
2208+
list
2209+
|> transpose
22082210
|> flatten
22092211
}
22102212

src/gleam/string.gleam

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ pub fn pop_grapheme(string: String) -> Result(#(String, String), Nil)
621621
///
622622
@external(javascript, "../gleam_stdlib.mjs", "graphemes")
623623
pub fn to_graphemes(string: String) -> List(String) {
624-
to_graphemes_loop(string, [])
624+
string
625+
|> to_graphemes_loop([])
625626
|> list.reverse
626627
}
627628

@@ -852,7 +853,8 @@ pub fn capitalise(string: String) -> String {
852853
/// problems.
853854
///
854855
pub fn inspect(term: anything) -> String {
855-
do_inspect(term)
856+
term
857+
|> do_inspect
856858
|> string_tree.to_string
857859
}
858860

src/gleam/uri.gleam

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ pub fn merge(base: Uri, relative: Uri) -> Result(Uri, Nil) {
709709
case relative {
710710
Uri(host: Some(_), ..) -> {
711711
let path =
712-
string.split(relative.path, "/")
712+
relative.path
713+
|> string.split("/")
713714
|> remove_dot_segments()
714715
|> join_segments()
715716
let resolved =
@@ -731,7 +732,8 @@ pub fn merge(base: Uri, relative: Uri) -> Result(Uri, Nil) {
731732
let path_segments = case string.starts_with(relative.path, "/") {
732733
True -> string.split(relative.path, "/")
733734
False ->
734-
string.split(base.path, "/")
735+
base.path
736+
|> string.split("/")
735737
|> drop_last()
736738
|> list.append(string.split(relative.path, "/"))
737739
}

0 commit comments

Comments
 (0)