We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dcf7b56 commit 7ef601eCopy full SHA for 7ef601e
gen/src/[email protected]
@@ -24,7 +24,7 @@ contains(List, Elem) ->
24
head(List) ->
25
case List of
26
[] ->
27
- {error, empty};
+ {error, {}};
28
29
[X | _] ->
30
{ok, X}
@@ -33,7 +33,7 @@ head(List) ->
33
tail(List) ->
34
35
36
37
38
[_ | Xs] ->
39
{ok, Xs}
@@ -172,7 +172,7 @@ fold_right(List, Acc, Fun) ->
172
find(Haystack, F) ->
173
case Haystack of
174
175
- {error, not_found};
176
177
[X | Rest] ->
178
case F(X) of
@@ -232,7 +232,7 @@ strict_zip(L1, L2) ->
232
{ok, zip(L1, L2)};
233
234
false ->
235
- {error, length_mismatch}
+ {error, {}}
236
end.
237
238
intersperse(List, Elem) ->
@@ -250,12 +250,12 @@ intersperse(List, Elem) ->
250
at(List, I) ->
251
case I < 0 of
252
true ->
253
254
255
256
257
258
259
260
261
case I =:= 0 of
@@ -72,7 +72,7 @@ update(Dict, Key, F) ->
72
put(Dict, Key, F({ok, Value}));
73
74
{error, _} ->
75
- put(Dict, Key, F({error, not_found}))
+ put(Dict, Key, F({error, nil}))
76
77
78
do_fold(List, Acc, F) ->
src/gleam/int.gleam
@@ -1,9 +1,6 @@
1
import gleam/order
2
3
-pub enum NotAnInt =
4
- | NotAnInt
5
-
6
-pub external fn parse(String) -> Result(Int, NotAnInt) = "gleam__stdlib" "parse_int";
+pub external fn parse(String) -> Result(Int, Nil) = "gleam__stdlib" "parse_int";
7
8
pub external fn to_string(Int) -> String = "erlang" "integer_to_binary"
9
src/gleam/list.gleam
@@ -2,14 +2,7 @@ import gleam/int
import gleam/pair
-pub enum Empty =
- | Empty
-pub enum NotFound =
- | NotFound
10
11
-pub enum LengthMismatch =
12
- | LengthMismatch
+pub struct LengthMismatch {}
13
14
// Using the Erlang C BIF implementation.
15
//
@@ -32,14 +25,14 @@ pub fn contains(list, elem) {
32
pub fn head(list) {
case list {
- | [] -> Error(Empty)
+ | [] -> Error(Nil)
| [x | _] -> Ok(x)
}
31
40
pub fn tail(list) {
41
42
43
| [_ | xs] -> Ok(xs)
44
45
@@ -157,7 +150,7 @@ pub fn fold_right(list, acc, fun) {
157
150
158
151
pub fn find(haystack, f) {
159
152
case haystack {
160
- | [] -> Error(NotFound)
153
161
154
| [x | rest] ->
162
155
case f(x) {
163
156
| Ok(x) -> Ok(x)
@@ -213,10 +206,10 @@ pub fn intersperse(list, elem) {
213
206
214
207
pub fn at(list, i) {
215
208
case i < 0 {
216
- | True -> Error(NotFound)
209
+ | True -> Error(Nil)
217
210
| False ->
218
211
219
212
220
221
case i == 0 {
222
| True -> Ok(x)
src/gleam/map.gleam
@@ -5,9 +5,6 @@ import gleam/pair
pub external type MapDict(key, value);
pub external fn size(MapDict(k, v)) -> Int
= "maps" "size"
@@ -27,7 +24,7 @@ pub fn has_key(map, key) {
pub external fn new() -> MapDict(key, value)
= "maps" "new"
-pub external fn fetch(MapDict(key, value), key) -> Result(value, NotFound)
+pub external fn fetch(MapDict(key, value), key) -> Result(value, Nil)
= "gleam__stdlib" "map_fetch";
external fn erl_put(key, value, MapDict(key, value)) -> MapDict(key, value)
@@ -79,12 +76,10 @@ pub fn drop(map, keys) {
79
})
80
81
82
-pub external type NotFound;
83
84
pub fn update(dict, key, f) {
85
case fetch(dict, key) {
86
| Ok(value) -> put(dict, key, f(Ok(value)))
87
- | Error(_) -> put(dict, key, f(Error(NotFound)))
+ | Error(_) -> put(dict, key, f(Error(Nil)))
88
89
90
src/gleam__stdlib.erl
@@ -17,7 +17,7 @@ expect_is_error(A) -> ?assertMatch({error, _}, A).
17
18
map_fetch(Map, Key) ->
19
case maps:find(Key, Map) of
20
- error -> {error, not_found};
+ error -> {error, nil};
21
OkFound -> OkFound
22
23
@@ -79,7 +79,7 @@ parse_int(String) ->
{ok, Integer};
_ ->
- {error, parse_error}
+ {error, nil}
parse_float(String) ->
0 commit comments