Skip to content

Commit 8337243

Browse files
committed
Run Gleam v0.8 formatter
1 parent f31235e commit 8337243

23 files changed

+783
-866
lines changed

src/gleam/atom.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// user input into atoms) we may hit the max limit of atoms and cause the
1414
/// virtual machine to crash.
1515
///
16-
pub external type Atom;
16+
pub external type Atom
1717

1818
/// An error returned when no atom is found in the virtual machine's atom table
1919
/// for a given string when calling the [`from_string`](#from_string) function.
@@ -35,7 +35,7 @@ pub type FromStringError {
3535
/// Error(AtomNotLoaded)
3636
///
3737
pub external fn from_string(String) -> Result(Atom, FromStringError) =
38-
"gleam_stdlib" "atom_from_string";
38+
"gleam_stdlib" "atom_from_string"
3939

4040
/// Create an atom from a string, inserting a new value into the virtual
4141
/// machine's atom table if an atom does not already exist for the given
@@ -47,7 +47,7 @@ pub external fn from_string(String) -> Result(Atom, FromStringError) =
4747
/// virtual machine to crash!
4848
///
4949
pub external fn create_from_string(String) -> Atom =
50-
"gleam_stdlib" "atom_create_from_string";
50+
"gleam_stdlib" "atom_create_from_string"
5151

5252
/// Retuns a `String` corresponding to the text representation of the given
5353
/// `Atom`.
@@ -59,4 +59,4 @@ pub external fn create_from_string(String) -> Atom =
5959
/// "ok"
6060
///
6161
pub external fn to_string(Atom) -> String =
62-
"gleam_stdlib" "atom_to_string";
62+
"gleam_stdlib" "atom_to_string"

src/gleam/dynamic.gleam

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import gleam/result
55
/// `Dynamic` data is data that we don"t know the type of yet.
66
/// We likely get data like this from interop with Erlang, or from
77
/// IO with the outside world.
8-
pub external type Dynamic;
8+
pub external type Dynamic
99

1010
/// Convert any Gleam data into `Dynamic` data.
1111
///
12-
pub external fn from(a) -> Dynamic = "gleam_stdlib" "identity";
12+
pub external fn from(a) -> Dynamic =
13+
"gleam_stdlib" "identity"
1314

1415
/// Unsafely cast a Dynamic value into any other type.
1516
///
@@ -18,7 +19,8 @@ pub external fn from(a) -> Dynamic = "gleam_stdlib" "identity";
1819
///
1920
/// If you can avoid using this function, do!
2021
///
21-
pub external fn unsafe_coerce(Dynamic) -> a = "gleam_stdlib" "identity";
22+
pub external fn unsafe_coerce(Dynamic) -> a =
23+
"gleam_stdlib" "identity"
2224

2325
/// Check to see whether a Dynamic value is a string, and return the string if
2426
/// it is.
@@ -31,8 +33,8 @@ pub external fn unsafe_coerce(Dynamic) -> a = "gleam_stdlib" "identity";
3133
/// > string(from(123))
3234
/// Error("Expected a String, got `123`")
3335
///
34-
pub external fn string(from: Dynamic) -> Result(String, String)
35-
= "gleam_stdlib" "decode_string"
36+
pub external fn string(from: Dynamic) -> Result(String, String) =
37+
"gleam_stdlib" "decode_string"
3638

3739
/// Check to see whether a Dynamic value is an int, and return the int if it
3840
/// is.
@@ -45,8 +47,8 @@ pub external fn string(from: Dynamic) -> Result(String, String)
4547
/// > int(from("Hello"))
4648
/// Error("Expected an Int, got `\"Hello World\"`")
4749
///
48-
pub external fn int(from: Dynamic) -> Result(Int, String)
49-
= "gleam_stdlib" "decode_int"
50+
pub external fn int(from: Dynamic) -> Result(Int, String) =
51+
"gleam_stdlib" "decode_int"
5052

5153
/// Check to see whether a Dynamic value is an float, and return the float if
5254
/// it is.
@@ -59,8 +61,8 @@ pub external fn int(from: Dynamic) -> Result(Int, String)
5961
/// > float(from(123))
6062
/// Error("Expected a Float, got `123`")
6163
///
62-
pub external fn float(from: Dynamic) -> Result(Float, String)
63-
= "gleam_stdlib" "decode_float"
64+
pub external fn float(from: Dynamic) -> Result(Float, String) =
65+
"gleam_stdlib" "decode_float"
6466

6567
/// Check to see whether a Dynamic value is an atom, and return the atom if
6668
/// it is.
@@ -74,8 +76,8 @@ pub external fn float(from: Dynamic) -> Result(Float, String)
7476
/// > atom(from(123))
7577
/// Error("Expected an Atom, got `123`")
7678
///
77-
pub external fn atom(from: Dynamic) -> Result(atom.Atom, String)
78-
= "gleam_stdlib" "decode_atom"
79+
pub external fn atom(from: Dynamic) -> Result(atom.Atom, String) =
80+
"gleam_stdlib" "decode_atom"
7981

8082
/// Check to see whether a Dynamic value is an bool, and return the bool if
8183
/// it is.
@@ -88,8 +90,8 @@ pub external fn atom(from: Dynamic) -> Result(atom.Atom, String)
8890
/// > bool(from(123))
8991
/// Error("Expected a Bool, got `123`")
9092
///
91-
pub external fn bool(from: Dynamic) -> Result(Bool, String)
92-
= "gleam_stdlib" "decode_bool"
93+
pub external fn bool(from: Dynamic) -> Result(Bool, String) =
94+
"gleam_stdlib" "decode_bool"
9395

9496
/// Check to see whether a Dynamic value is a function that takes no arguments,
9597
/// and return the function if it is.
@@ -104,11 +106,11 @@ pub external fn bool(from: Dynamic) -> Result(Bool, String)
104106
/// > thunk(from(123))
105107
/// Error("Expected a zero arity function, got `123`")
106108
///
107-
pub external fn thunk(from: Dynamic) -> Result(fn() -> Dynamic, String)
108-
= "gleam_stdlib" "decode_thunk"
109+
pub external fn thunk(from: Dynamic) -> Result(fn() -> Dynamic, String) =
110+
"gleam_stdlib" "decode_thunk"
109111

110-
external fn list_dynamic(from: Dynamic) -> Result(List(Dynamic), String)
111-
= "gleam_stdlib" "decode_list"
112+
external fn list_dynamic(from: Dynamic) -> Result(List(Dynamic), String) =
113+
"gleam_stdlib" "decode_list"
112114

113115
/// Check to see whether a Dynamic value is a list, and return the list if it
114116
/// is.
@@ -130,7 +132,7 @@ pub fn list(
130132
) -> Result(List(inner), String) {
131133
dynamic
132134
|> list_dynamic
133-
|> result.then(_, list_mod.traverse(_, decoder_type))
135+
|> result.then(list_mod.traverse(_, decoder_type))
134136
}
135137

136138
/// Check to see if a Dynamic value is a map with a specific field, and return
@@ -147,8 +149,8 @@ pub fn list(
147149
/// > field(from(123), "Hello")
148150
/// Error("Expected a map with key `\"Hello\"`, got an Int")
149151
///
150-
pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, String)
151-
= "gleam_stdlib" "decode_field"
152+
pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, String) =
153+
"gleam_stdlib" "decode_field"
152154

