-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, binary()}. tuple_to_list(Tuple) -> case erlang:is_tuple(Tuple) of true -> {ok, erlang:tuple_to_list(Tuple)}; false -> {error, <<"Non tuple passed: "/utf8, (gleam@string:inspect(Tuple))/binary>>} end. -spec list_to_tuple(list(any())) -> any(). list_to_tuple(List) -> erlang:list_to_tuple(List). -spec tuple_size(any()) -> {ok, integer()} | {error, binary()}. tuple_size(Tuple) -> case erlang:is_tuple(Tuple) of true -> {ok, erlang:tuple_size(Tuple)}; false -> {error, <<"Non tuple passed: "/utf8, (gleam@string:inspect(Tuple))/binary>>} end. -spec tuple_element(any(), integer()) -> {ok, any()} | {error, binary()}. 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, <<<<<<"Tuple index out of range; tuple size: "/utf8, (gleam@int:to_string(Tuple_size))/binary>>/binary, ", index: "/utf8>>/binary, (gleam@int:to_string(Index))/binary>>} end; false -> {error, <<"Non tuple passed: "/utf8, (gleam@string:inspect(Tuple))/binary>>} end.