Skip to content

Commit 1b8fd2a

Browse files
committed
Update for Gleam v0.6.0
1 parent 0c165bc commit 1b8fd2a

File tree

12 files changed

+151
-149
lines changed

12 files changed

+151
-149
lines changed

gen/test/gleam@dynamic_test.erl

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/gleam/atom.gleam

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
pub external type Atom;
22

3-
pub struct AtomNotLoaded {}
3+
pub type AtomNotLoaded {
4+
AtomNotLoaded
5+
}
46

57
pub external fn from_string(String) -> Result(Atom, AtomNotLoaded) =
68
"gleam_stdlib" "atom_from_string";

src/gleam/iodata.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub external fn uppercase(Iodata) -> Iodata = "string" "uppercase"
3636

3737
pub external fn reverse(Iodata) -> Iodata = "string" "reverse"
3838

39-
enum Direction {
39+
type Direction {
4040
All
4141
}
4242

src/gleam/list.gleam

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import gleam/int
22
import gleam/order
33
import gleam/pair
44

5-
pub struct LengthMismatch {}
5+
pub type LengthMismatch {
6+
LengthMismatch
7+
}
68

79
// Using the Erlang C BIF implementation.
810
//
@@ -196,7 +198,7 @@ pub fn zip(xs, ys) {
196198
case xs, ys {
197199
[], _ -> []
198200
_, [] -> []
199-
[x | xs], [y | ys] -> [ struct(x, y) | zip(xs, ys) ]
201+
[x | xs], [y | ys] -> [ tuple(x, y) | zip(xs, ys) ]
200202
}
201203
}
202204

@@ -290,10 +292,10 @@ pub fn repeat(item a, times times) {
290292

291293
fn do_split(list, n, taken) {
292294
case n <= 0 {
293-
True -> struct(reverse(taken), list)
295+
True -> tuple(reverse(taken), list)
294296
False ->
295297
case list {
296-
[] -> struct(reverse(taken), [])
298+
[] -> tuple(reverse(taken), [])
297299
[x | xs] -> do_split(xs, n - 1, [x | taken])
298300
}
299301
}
@@ -305,10 +307,10 @@ pub fn split(list list, on target) {
305307

306308
fn do_split_while(list, f, acc) {
307309
case list {
308-
[] -> struct(reverse(acc), [])
310+
[] -> tuple(reverse(acc), [])
309311
[x | xs] ->
310312
case f(x) {
311-
False -> struct(reverse(acc), list)
313+
False -> tuple(reverse(acc), list)
312314
_ -> do_split_while(xs, f, [x | acc])
313315
}
314316
}

src/gleam/map.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ pub external type Map(key, value);
66
pub external fn size(Map(k, v)) -> Int
77
= "maps" "size"
88

9-
pub external fn to_list(Map(key, value)) -> List(struct(key, value))
9+
pub external fn to_list(Map(key, value)) -> List(tuple(key, value))
1010
= "maps" "to_list"
1111

12-
pub external fn from_list(List(struct(key, value))) -> Map(key, value)
12+
pub external fn from_list(List(tuple(key, value))) -> Map(key, value)
1313
= "maps" "from_list"
1414

1515
external fn is_key(key, Map(key, v)) -> Bool
@@ -84,7 +84,7 @@ pub fn update(in map, update key, with fun) {
8484
fn do_fold(list, initial, fun) {
8585
case list {
8686
[] -> initial
87-
[struct(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun)
87+
[tuple(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun)
8888
}
8989
}
9090

src/gleam/order.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub enum Order {
1+
pub type Order {
22
Lt
33
Eq
44
Gt

src/gleam/pair.gleam

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
pub fn first(pair) {
2-
let struct(a, _) = pair
2+
let tuple(a, _) = pair
33
a
44
}
55

66
pub fn second(pair) {
7-
let struct(_, a) = pair
7+
let tuple(_, a) = pair
88
a
99
}
1010

1111
pub fn swap(pair) {
12-
let struct(a, b) = pair
13-
struct(b, a)
12+
let tuple(a, b) = pair
13+
tuple(b, a)
1414
}
1515

1616
pub fn map_first(of pair, with fun) {
17-
let struct(a, b) = pair
18-
struct(fun(a), b)
17+
let tuple(a, b) = pair
18+
tuple(fun(a), b)
1919
}
2020

2121
pub fn map_second(of pair, with fun) {
22-
let struct(a, b) = pair
23-
struct(a, fun(b))
22+
let tuple(a, b) = pair
23+
tuple(a, fun(b))
2424
}

test/gleam/dynamic_test.gleam

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ pub fn list_test() {
187187
|> expect.is_error
188188
}
189189

190-
// TODO: struct2
191-
192190
pub fn field_test() {
193191
let Ok(ok_atom) = atom.from_string("ok")
194192
let Ok(error_atom) = atom.from_string("error")
@@ -224,24 +222,24 @@ pub fn field_test() {
224222

225223
pub fn element_test() {
226224
let Ok(ok_atom) = atom.from_string("ok")
227-
let ok_one_struct = struct(ok_atom, 1)
225+
let ok_one_tuple = tuple(ok_atom, 1)
228226

229-
ok_one_struct
227+
ok_one_tuple
230228
|> dynamic.from
231229
|> dynamic.element(_, 0)
232230
|> expect.equal(_, Ok(dynamic.from(ok_atom)))
233231

234-
ok_one_struct
232+
ok_one_tuple
235233
|> dynamic.from
236234
|> dynamic.element(_, 1)
237235
|> expect.equal(_, Ok(dynamic.from(1)))
238236

239-
ok_one_struct
237+
ok_one_tuple
240238
|> dynamic.from
241239
|> dynamic.element(_, 2)
242240
|> expect.is_error
243241

244-
ok_one_struct
242+
ok_one_tuple
245243
|> dynamic.from
246244
|> dynamic.element(_, -1)
247245
|> expect.is_error

test/gleam/list_test.gleam

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ pub fn zip_test() {
222222
|> expect.equal(_, [])
223223

224224
list.zip([1, 2, 3], [4, 5, 6])
225-
|> expect.equal(_, [struct(1, 4), struct(2, 5), struct(3, 6)])
225+
|> expect.equal(_, [tuple(1, 4), tuple(2, 5), tuple(3, 6)])
226226

227227
list.zip([5, 6], [1, 2, 3])
228-
|> expect.equal(_, [struct(5, 1), struct(6, 2)])
228+
|> expect.equal(_, [tuple(5, 1), tuple(6, 2)])
229229

230230
list.zip([5, 6, 7], [1, 2])
231-
|> expect.equal(_, [struct(5, 1), struct(6, 2)])
231+
|> expect.equal(_, [tuple(5, 1), tuple(6, 2)])
232232
}
233233

234234
pub fn strict_zip_test() {
@@ -240,9 +240,9 @@ pub fn strict_zip_test() {
240240

241241
list.strict_zip([1, 2, 3], [4, 5, 6])
242242
|> expect.equal(_, Ok([
243-
struct(1, 4),
244-
struct(2, 5),
245-
struct(3, 6),
243+
tuple(1, 4),
244+
tuple(2, 5),
245+
tuple(3, 6),
246246
]))
247247

248248
list.strict_zip([5, 6], [1, 2, 3])
@@ -307,8 +307,8 @@ pub fn sort_test() {
307307
}
308308

309309
pub fn index_map_test() {
310-
list.index_map([3, 4, 5], fn(i, x) { struct(i, x) })
311-
|> expect.equal(_, [struct(0, 3), struct(1, 4), struct(2, 5)])
310+
list.index_map([3, 4, 5], fn(i, x) { tuple(i, x) })
311+
|> expect.equal(_, [tuple(0, 3), tuple(1, 4), tuple(2, 5)])
312312

313313
let f = fn(i, x) {
314314
string.append(x, int.to_string(i))
@@ -354,54 +354,54 @@ pub fn repeat_test() {
354354
pub fn split_test() {
355355
[]
356356
|> list.split(_, 0)
357-
|> expect.equal(_, struct([], []))
357+
|> expect.equal(_, tuple([], []))
358358

359359
[0, 1, 2, 3, 4]
360360
|> list.split(_, 0)
361-
|> expect.equal(_, struct([], [0, 1, 2, 3, 4]))
361+
|> expect.equal(_, tuple([], [0, 1, 2, 3, 4]))
362362

363363
[0, 1, 2, 3, 4]
364364
|> list.split(_, -2)
365-
|> expect.equal(_, struct([], [0, 1, 2, 3, 4]))
365+
|> expect.equal(_, tuple([], [0, 1, 2, 3, 4]))
366366

367367
[0, 1, 2, 3, 4]
368368
|> list.split(_, 1)
369-
|> expect.equal(_, struct([0], [1, 2, 3, 4]))
369+
|> expect.equal(_, tuple([0], [1, 2, 3, 4]))
370370

371371
[0, 1, 2, 3, 4]
372372
|> list.split(_, 3)
373-
|> expect.equal(_, struct([0, 1, 2], [3, 4]))
373+
|> expect.equal(_, tuple([0, 1, 2], [3, 4]))
374374

375375
[0, 1, 2, 3, 4]
376376
|> list.split(_, 9)
377-
|> expect.equal(_, struct([0, 1, 2, 3, 4], []))
377+
|> expect.equal(_, tuple([0, 1, 2, 3, 4], []))
378378
}
379379

380380
pub fn split_while_test() {
381381
[]
382382
|> list.split_while(_, fn(x) { x <= 5 })
383-
|> expect.equal(_, struct([], []))
383+
|> expect.equal(_, tuple([], []))
384384

385385
[1, 2, 3, 4, 5]
386386
|> list.split_while(_, fn(x) { x <= 5 })
387-
|> expect.equal(_, struct([1, 2, 3, 4, 5], []))
387+
|> expect.equal(_, tuple([1, 2, 3, 4, 5], []))
388388

389389
[1, 2, 3, 4, 5]
390390
|> list.split_while(_, fn(x) { x == 2 })
391-
|> expect.equal(_, struct([], [1, 2, 3, 4, 5]))
391+
|> expect.equal(_, tuple([], [1, 2, 3, 4, 5]))
392392

393393
[1, 2, 3, 4, 5]
394394
|> list.split_while(_, fn(x) { x <= 3 })
395-
|> expect.equal(_, struct([1, 2, 3], [4, 5]))
395+
|> expect.equal(_, tuple([1, 2, 3], [4, 5]))
396396

397397
[1, 2, 3, 4, 5]
398398
|> list.split_while(_, fn(x) { x <= -3 })
399-
|> expect.equal(_, struct([], [1, 2, 3, 4, 5]))
399+
|> expect.equal(_, tuple([], [1, 2, 3, 4, 5]))
400400
}
401401

402402

403403
pub fn key_find_test() {
404-
let proplist = [struct(0, "1"), struct(1, "2")]
404+
let proplist = [tuple(0, "1"), tuple(1, "2")]
405405

406406
proplist
407407
|> list.key_find(_, 0)

0 commit comments

Comments
 (0)