153155
/// Check to see if the Dynamic value is a tuple large enough to have a certain
154156
/// index, and return the value of that index if it is.
@@ -164,5 +166,8 @@ pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, String)
164166
/// > element(from(""), 2)
165167
/// Error("Expected a Tuple, got a binary")
166168
///
167-
pub external fn element(from: Dynamic, position: Int) -> Result(Dynamic, String)
168-
= "gleam_stdlib" "decode_element"
169+
pub external fn element(
170+
from: Dynamic,
171+
position: Int,
172+
) -> Result(Dynamic, String) =
173+
"gleam_stdlib" "decode_element"

src/gleam/float.gleam

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub type Float =
1515
/// > parse("ABC")
1616
/// None
1717
///
18-
pub external fn parse(String) -> Option(Float)
19-
= "gleam_stdlib" "parse_float";
18+
pub external fn parse(String) -> Option(Float) =
19+
"gleam_stdlib" "parse_float"
2020

2121
/// Return the string representation of the provided float.
2222
///
@@ -39,11 +39,10 @@ pub fn to_string(f: Float) -> String {
3939
pub fn compare(a: Float, with b: Float) -> Order {
4040
case a == b {
4141
True -> order.Eq
42-
False ->
43-
case a <. b {
44-
True -> order.Lt
45-
False -> order.Gt
46-
}
42+
False -> case a <. b {
43+
True -> order.Lt
44+
False -> order.Gt
45+
}
4746
}
4847
}
4948

@@ -82,7 +81,8 @@ pub fn max(a: Float, b: Float) -> Float {
8281
/// > ceiling(2.3)
8382
/// 3.0
8483
///
85-
pub external fn ceiling(Float) -> Float = "math" "ceil";
84+
pub external fn ceiling(Float) -> Float =
85+
"math" "ceil"
8686

8787
/// Rounds the value to the next lowest whole number as a float.
8888
///
@@ -91,7 +91,8 @@ pub external fn ceiling(Float) -> Float = "math" "ceil";
9191
/// > floor(2.3)
9292
/// 2.0
9393
///
94-
pub external fn floor(Float) -> Float = "math" "floor";
94+
pub external fn floor(Float) -> Float =
95+
"math" "floor"
9596

9697
/// Rounds the value to the nearest whole number as an int.
9798
///
@@ -103,7 +104,8 @@ pub external fn floor(Float) -> Float = "math" "floor";
103104
/// > round(2.5)
104105
/// 3
105106
///
106-
pub external fn round(Float) -> Int = "erlang" "round";
107+
pub external fn round(Float) -> Int =
108+
"erlang" "round"
107109

108110
/// Returns the value as an int, truncating all decimal digits.
109111
///
@@ -112,4 +114,5 @@ pub external fn round(Float) -> Int = "erlang" "round";
112114
/// > truncate(2.4343434847383438)
113115
/// 2
114116
///
115-
pub external fn truncate(Float) -> Int = "erlang" "trunc";
117+
pub external fn truncate(Float) -> Int =
118+
"erlang" "trunc"

src/gleam/int.gleam

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pub type Int =
1414
/// > parse("ABC")
1515
/// Error(Nil)
1616
///
17-
pub external fn parse(String) -> Option(Int) = "gleam_stdlib" "parse_int";
17+
pub external fn parse(String) -> Option(Int) =
18+
"gleam_stdlib" "parse_int"
1819

1920
/// Print a given int to a string.
2021
///
@@ -23,7 +24,8 @@ pub external fn parse(String) -> Option(Int) = "gleam_stdlib" "parse_int";
2324
/// > to_string(2)
2425
/// "2"
2526
///
26-
pub external fn to_string(Int) -> String = "erlang" "integer_to_binary"
27+
pub external fn to_string(Int) -> String =
28+
"erlang" "integer_to_binary"
2729

2830
/// Print a given int to a string using the base number provided.
2931
///
@@ -38,7 +40,8 @@ pub external fn to_string(Int) -> String = "erlang" "integer_to_binary"
3840
/// > to_base_string(48, 36)
3941
/// "1C"
4042
///
41-
pub external fn to_base_string(Int, Int) -> String = "erlang" "integer_to_binary"
43+
pub external fn to_base_string(Int, Int) -> String =
44+
"erlang" "integer_to_binary"
4245

4346
/// Compares two ints, returning an order.
4447
///
@@ -56,11 +59,10 @@ pub external fn to_base_string(Int, Int) -> String = "erlang" "integer_to_binary
5659
pub fn compare(a: Int, with b: Int) -> Order {
5760
case a == b {
5861
True -> order.Eq
59-
False ->
60-
case a < b {
61-
True -> order.Lt
62-
False -> order.Gt
63-
}
62+
False -> case a < b {
63+
True -> order.Lt
64+
False -> order.Gt
65+
}
6466
}
6567
}
6668

src/gleam/iodata.gleam

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,89 +9,92 @@
99
/// using minimal memory, and then can be efficiently converted to a string
1010
/// using the `to_string` function.
1111
///
12-
pub external type Iodata;
12+
pub external type Iodata
1313

1414
/// Prepend a String onto the start of some Iodata.
1515
///
1616
/// Runs in constant time.
1717
///
1818
pub external fn prepend(to: Iodata, prefix: String) -> Iodata =
19-
"gleam_stdlib" "iodata_prepend";
19+
"gleam_stdlib" "iodata_prepend"
2020

2121
/// Append a String onto the end of some Iodata.
2222
///
2323
/// Runs in constant time.
2424
///
2525
pub external fn append(to: Iodata, suffix: String) -> Iodata =
26-
"gleam_stdlib" "iodata_append";
26+
"gleam_stdlib" "iodata_append"
2727

2828
/// Prepend some Iodata onto the start of another.
2929
///
3030
/// Runs in constant time.
3131
///
3232
pub external fn prepend_iodata(to: Iodata, prefix: Iodata) -> Iodata =
33-
"gleam_stdlib" "iodata_prepend";
33+
"gleam_stdlib" "iodata_prepend"
3434

3535
/// Append some Iodata onto the end of another.
3636
///
3737
/// Runs in constant time.
3838
///
3939
pub external fn append_iodata(to: Iodata, suffix: Iodata) -> Iodata =
40-
"gleam_stdlib" "iodata_append";
40+
"gleam_stdlib" "iodata_append"
4141

4242
/// Convert a list of strings into iodata.
4343
///
4444
/// Runs in constant time.
4545
///
4646
pub external fn from_strings(List(String)) -> Iodata =
47-
"gleam_stdlib" "identity";
47+
"gleam_stdlib" "identity"
4848

4949
/// Joins a list of iodata into a single iodata.
5050
///
5151
/// Runs in constant time.
5252
///
5353
pub external fn concat(List(Iodata)) -> Iodata =
54-
"gleam_stdlib" "identity";
54+
"gleam_stdlib" "identity"
5555

5656
/// Convert a string into iodata.
5757
///
5858
/// Runs in constant time.
5959
///
6060
pub external fn new(String) -> Iodata =
61-
"gleam_stdlib" "identity";
61+
"gleam_stdlib" "identity"
6262

6363
/// Turns an `Iodata` into a `String`
6464
///
6565
/// This function is implemented natively by the virtual machine and is highly
6666
/// optimised.
6767
///
6868
pub external fn to_string(Iodata) -> String =
69-
"erlang" "iolist_to_binary";
69+
"erlang" "iolist_to_binary"
7070

7171
/// Returns the size of the Iodata in bytes.
7272
///
7373
pub external fn byte_size(Iodata) -> Int =
74-
"erlang" "iolist_size";
74+
"erlang" "iolist_size"
7575

7676
/// Creates textual representation of the given float as iodata.
7777
///
7878
pub external fn from_float(Float) -> Iodata =
79-
"io_lib_format" "fwrite_g";
79+
"io_lib_format" "fwrite_g"
8080

8181
/// Converts Iodata to a new Iodata where valid UTF-8 string data is
8282
/// lowercased.
8383
///
84-
pub external fn lowercase(Iodata) -> Iodata = "string" "lowercase"
84+
pub external fn lowercase(Iodata) -> Iodata =
85+
"string" "lowercase"
8586

8687
/// Converts Iodata to a new Iodata where valid UTF-8 string data is
8788
/// uppercased.
8889
///
89-
pub external fn uppercase(Iodata) -> Iodata = "string" "uppercase"
90+
pub external fn uppercase(Iodata) -> Iodata =
91+
"string" "uppercase"
9092

9193
/// Converts Iodata to a new Iodata where valid UTF-8 string data is
9294
/// reversed.
9395
///
94-
pub external fn reverse(Iodata) -> Iodata = "string" "reverse"
96+
pub external fn reverse(Iodata) -> Iodata =
97+
"string" "reverse"
9598

9699
type Direction {
97100
All
@@ -135,7 +138,8 @@ pub fn replace(
135138
/// True
136139
///
137140
///
138-
pub external fn is_equal(Iodata, Iodata) -> Bool = "string" "equal"
141+
pub external fn is_equal(Iodata, Iodata) -> Bool =
142+
"string" "equal"
139143

140144
/// Inspect some iodata to determine if it is equivalent to an empty string.
141145
///
@@ -151,4 +155,5 @@ pub external fn is_equal(Iodata, Iodata) -> Bool = "string" "equal"
151155
/// True
152156
///
153157
///
154-
pub external fn is_empty(Iodata) -> Bool = "string" "is_empty"
158+
pub external fn is_empty(Iodata) -> Bool =
159+
"string" "is_empty"

0 commit comments

Comments
 (0)