Current section
Files
Jump to
Current section
Files
src/deriv@example@bar.erl
-module(deriv@example@bar).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([decoder_baz/0, encode_baz/1]).
-export_type([baz/0]).
-type baz() :: {baz, integer(), binary(), boolean()}.
-file("/home/bosco/dev/gleam/deriv/src/deriv/example/bar.gleam", 13).
-spec decoder_baz() -> decode:decoder(baz()).
decoder_baz() ->
_pipe = decode:into(
(decode:parameter(
fun(Id) ->
decode:parameter(
fun(Name) ->
decode:parameter(
fun(Active) -> {baz, Id, Name, Active} end
)
end
)
end
))
),
_pipe@1 = decode:field(
_pipe,
<<"id"/utf8>>,
{decoder, fun gleam@dynamic:int/1}
),
_pipe@2 = decode:field(
_pipe@1,
<<"name"/utf8>>,
{decoder, fun gleam@dynamic:string/1}
),
decode:field(
_pipe@2,
<<"active"/utf8>>,
{decoder, fun gleam@dynamic:bool/1}
).
-file("/home/bosco/dev/gleam/deriv/src/deriv/example/bar.gleam", 26).
-spec encode_baz(baz()) -> gleam@json:json().
encode_baz(Value) ->
gleam@json:object(
[{<<"id"/utf8>>, gleam@json:int(erlang:element(2, Value))},
{<<"name"/utf8>>, gleam@json:string(erlang:element(3, Value))},
{<<"active"/utf8>>, gleam@json:bool(erlang:element(4, Value))}]
).