Skip to content

Commit fa47fcb

Browse files
committed
Improve erl formatting
1 parent 02fd6d9 commit fa47fcb

10 files changed

+512
-333
lines changed

gen/src/[email protected]

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ list_any(A) ->
3131
gleam__stdlib:decode_list(A).
3232

3333
list(Any, Decode) ->
34-
gleam@result:then(list_any(Any),
35-
fun(Capture1) ->
36-
gleam@list:traverse(Capture1, Decode)
37-
end).
34+
gleam@result:then(
35+
list_any(Any),
36+
fun(Capture1) -> gleam@list:traverse(Capture1, Decode) end
37+
).
3838

3939
tuple(A) ->
4040
gleam__stdlib:decode_tuple(A).

gen/src/[email protected]

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ reverse(String) ->
1616
gleam@iodata:to_string(gleam@iodata:reverse(gleam@iodata:new(String))).
1717

1818
split(String, On) ->
19-
gleam@list:map(gleam@iodata:split(gleam@iodata:new(String), On),
20-
fun gleam@iodata:to_string/1).
19+
gleam@list:map(
20+
gleam@iodata:split(gleam@iodata:new(String), On),
21+
fun gleam@iodata:to_string/1
22+
).
2123

2224
replace(String, Pattern, With) ->
23-
gleam@iodata:to_string(gleam@iodata:replace(gleam@iodata:new(String),
24-
Pattern,
25-
With)).
25+
gleam@iodata:to_string(
26+
gleam@iodata:replace(gleam@iodata:new(String), Pattern, With)
27+
).
2628

2729
append(S1, S2) ->
2830
gleam@iodata:to_string(gleam@iodata:append(gleam@iodata:new(S1), S2)).

gen/src/[email protected]

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ swap(Tup) ->
2020

2121
fetch(Haystack, Needle) ->
2222
gleam@list:find(Haystack, fun(Tuple) -> case first(Tuple) =:= Needle of
23-
true ->
24-
{ok, second(Tuple)};
23+
true ->
24+
{ok, second(Tuple)};
2525

26-
false ->
27-
{error, []}
28-
end end).
26+
false ->
27+
{error, []}
28+
end end).

gen/test/gleam@any_test.erl

Lines changed: 123 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -5,114 +5,160 @@
55

66
string_test() ->
77
gleam@expect:equal(gleam@any:string(gleam@any:from(<<"">>)), {ok, <<"">>}),
8-
gleam@expect:equal(gleam@any:string(gleam@any:from(<<"Hello">>)),
9-
{ok, <<"Hello">>}),
10-
gleam@expect:equal(gleam@any:string(gleam@any:from(1)),
11-
{error, <<"Expected a String, got `1`">>}),
12-
gleam@expect:equal(gleam@any:string(gleam@any:from([])),
13-
{error, <<"Expected a String, got `[]`">>}).
8+
gleam@expect:equal(
9+
gleam@any:string(gleam@any:from(<<"Hello">>)),
10+
{ok, <<"Hello">>}
11+
),
12+
gleam@expect:equal(
13+
gleam@any:string(gleam@any:from(1)),
14+
{error, <<"Expected a String, got `1`">>}
15+
),
16+
gleam@expect:equal(
17+
gleam@any:string(gleam@any:from([])),
18+
{error, <<"Expected a String, got `[]`">>}
19+
).
1420

1521
int_test() ->
1622
gleam@expect:equal(gleam@any:int(gleam@any:from(1)), {ok, 1}),
1723
gleam@expect:equal(gleam@any:int(gleam@any:from(2)), {ok, 2}),
18-
gleam@expect:equal(gleam@any:int(gleam@any:from(1.0)),
19-
{error, <<"Expected an Int, got `1.0`">>}),
20-
gleam@expect:equal(gleam@any:int(gleam@any:from([])),
21-
{error, <<"Expected an Int, got `[]`">>}).
24+
gleam@expect:equal(
25+
gleam@any:int(gleam@any:from(1.0)),
26+
{error, <<"Expected an Int, got `1.0`">>}
27+
),
28+
gleam@expect:equal(
29+
gleam@any:int(gleam@any:from([])),
30+
{error, <<"Expected an Int, got `[]`">>}
31+
).
2232

