aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2020-05-19 18:27:10 +0100
committerLouis Pilfold <louis@lpil.uk>2020-05-19 19:22:49 +0100
commitcbf07061be7524aa049864b6dec49715e641499a (patch)
tree8a409378ba4e94461ad13d29d97b29d3a6322bdc /src/gleam_stdlib.erl
parentf3c4b7a3170fb4beb7483bba929d1eca616f48df (diff)
downloadgleam_stdlib-cbf07061be7524aa049864b6dec49715e641499a.tar.gz
gleam_stdlib-cbf07061be7524aa049864b6dec49715e641499a.zip
dynamic.{tuple2, tuple2_of}
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index bbf7630..e12ee87 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -1,13 +1,15 @@
-module(gleam_stdlib).
-include_lib("eunit/include/eunit.hrl").
--export([should_equal/2, should_not_equal/2, should_be_true/1, should_be_false/1,
- should_be_ok/1, should_be_error/1, atom_from_string/1,
- atom_create_from_string/1, atom_to_string/1, map_get/2,
- iodata_append/2, iodata_prepend/2, identity/1, decode_int/1,
- decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, decode_atom/1,
- decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2,
- string_contains/2, string_starts_with/2, string_ends_with/2, string_pad/4]).
+-export([should_equal/2, should_not_equal/2, should_be_true/1,
+ should_be_false/1, should_be_ok/1, should_be_error/1,
+ atom_from_string/1, atom_create_from_string/1, atom_to_string/1,
+ map_get/2, iodata_append/2, iodata_prepend/2, identity/1,
+ decode_int/1, decode_string/1, decode_bool/1, decode_float/1,
+ decode_thunk/1, decode_atom/1, decode_list/1, decode_field/2,
+ decode_element/2, parse_int/1, parse_float/1, compare_strings/2,
+ string_contains/2, string_starts_with/2, string_ends_with/2,
+ string_pad/4, decode_tuple2/1]).
should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual).
should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual).
@@ -48,8 +50,12 @@ classify(X) when is_float(X) -> "a float";
classify(X) when is_list(X) -> "a list";
classify(X) when is_boolean(X) -> "a bool";
classify(X) when is_function(X, 0) -> "a zero arity function";
+classify(X) when is_tuple(X) -> ["a ", integer_to_list(tuple_size(X)), " element tuple"];
classify(_) -> "some other type".
+decode_tuple2({_, _} = T) -> {ok, T};
+decode_tuple2(Data) -> decode_error_msg("a 2 element tuple", Data).
+
decode_atom(Data) when is_atom(Data) -> {ok, Data};
decode_atom(Data) -> decode_error_msg("an atom", Data).