Skip to content

Commit 69b0e8e

Browse files
committed
Update for Gleam v0.5
1 parent 09bd0a8 commit 69b0e8e

18 files changed

+151
-315
lines changed

gen/src/[email protected]

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

gen/src/[email protected]

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

gen/src/[email protected]

Lines changed: 0 additions & 16 deletions
This file was deleted.

gen/test/gleam@any_test.erl

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

gen/test/gleam@triple_test.erl

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/gleam/any.gleam

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import gleam/list as list_mod
22
import gleam/atom
33
import gleam/result
4-
import gleam/pair.{Pair}
54

65
// `Any` data is data that we don"t know the type of yet.
76
// We likely get data like this from interop with Erlang, or from
@@ -47,8 +46,5 @@ pub fn list(from any, containing decoder_type) {
4746
|> result.then(_, list_mod.traverse(_, decoder_type))
4847
}
4948

50-
pub external fn pair(from: Any) -> Result(Pair(Any, Any), String)
51-
= "gleam_stdlib" "decode_pair"
52-
5349
pub external fn field(from: Any, named: a) -> Result(Any, String)
5450
= "gleam_stdlib" "decode_field"

src/gleam/atom.gleam

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

3-
pub enum AtomNotLoaded {
4-
AtomNotLoaded
5-
}
3+
pub struct AtomNotLoaded {}
64

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

src/gleam/list.gleam

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import gleam/int
22
import gleam/order
3-
import gleam/pair.{Pair}
3+
import gleam/pair
44

5-
pub enum LengthMismatch {
6-
LengthMismatch
7-
}
5+
pub struct LengthMismatch {}
86

97
// Using the Erlang C BIF implementation.
108
//
@@ -198,7 +196,7 @@ pub fn zip(xs, ys) {
198196
case xs, ys {
199197
[], _ -> []
200198
_, [] -> []
201-
[x | xs], [y | ys] -> [ Pair(x, y) | zip(xs, ys) ]
199+
[x | xs], [y | ys] -> [ struct(x, y) | zip(xs, ys) ]
202200
}
203201
}
204202

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

293291
fn do_split(list, n, taken) {
294292
case n <= 0 {
295-
True -> Pair(reverse(taken), list)
293+
True -> struct(reverse(taken), list)
296294
False ->
297295
case list {
298-
[] -> Pair(reverse(taken), [])
296+
[] -> struct(reverse(taken), [])
299297
[x | xs] -> do_split(xs, n - 1, [x | taken])
300298
}
301299
}
@@ -307,10 +305,10 @@ pub fn split(list list, on target) {
307305

308306
fn do_split_while(list, f, acc) {
309307
case list {
310-
[] -> Pair(reverse(acc), [])
308+
[] -> struct(reverse(acc), [])
311309
[x | xs] ->
312310
case f(x) {
313-
False -> Pair(reverse(acc), list)
311+
False -> struct(reverse(acc), list)
314312
_ -> do_split_while(xs, f, [x | acc])
315313
}
316314
}

src/gleam/map.gleam

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import gleam/any
22
import gleam/result
33
import gleam/list
4-
import gleam/pair.{Pair}
54

65
pub external type Map(key, value);
76

87
pub external fn size(Map(k, v)) -> Int
98
= "maps" "size"
109

11-
pub external fn to_list(Map(key, value)) -> List(Pair(key, value))
10+
pub external fn to_list(Map(key, value)) -> List(struct(key, value))
1211
= "maps" "to_list"
1312

14-
pub external fn from_list(List(Pair(key, value))) -> Map(key, value)
13+
pub external fn from_list(List(struct(key, value))) -> Map(key, value)
1514
= "maps" "from_list"
1615

1716
external fn is_key(key, Map(key, v)) -> Bool
@@ -86,7 +85,7 @@ pub fn update(in map, update key, with fun) {
8685
fn do_fold(list, initial, fun) {
8786
case list {
8887
[] -> initial
89-
[Pair(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun)
88+
[struct(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun)
9089
}
9190
}
9291

src/gleam/pair.gleam

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
pub struct Pair(a, b) {
2-
first: a
3-
second: b
4-
}
5-
6-
pub fn first(tup) {
7-
let Pair(a, _) = tup
1+
pub fn first(pair) {
2+
let struct(a, _) = pair
83
a
94
}
105

11-
pub fn second(tup) {
12-
let Pair(_, a) = tup
6+
pub fn second(pair) {
7+
let struct(_, a) = pair
138
a
149
}
1510

16-
pub fn swap(tup) {
17-
let Pair(a, b) = tup
18-
Pair(b, a)
11+
pub fn swap(pair) {
12+
let struct(a, b) = pair
13+
struct(b, a)
1914
}
2015

21-
pub fn map_first(of tup, with fun) {
22-
let Pair(a, b) = tup
23-
Pair(fun(a), b)
16+
pub fn map_first(of pair, with fun) {
17+
let struct(a, b) = pair
18+
struct(fun(a), b)
2419
}
2520

26-
pub fn map_second(of tup, with fun) {
27-
let Pair(a, b) = tup
28-
Pair(a, fun(b))
21+
pub fn map_second(of pair, with fun) {
22+
let struct(a, b) = pair
23+
struct(a, fun(b))
2924
}

0 commit comments

Comments
 (0)