2333
float_test() ->
2434
gleam@expect:equal(gleam@any:float(gleam@any:from(1.0)), {ok, 1.0}),
2535
gleam@expect:equal(gleam@any:float(gleam@any:from(2.2)), {ok, 2.2}),
26-
gleam@expect:equal(gleam@any:float(gleam@any:from(1)),
27-
{error, <<"Expected a Float, got `1`">>}),
28-
gleam@expect:equal(gleam@any:float(gleam@any:from([])),
29-
{error, <<"Expected a Float, got `[]`">>}).
36+
gleam@expect:equal(
37+
gleam@any:float(gleam@any:from(1)),
38+
{error, <<"Expected a Float, got `1`">>}
39+
),
40+
gleam@expect:equal(
41+
gleam@any:float(gleam@any:from([])),
42+
{error, <<"Expected a Float, got `[]`">>}
43+
).
3044

3145
thunk_test() ->
3246
gleam@expect:is_ok(gleam@any:thunk(gleam@any:from(fun() -> 1 end))),
33-
gleam@expect:equal(gleam@result:map(gleam@any:thunk(gleam@any:from(fun() ->
34-
1
35-
end)),
36-
fun(F) -> F() end),
37-
{ok, gleam@any:from(1)}),
47+
gleam@expect:equal(
48+
gleam@result:map(
49+
gleam@any:thunk(gleam@any:from(fun() -> 1 end)),
50+
fun(F) -> F() end
51+
),
52+
{ok, gleam@any:from(1)}
53+
),
3854
gleam@expect:is_error(gleam@any:thunk(gleam@any:from(fun(X) -> X end))),
3955
gleam@expect:is_error(gleam@any:thunk(gleam@any:from(1))),
4056
gleam@expect:is_error(gleam@any:thunk(gleam@any:from([]))).
4157

4258
bool_test() ->
4359
gleam@expect:equal(gleam@any:bool(gleam@any:from(true)), {ok, true}),
4460
gleam@expect:equal(gleam@any:bool(gleam@any:from(false)), {ok, false}),
45-
gleam@expect:equal(gleam@any:bool(gleam@any:from(1)),
46-
{error, <<"Expected a Bool, got `1`">>}),
47-
gleam@expect:equal(gleam@any:bool(gleam@any:from([])),
48-
{error, <<"Expected a Bool, got `[]`">>}).
61+
gleam@expect:equal(
62+
gleam@any:bool(gleam@any:from(1)),
63+
{error, <<"Expected a Bool, got `1`">>}
64+
),
65+
gleam@expect:equal(
66+
gleam@any:bool(gleam@any:from([])),
67+
{error, <<"Expected a Bool, got `[]`">>}
68+
).
4969

5070
atom_test() ->
51-
gleam@expect:equal(gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"">>))),
52-
{ok, gleam@atom:create_from_string(<<"">>)}),
53-
gleam@expect:equal(gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"ok">>))),
54-
{ok, gleam@atom:create_from_string(<<"ok">>)}),
71+
gleam@expect:equal(
72+
gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"">>))),
73+
{ok, gleam@atom:create_from_string(<<"">>)}
74+
),
75+
gleam@expect:equal(
76+
gleam@any:atom(gleam@any:from(gleam@atom:create_from_string(<<"ok">>))),
77+
{ok, gleam@atom:create_from_string(<<"ok">>)}
78+
),
5579
gleam@expect:is_error(gleam@any:atom(gleam@any:from(1))),
5680
gleam@expect:is_error(gleam@any:atom(gleam@any:from([]))).
5781

