aboutsummaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-11-24 22:13:34 +0000
committerLouis Pilfold <louis@lpil.uk>2019-11-25 11:22:45 +0000
commit69b0e8e1abb78db55cbdbd8db3ba4fe75b743e60 (patch)
tree47eec11c69fecb4033b33bd0987992e51b41f49c /gen
parent09bd0a89dd80500d99589646a738c45c9537091a (diff)
downloadgleam_stdlib-69b0e8e1abb78db55cbdbd8db3ba4fe75b743e60.tar.gz
gleam_stdlib-69b0e8e1abb78db55cbdbd8db3ba4fe75b743e60.zip
Update for Gleam v0.5
Diffstat (limited to 'gen')
-rw-r--r--gen/src/gleam@any.erl5
-rw-r--r--gen/src/gleam@pair.erl20
-rw-r--r--gen/src/gleam@triple.erl16
-rw-r--r--gen/test/gleam@any_test.erl32
-rw-r--r--gen/test/gleam@triple_test.erl16
5 files changed, 12 insertions, 77 deletions
diff --git a/gen/src/gleam@any.erl b/gen/src/gleam@any.erl
index 9f2a8e6..2cedd83 100644
--- a/gen/src/gleam@any.erl
+++ b/gen/src/gleam@any.erl
@@ -1,7 +1,7 @@
-module(gleam@any).
-compile(no_auto_import).
--export([from/1, unsafe_coerce/1, string/1, int/1, float/1, atom/1, bool/1, thunk/1, list/2, pair/1, field/2]).
+-export([from/1, unsafe_coerce/1, string/1, int/1, float/1, atom/1, bool/1, thunk/1, list/2, field/2]).
from(A) ->
gleam_stdlib:identity(A).
@@ -36,8 +36,5 @@ list(Any, DecoderType) ->
fun(Capture1) -> gleam@list:traverse(Capture1, DecoderType) end
).
-pair(A) ->
- gleam_stdlib:decode_pair(A).
-
field(A, B) ->
gleam_stdlib:decode_field(A, B).
diff --git a/gen/src/gleam@pair.erl b/gen/src/gleam@pair.erl
index 0f8e8be..3c07918 100644
--- a/gen/src/gleam@pair.erl
+++ b/gen/src/gleam@pair.erl
@@ -3,22 +3,22 @@
-export([first/1, second/1, swap/1, map_first/2, map_second/2]).
-first(Tup) ->
- {A, _} = Tup,
+first(Pair) ->
+ {A, _} = Pair,
A.
-second(Tup) ->
- {_, A} = Tup,
+second(Pair) ->
+ {_, A} = Pair,
A.
-swap(Tup) ->
- {A, B} = Tup,
+swap(Pair) ->
+ {A, B} = Pair,
{B, A}.
-map_first(Tup, Fun) ->
- {A, B} = Tup,
+map_first(Pair, Fun) ->
+ {A, B} = Pair,
{Fun(A), B}.
-map_second(Tup, Fun) ->
- {A, B} = Tup,
+map_second(Pair, Fun) ->
+ {A, B} = Pair,
{A, Fun(B)}.
diff --git a/gen/src/gleam@triple.erl b/gen/src/gleam@triple.erl
deleted file mode 100644
index 62a32da..0000000
--- a/gen/src/gleam@triple.erl
+++ /dev/null
@@ -1,16 +0,0 @@
--module(gleam@triple).
--compile(no_auto_import).
-
--export([first/1, second/1, third/1]).
-
-first(Trip) ->
- {A, _, _} = Trip,
- A.
-
-second(Trip) ->
- {_, A, _} = Trip,
- A.
-
-third(Trip) ->
- {_, _, A} = Trip,
- A.
diff --git a/gen/test/gleam@any_test.erl b/gen/test/gleam@any_test.erl
index ed58ebf..b7e472d 100644
--- a/gen/test/gleam@any_test.erl
+++ b/gen/test/gleam@any_test.erl
@@ -1,7 +1,7 @@
-module(gleam@any_test).
-compile(no_auto_import).
--export([string_test/0, int_test/0, float_test/0, thunk_test/0, bool_test/0, atom_test/0, list_test/0, pair_test/0, field_test/0]).
+-export([string_test/0, int_test/0, float_test/0, thunk_test/0, bool_test/0, atom_test/0, list_test/0, field_test/0]).
string_test() ->
gleam@expect:equal(gleam@any:string(gleam@any:from(<<"">>)), {ok, <<"">>}),
@@ -117,36 +117,6 @@ list_test() ->
)
).
-pair_test() ->
- gleam@expect:equal(
- gleam@any:pair(gleam@any:from({1, []})),
- {ok, {gleam@any:from(1), gleam@any:from([])}}
- ),
- gleam@expect:equal(
- gleam@any:pair(gleam@any:from({<<"ok">>, <<"ok">>})),
- {ok, {gleam@any:from(<<"ok">>), gleam@any:from(<<"ok">>)}}
- ),
- gleam@expect:equal(
- gleam@result:then(
- gleam@result:then(
- gleam@any:pair(gleam@any:from({1, 2.0})),
- fun(X) ->
- gleam@result:map(
- gleam@any:int(gleam@pair:first(X)),
- fun(F) -> {F, gleam@pair:second(X)} end
- )
- end
- ),
- fun(X) ->
- gleam@result:map(
- gleam@any:float(gleam@pair:second(X)),
- fun(F) -> {gleam@pair:first(X), F} end
- )
- end
- ),
- {ok, {1, 2.0}}
- ).
-
field_test() ->
{ok, OkAtom} = gleam@atom:from_string(<<"ok">>),
{ok, ErrorAtom} = gleam@atom:from_string(<<"error">>),
diff --git a/gen/test/gleam@triple_test.erl b/gen/test/gleam@triple_test.erl
deleted file mode 100644
index b143e31..0000000
--- a/gen/test/gleam@triple_test.erl
+++ /dev/null
@@ -1,16 +0,0 @@
--module(gleam@triple_test).
--compile(no_auto_import).
-
--export([first_test/0, second_test/0, third_test/0]).
-
-first_test() ->
- gleam@expect:equal(gleam@triple:first({1, 2, 3}), 1),
- gleam@expect:equal(gleam@triple:first({[], <<"abc">>, 3}), []).
-
-second_test() ->
- gleam@expect:equal(gleam@triple:second({1, 2, 3}), 2),
- gleam@expect:equal(gleam@triple:second({[], <<"abc">>, 3}), <<"abc">>).
-
-third_test() ->
- gleam@expect:equal(gleam@triple:third({1, 2, 3}), 3),
- gleam@expect:equal(gleam@triple:third({[], <<"abc">>, 3}), 3).