Current section

Files

Jump to
gleam_stdlib gen src gleam@dynamic.erl
Raw

gen/src/gleam@dynamic.erl

-module(gleam@dynamic).
-compile(no_auto_import).
-export([from/1, unsafe_coerce/1, string/1, int/1, float/1, atom/1, bool/1, thunk/1, opaque_list/1, list/2, field/2, element/2, tuple2/1, tuple2_of/3, map/1]).
from(A) ->
gleam_stdlib:identity(A).
unsafe_coerce(A) ->
gleam_stdlib:identity(A).
string(A) ->
gleam_stdlib:decode_string(A).
int(A) ->
gleam_stdlib:decode_int(A).
float(A) ->
gleam_stdlib:decode_float(A).
atom(A) ->
gleam_stdlib:decode_atom(A).
bool(A) ->
gleam_stdlib:decode_bool(A).
thunk(A) ->
gleam_stdlib:decode_thunk(A).
opaque_list(A) ->
gleam_stdlib:decode_list(A).
list(Dynamic, DecoderType) ->
gleam@result:then(
gleam_stdlib:decode_list(Dynamic),
fun(GleamCaptureVariable) ->
gleam@list:traverse(GleamCaptureVariable, DecoderType)
end
).
field(A, B) ->
gleam_stdlib:decode_field(A, B).
element(A, B) ->
gleam_stdlib:decode_element(A, B).
tuple2(A) ->
gleam_stdlib:decode_tuple2(A).
tuple2_of(Tup, DecodeFirst, DecodeSecond) ->
case gleam_stdlib:decode_tuple2(Tup) of
{error, GleamTryError} -> {error, GleamTryError};
{ok, {First, Second}} ->
case DecodeFirst(First) of
{error, GleamTryError1} -> {error, GleamTryError1};
{ok, A} ->
case DecodeSecond(Second) of
{error, GleamTryError2} -> {error, GleamTryError2};
{ok, B} ->
{ok, {A, B}}
end
end
end.
map(A) ->
gleam_stdlib:decode_map(A).