5882
list_test() ->
59-
gleam@expect:equal(gleam@any:list(gleam@any:from([]),
60-
fun gleam@any:string/1),
61-
{ok, []}),
62-
gleam@expect:equal(gleam@any:list(gleam@any:from([]), fun gleam@any:int/1),
63-
{ok, []}),
64-
gleam@expect:equal(gleam@any:list(gleam@any:from([1, 2, 3]),
65-
fun gleam@any:int/1),
66-
{ok, [1, 2, 3]}),
67-
gleam@expect:equal(gleam@any:list(gleam@any:from([[1], [2], [3]]),
68-
fun(Capture1) ->
69-
gleam@any:list(Capture1,
70-
fun gleam@any:int/1)
71-
end),
72-
{ok, [[1], [2], [3]]}),
73-
gleam@expect:is_error(gleam@any:list(gleam@any:from(1),
74-
fun gleam@any:string/1)),
75-
gleam@expect:is_error(gleam@any:list(gleam@any:from(1.0),
76-
fun gleam@any:int/1)),
77-
gleam@expect:is_error(gleam@any:list(gleam@any:from([<<"">>]),
78-
fun gleam@any:int/1)),
79-
gleam@expect:is_error(gleam@any:list(gleam@any:from([gleam@any:from(1),
80-
gleam@any:from(<<"not an int">>)]),
81-
fun gleam@any:int/1)).
83+
gleam@expect:equal(
84+
gleam@any:list(gleam@any:from([]), fun gleam@any:string/1),
85+
{ok, []}
86+
),
87+
gleam@expect:equal(
88+
gleam@any:list(gleam@any:from([]), fun gleam@any:int/1),
89+
{ok, []}
90+
),
91+
gleam@expect:equal(
92+
gleam@any:list(gleam@any:from([1, 2, 3]), fun gleam@any:int/1),
93+
{ok, [1, 2, 3]}
94+
),
95+
gleam@expect:equal(
96+
gleam@any:list(
97+
gleam@any:from([[1], [2], [3]]),
98+
fun(Capture1) -> gleam@any:list(Capture1, fun gleam@any:int/1) end
99+
),
100+
{ok, [[1], [2], [3]]}
101+
),
102+
gleam@expect:is_error(
103+
gleam@any:list(gleam@any:from(1), fun gleam@any:string/1)
104+
),
105+
gleam@expect:is_error(
106+
gleam@any:list(gleam@any:from(1.0), fun gleam@any:int/1)
107+
),
108+
gleam@expect:is_error(
109+
gleam@any:list(gleam@any:from([<<"">>]), fun gleam@any:int/1)
110+
),
111+
gleam@expect:is_error(
112+
gleam@any:list(
113+
gleam@any:from(
114+
[gleam@any:from(1), gleam@any:from(<<"not an int">>)]
115+
),
116+
fun gleam@any:int/1
117+
)
118+
).
82119

83120
tuple_test() ->
84-
gleam@expect:equal(gleam@any:tuple(gleam@any:from({1, []})),
85-
{ok, {gleam@any:from(1), gleam@any:from([])}}),
86-
gleam@expect:equal(gleam@any:tuple(gleam@any:from({<<"ok">>, <<"ok">>})),
87-
{ok,
88-
{gleam@any:from(<<"ok">>), gleam@any:from(<<"ok">>)}}),
121+
gleam@expect:equal(
122+
gleam@any:tuple(gleam@any:from({1, []})),
123+
{ok, {gleam@any:from(1), gleam@any:from([])}}
124+
),
125+
gleam@expect:equal(
126+
gleam@any:tuple(gleam@any:from({<<"ok">>, <<"ok">>})),
127+
{ok, {gleam@any:from(<<"ok">>), gleam@any:from(<<"ok">>)}}
128+
),
89129
gleam@expect:is_error(gleam@any:tuple(gleam@any:from({1}))),
90130
gleam@expect:is_error(gleam@any:tuple(gleam@any:from({1, 2, 3}))),
91-
gleam@expect:equal(gleam@result:then(gleam@result:then(gleam@any:tuple(gleam@any:from({1,
92-
2.0})),
93-
fun(X) ->
94-
gleam@result:map(gleam@any:int(gleam@tuple:first(X)),
95-
fun(F) ->
96-
{F,
97-
gleam@tuple:second(X)}
98-
end)
99-
end),
100-
fun(X) ->
101-
gleam@result:map(gleam@any:float(gleam@tuple:second(X)),
102-
fun(F) ->
103-
{gleam@tuple:first(X),
104-
F}
105-
end)
106-
end),
107-
{ok, {1, 2.0}}).
131+
gleam@expect:equal(
132+
gleam@result:then(
133+
gleam@result:then(
134+
gleam@any:tuple(gleam@any:from({1, 2.0})),
135+
fun(X) ->
136+
gleam@result:map(
137+
gleam@any:int(gleam@tuple:first(X)),
138+
fun(F) -> {F, gleam@tuple:second(X)} end
139+
)
140+
end
141+
),
142+
fun(X) ->
143+
gleam@result:map(
144+
gleam@any:float(gleam@tuple:second(X)),
145+
fun(F) -> {gleam@tuple:first(X), F} end
146+
)
147+
end
148+
),
149+
{ok, {1, 2.0}}
150+
).
108151

