diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-09-17 21:16:54 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-09-17 22:20:26 +0100 |
commit | 6fe389492ce7d788c1177b3ea76717ee6c274347 (patch) | |
tree | b1b5c5c4067186a4a86e9936467b1faad1c5e56f /src | |
parent | 4dc0d1854fa7dfc0229e27b6b69848564185e43b (diff) | |
download | gleam_stdlib-6fe389492ce7d788c1177b3ea76717ee6c274347.tar.gz gleam_stdlib-6fe389492ce7d788c1177b3ea76717ee6c274347.zip |
Removing is_error from tests
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/atom.gleam | 3 | ||||
-rw-r--r-- | src/gleam/float.gleam | 5 | ||||
-rw-r--r-- | src/gleam/list.gleam | 8 | ||||
-rw-r--r-- | src/gleam/map.gleam | 34 | ||||
-rw-r--r-- | src/gleam_stdlib.erl | 2 |
5 files changed, 24 insertions, 28 deletions
diff --git a/src/gleam/atom.gleam b/src/gleam/atom.gleam index 24b82d5..a5418d5 100644 --- a/src/gleam/atom.gleam +++ b/src/gleam/atom.gleam @@ -1,7 +1,6 @@ pub external type Atom; -pub enum AtomNotLoaded = - | AtomNotLoaded +pub enum AtomNotLoaded = | AtomNotLoaded pub external fn from_string(String) -> Result(Atom, AtomNotLoaded) = "gleam_stdlib" "atom_from_string"; diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam index 9095ec4..441d9a0 100644 --- a/src/gleam/float.gleam +++ b/src/gleam/float.gleam @@ -1,10 +1,7 @@ import gleam/iodata import gleam/order -pub enum NotAFloat = - | NotAFloat - -pub external fn parse(String) -> Result(Float, NotAFloat) = +pub external fn parse(String) -> Result(Float, Nil) = "gleam_stdlib" "parse_float"; pub fn to_string(f) { diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index 2df547c..ecc2a6c 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -2,7 +2,7 @@ import gleam/int import gleam/order import gleam/pair -pub struct LengthMismatch {} +pub enum LengthMismatch = | LengthMismatch // Using the Erlang C BIF implementation. // @@ -183,9 +183,9 @@ pub fn any(list, f) { pub fn zip(l1, l2) { case pair.Pair(l1, l2) { - | pair.Pair([], _) -> [] - | pair.Pair(_, []) -> [] - | pair.Pair([x1 | rest1], [x2 | rest2]) -> [ pair.Pair(x1, x2) | zip(rest1, rest2) ] + | pair.Pair([], _) -> [] + | pair.Pair(_, []) -> [] + | pair.Pair([x1 | rest1], [x2 | rest2]) -> [ pair.Pair(x1, x2) | zip(rest1, rest2) ] } } diff --git a/src/gleam/map.gleam b/src/gleam/map.gleam index af49d5e..3330dcc 100644 --- a/src/gleam/map.gleam +++ b/src/gleam/map.gleam @@ -3,68 +3,68 @@ import gleam/result import gleam/list import gleam/pair -pub external type MapDict(key, value); +pub external type Map(key, value); -pub external fn size(MapDict(k, v)) -> Int +pub external fn size(Map(k, v)) -> Int = "maps" "size" -pub external fn to_list(MapDict(key, value)) -> List(pair.Pair(key, value)) +pub external fn to_list(Map(key, value)) -> List(pair.Pair(key, value)) = "maps" "to_list" -pub external fn from_list(List(pair.Pair(key, value))) -> MapDict(key, value) +pub external fn from_list(List(pair.Pair(key, value))) -> Map(key, value) = "maps" "from_list" -external fn is_key(key, MapDict(key, v)) -> Bool +external fn is_key(key, Map(key, v)) -> Bool = "maps" "is_key" pub fn has_key(map, key) { is_key(key, map) } -pub external fn new() -> MapDict(key, value) +pub external fn new() -> Map(key, value) = "maps" "new" -pub external fn fetch(MapDict(key, value), key) -> Result(value, Nil) +pub external fn fetch(Map(key, value), key) -> Result(value, Nil) = "gleam_stdlib" "map_fetch"; -external fn erl_put(key, value, MapDict(key, value)) -> MapDict(key, value) +external fn erl_put(key, value, Map(key, value)) -> Map(key, value) = "maps" "put"; pub fn put(map, key, value) { erl_put(key, value, map) } -external fn erl_map_values(fn(key, value) -> value, MapDict(key, value)) - -> MapDict(key, value) +external fn erl_map_values(fn(key, value) -> value, Map(key, value)) + -> Map(key, value) = "maps" "map"; pub fn map_values(map, fun) { erl_map_values(fun, map) } -pub external fn keys(MapDict(keys, v)) -> List(keys) +pub external fn keys(Map(keys, v)) -> List(keys) = "maps" "keys" -pub external fn values(MapDict(k, values)) -> List(values) +pub external fn values(Map(k, values)) -> List(values) = "maps" "values" -external fn erl_filter(fn(key, value) -> Bool, MapDict(key, value)) - -> MapDict(key, value) +external fn erl_filter(fn(key, value) -> Bool, Map(key, value)) + -> Map(key, value) = "maps" "filter"; pub fn filter(map, fun) { erl_filter(fun, map) } -external fn erl_take(List(k), MapDict(k, v)) -> MapDict(k, v) = "maps" "with" +external fn erl_take(List(k), Map(k, v)) -> Map(k, v) = "maps" "with" pub fn take(map, keys) { erl_take(keys, map) } -pub external fn merge(MapDict(k, v), MapDict(k, v)) -> MapDict(k, v) = "maps" "merge" +pub external fn merge(Map(k, v), Map(k, v)) -> Map(k, v) = "maps" "merge" -external fn erl_delete(k, MapDict(k, v)) -> MapDict(k, v) = "maps" "remove" +external fn erl_delete(k, Map(k, v)) -> Map(k, v) = "maps" "remove" pub fn delete(map, key) { erl_delete(key, map) diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index 480518a..3bb762d 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -88,5 +88,5 @@ parse_float(String) -> {ok, Float}; _ -> - {error, parse_error} + {error, nil} end. |