diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-12-23 14:55:31 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-12-23 14:55:31 +0000 |
commit | 1b8fd2a16ca588dfa53b644a312f21dee4c610e4 (patch) | |
tree | 786b660ccdb0a900bf1cb98bb0b3959902ea2b43 /src | |
parent | 0c165bcee923e698d0a4c46f221f2e62f2a6d5ab (diff) | |
download | gleam_stdlib-1b8fd2a16ca588dfa53b644a312f21dee4c610e4.tar.gz gleam_stdlib-1b8fd2a16ca588dfa53b644a312f21dee4c610e4.zip |
Update for Gleam v0.6.0
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/atom.gleam | 4 | ||||
-rw-r--r-- | src/gleam/iodata.gleam | 2 | ||||
-rw-r--r-- | src/gleam/list.gleam | 14 | ||||
-rw-r--r-- | src/gleam/map.gleam | 6 | ||||
-rw-r--r-- | src/gleam/order.gleam | 2 | ||||
-rw-r--r-- | src/gleam/pair.gleam | 16 |
6 files changed, 24 insertions, 20 deletions
diff --git a/src/gleam/atom.gleam b/src/gleam/atom.gleam index b37ae14..9b69127 100644 --- a/src/gleam/atom.gleam +++ b/src/gleam/atom.gleam @@ -1,6 +1,8 @@ pub external type Atom; -pub struct AtomNotLoaded {} +pub type AtomNotLoaded { + AtomNotLoaded +} pub external fn from_string(String) -> Result(Atom, AtomNotLoaded) = "gleam_stdlib" "atom_from_string"; diff --git a/src/gleam/iodata.gleam b/src/gleam/iodata.gleam index 3a7f5f2..ed993d1 100644 --- a/src/gleam/iodata.gleam +++ b/src/gleam/iodata.gleam @@ -36,7 +36,7 @@ pub external fn uppercase(Iodata) -> Iodata = "string" "uppercase" pub external fn reverse(Iodata) -> Iodata = "string" "reverse" -enum Direction { +type Direction { All } diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index 101e24e..221311a 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -2,7 +2,9 @@ import gleam/int import gleam/order import gleam/pair -pub struct LengthMismatch {} +pub type LengthMismatch { + LengthMismatch +} // Using the Erlang C BIF implementation. // @@ -196,7 +198,7 @@ pub fn zip(xs, ys) { case xs, ys { [], _ -> [] _, [] -> [] - [x | xs], [y | ys] -> [ struct(x, y) | zip(xs, ys) ] + [x | xs], [y | ys] -> [ tuple(x, y) | zip(xs, ys) ] } } @@ -290,10 +292,10 @@ pub fn repeat(item a, times times) { fn do_split(list, n, taken) { case n <= 0 { - True -> struct(reverse(taken), list) + True -> tuple(reverse(taken), list) False -> case list { - [] -> struct(reverse(taken), []) + [] -> tuple(reverse(taken), []) [x | xs] -> do_split(xs, n - 1, [x | taken]) } } @@ -305,10 +307,10 @@ pub fn split(list list, on target) { fn do_split_while(list, f, acc) { case list { - [] -> struct(reverse(acc), []) + [] -> tuple(reverse(acc), []) [x | xs] -> case f(x) { - False -> struct(reverse(acc), list) + False -> tuple(reverse(acc), list) _ -> do_split_while(xs, f, [x | acc]) } } diff --git a/src/gleam/map.gleam b/src/gleam/map.gleam index d103d01..00e6f1c 100644 --- a/src/gleam/map.gleam +++ b/src/gleam/map.gleam @@ -6,10 +6,10 @@ pub external type Map(key, value); pub external fn size(Map(k, v)) -> Int = "maps" "size" -pub external fn to_list(Map(key, value)) -> List(struct(key, value)) +pub external fn to_list(Map(key, value)) -> List(tuple(key, value)) = "maps" "to_list" -pub external fn from_list(List(struct(key, value))) -> Map(key, value) +pub external fn from_list(List(tuple(key, value))) -> Map(key, value) = "maps" "from_list" external fn is_key(key, Map(key, v)) -> Bool @@ -84,7 +84,7 @@ pub fn update(in map, update key, with fun) { fn do_fold(list, initial, fun) { case list { [] -> initial - [struct(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun) + [tuple(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun) } } diff --git a/src/gleam/order.gleam b/src/gleam/order.gleam index cf3bc40..0b90d01 100644 --- a/src/gleam/order.gleam +++ b/src/gleam/order.gleam @@ -1,4 +1,4 @@ -pub enum Order { +pub type Order { Lt Eq Gt diff --git a/src/gleam/pair.gleam b/src/gleam/pair.gleam index aaa336f..1637034 100644 --- a/src/gleam/pair.gleam +++ b/src/gleam/pair.gleam @@ -1,24 +1,24 @@ pub fn first(pair) { - let struct(a, _) = pair + let tuple(a, _) = pair a } pub fn second(pair) { - let struct(_, a) = pair + let tuple(_, a) = pair a } pub fn swap(pair) { - let struct(a, b) = pair - struct(b, a) + let tuple(a, b) = pair + tuple(b, a) } pub fn map_first(of pair, with fun) { - let struct(a, b) = pair - struct(fun(a), b) + let tuple(a, b) = pair + tuple(fun(a), b) } pub fn map_second(of pair, with fun) { - let struct(a, b) = pair - struct(a, fun(b)) + let tuple(a, b) = pair + tuple(a, fun(b)) } |