109152
field_test() ->
110153
{ok, OkAtom} = gleam@atom:from_string(<<"ok">>),
111-
gleam@expect:equal(gleam@any:field(gleam@any:from(#{}#{ok => 1}), OkAtom),
112-
{ok, gleam@any:from(1)}),
113-
gleam@expect:equal(gleam@any:field(gleam@any:from(#{}#{ok => 3}#{earlier => 2}),
114-
OkAtom),
115-
{ok, gleam@any:from(3)}),
154+
gleam@expect:equal(
155+
gleam@any:field(gleam@any:from(#{}#{ok => 1}), OkAtom),
156+
{ok, gleam@any:from(1)}
157+
),
158+
gleam@expect:equal(
159+
gleam@any:field(gleam@any:from(#{}#{ok => 3}#{earlier => 2}), OkAtom),
160+
{ok, gleam@any:from(3)}
161+
),
116162
gleam@expect:is_error(gleam@any:field(gleam@any:from(#{}), OkAtom)),
117163
gleam@expect:is_error(gleam@any:field(gleam@any:from(1), OkAtom)),
118164
gleam@expect:is_error(gleam@any:field(gleam@any:from([]), [])).

gen/test/gleam@atom_test.erl

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,35 @@
66
from_string_test() ->
77
gleam@expect:is_ok(gleam@atom:from_string(<<"ok">>)),
88
gleam@expect:is_ok(gleam@atom:from_string(<<"expect">>)),
9-
gleam@expect:is_error(gleam@atom:from_string(<<"this is not an atom we have seen before">>)).
9+
gleam@expect:is_error(
10+
gleam@atom:from_string(<<"this is not an atom we have seen before">>)
11+
).
1012

1113
create_from_string_test() ->
12-
gleam@expect:equal({ok, gleam@atom:create_from_string(<<"ok">>)},
13-
gleam@atom:from_string(<<"ok">>)),
14-
gleam@expect:equal({ok, gleam@atom:create_from_string(<<"expect">>)},
15-
gleam@atom:from_string(<<"expect">>)),
16-
gleam@expect:equal({ok,
17-
gleam@atom:create_from_string(<<"this is another atom we have not seen before">>)},
18-
gleam@atom:from_string(<<"this is another atom we have not seen before">>)).
14+
gleam@expect:equal(
15+
{ok, gleam@atom:create_from_string(<<"ok">>)},
16+
gleam@atom:from_string(<<"ok">>)
17+
),
18+
gleam@expect:equal(
19+
{ok, gleam@atom:create_from_string(<<"expect">>)},
20+
gleam@atom:from_string(<<"expect">>)
21+
),
22+
gleam@expect:equal(
23+
{ok,
24+
gleam@atom:create_from_string(
25+
<<"this is another atom we have not seen before">>
26+
)},
27+
gleam@atom:from_string(
28+
<<"this is another atom we have not seen before">>
29+
)
30+
).
1931

2032
to_string_test() ->
21-
gleam@expect:equal(gleam@atom:to_string(gleam@atom:create_from_string(<<"ok">>)),
22-
<<"ok">>),
23-
gleam@expect:equal(gleam@atom:to_string(gleam@atom:create_from_string(<<"expect">>)),
24-
<<"expect">>).
33+
gleam@expect:equal(
34+
gleam@atom:to_string(gleam@atom:create_from_string(<<"ok">>)),
35+
<<"ok">>
36+
),
37+
gleam@expect:equal(
38+
gleam@atom:to_string(gleam@atom:create_from_string(<<"expect">>)),
39+
<<"expect">>
40+
).

0 commit comments

Comments
 (0)