-module(gluple). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([is_tuple/1, tuple_to_list/1, list_to_tuple/1, tuple_size/1, tuple_element/2]). -spec is_tuple(any()) -> boolean(). is_tuple(Maybe_tuple) -> erlang:is_tuple(Maybe_tuple). -spec tuple_to_list(any()) -> {ok, list(gleam@dynamic:dynamic_())} | {error, list(gleam@dynamic:decode_error())}. tuple_to_list(Tuple) -> case erlang:is_tuple(Tuple) of true -> {ok, erlang:tuple_to_list(Tuple)}; false -> {error, [{decode_error, <<"Tuple"/utf8>>, gleam@string:inspect(Tuple), []}]} end. -spec list_to_tuple(list(any())) -> gleam@dynamic:dynamic_(). list_to_tuple(List) -> erlang:list_to_tuple(List). -spec tuple_size(any()) -> {ok, integer()} | {error, list(gleam@dynamic:decode_error())}. tuple_size(Tuple) -> case erlang:is_tuple(Tuple) of true -> {ok, erlang:tuple_size(Tuple)}; false -> {error, [{decode_error, <<"Tuple"/utf8>>, gleam@string:inspect(Tuple), []}]} end. -spec tuple_element(any(), integer()) -> {ok, gleam@dynamic:dynamic_()} | {error, list(gleam@dynamic:decode_error())}. tuple_element(Tuple, Index) -> case erlang:is_tuple(Tuple) of true -> Tuple_size = erlang:tuple_size(Tuple), case (Index >= 0) andalso (Index < Tuple_size) of true -> {ok, erlang:element(Index + 1, Tuple)}; false -> {error, [{decode_error, <<"Tuple size "/utf8, (gleam@int:to_string(Tuple_size))/binary>>, <<"Desired index "/utf8, (gleam@int:to_string(Index))/binary>>, []}]} end; false -> {error, [{decode_error, <<"Tuple"/utf8>>, gleam@string:inspect(Tuple), []}]} end.