Current section

Files

Jump to
gleamgen src gleamgen@module.erl
Raw

src/gleamgen@module.erl

-module(gleamgen@module).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([with_constant/3, with_import/2, with_imports_unchecked/2, with_function/3, with_custom_type1/3, with_custom_type2/3, with_custom_type3/3, with_custom_type4/3, with_custom_type5/3, with_custom_type6/3, with_custom_type7/3, with_custom_type8/3, with_custom_type9/3, with_custom_type_unchecked/3, with_type_alias/3, eof/0, render_function/3, render/2, render_imported_module/1]).
-export_type([definition/0, attribute/0, definition_details/0, definable/0, module_/0]).
-type definition() :: {definition, definition_details(), definable()}.
-type attribute() :: external_erlang |
external_javascript |
{deprecated, binary()} |
internal.
-type definition_details() :: {definition_details,
binary(),
boolean(),
list(attribute())}.
-type definable() :: {function,
gleamgen@function:function_(gleamgen@types:unchecked(), gleamgen@types:unchecked())} |
{custom_type,
gleamgen@types@custom:custom_type(gleamgen@types:unchecked(), nil, nil)} |
{constant, gleamgen@expression:expression(gleamgen@types:unchecked())} |
{type_alias, gleamgen@types:generated_type(gleamgen@types:unchecked())}.
-type module_() :: {module,
list(definition()),
list(gleamgen@import_:imported_module())}.
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 40).
-spec with_constant(
definition_details(),
gleamgen@expression:expression(KWZ),
fun((gleamgen@expression:expression(KWZ)) -> module_())
) -> module_().
with_constant(Details, Value, Handler) ->
Rest = Handler(
gleamgen@expression:unchecked_ident(erlang:element(2, Details))
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{constant,
begin
_pipe = Value,
gleamgen_ffi:identity(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 55).
-spec with_import(
gleamgen@import_:imported_module(),
fun((gleamgen@import_:imported_module()) -> module_())
) -> module_().
with_import(Module, Handler) ->
Rest = Handler(Module),
erlang:setelement(3, Rest, [Module | erlang:element(3, Rest)]).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 63).
-spec with_imports_unchecked(
list(gleamgen@import_:imported_module()),
fun((list(gleamgen@import_:imported_module())) -> module_())
) -> module_().
with_imports_unchecked(Modules, Handler) ->
Rest = Handler(Modules),
erlang:setelement(
3,
Rest,
lists:append(lists:reverse(Modules), erlang:element(3, Rest))
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 71).
-spec with_function(
definition_details(),
gleamgen@function:function_(KXE, any()),
fun((gleamgen@expression:expression(KXE)) -> module_())
) -> module_().
with_function(Details, Func, Handler) ->
Rest = Handler(
gleamgen@expression:unchecked_ident(erlang:element(2, Details))
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{function,
begin
_pipe = Func,
gleamgen_ffi:identity(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 86).
-spec with_custom_type1(
definition_details(),
gleamgen@types@custom:custom_type(KXJ, {{}, KXK}, any()),
fun((gleamgen@types:generated_type(KXJ), gleamgen@expression@constructor:construtor(KXJ, KXK)) -> module_())
) -> module_().
with_custom_type1(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant1] = case _assert_subject of
[_] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type1"/utf8>>,
line => 92})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 104).
-spec with_custom_type2(
definition_details(),
gleamgen@types@custom:custom_type(KXS, {{{}, KXT}, KXU}, any()),
fun((gleamgen@types:generated_type(KXS), gleamgen@expression@constructor:construtor(KXS, KXT), gleamgen@expression@constructor:construtor(KXS, KXU)) -> module_())
) -> module_().
with_custom_type2(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant2, Variant1] = case _assert_subject of
[_, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type2"/utf8>>,
line => 114})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 130).
-spec with_custom_type3(
definition_details(),
gleamgen@types@custom:custom_type(KYE, {{{}, KYF}, KYG, KYH}, any()),
fun((gleamgen@types:generated_type(KYE), gleamgen@expression@constructor:construtor(KYE, KYF), gleamgen@expression@constructor:construtor(KYE, KYG), gleamgen@expression@constructor:construtor(KYE, KYH)) -> module_())
) -> module_().
with_custom_type3(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant3, Variant2, Variant1] = case _assert_subject of
[_, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type3"/utf8>>,
line => 141})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 158).
-spec with_custom_type4(
definition_details(),
gleamgen@types@custom:custom_type(KYT, {{{{}, KYU}, KYV}, KYW, KYX}, any()),
fun((gleamgen@types:generated_type(KYT), gleamgen@expression@constructor:construtor(KYT, KYU), gleamgen@expression@constructor:construtor(KYT, KYV), gleamgen@expression@constructor:construtor(KYT, KYW), gleamgen@expression@constructor:construtor(KYT, KYX)) -> module_())
) -> module_().
with_custom_type4(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant4, Variant3, Variant2, Variant1] = case _assert_subject of
[_, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type4"/utf8>>,
line => 170})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 188).
-spec with_custom_type5(
definition_details(),
gleamgen@types@custom:custom_type(KZL, {{{{{}, KZM}, KZN}, KZO}, KZP, KZQ}, any()),
fun((gleamgen@types:generated_type(KZL), gleamgen@expression@constructor:construtor(KZL, KZM), gleamgen@expression@constructor:construtor(KZL, KZN), gleamgen@expression@constructor:construtor(KZL, KZO), gleamgen@expression@constructor:construtor(KZL, KZP), gleamgen@expression@constructor:construtor(KZL, KZQ)) -> module_())
) -> module_().
with_custom_type5(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant5, Variant4, Variant3, Variant2, Variant1] = case _assert_subject of
[_, _, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type5"/utf8>>,
line => 201})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4),
gleamgen@expression@constructor:new(Variant5)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 220).
-spec with_custom_type6(
definition_details(),
gleamgen@types@custom:custom_type(LAG, {{{{{{}, LAH}, LAI}, LAJ}, LAK},
LAL,
LAM}, any()),
fun((gleamgen@types:generated_type(LAG), gleamgen@expression@constructor:construtor(LAG, LAH), gleamgen@expression@constructor:construtor(LAG, LAI), gleamgen@expression@constructor:construtor(LAG, LAJ), gleamgen@expression@constructor:construtor(LAG, LAK), gleamgen@expression@constructor:construtor(LAG, LAL), gleamgen@expression@constructor:construtor(LAG, LAM)) -> module_())
) -> module_().
with_custom_type6(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant6, Variant5, Variant4, Variant3, Variant2, Variant1] = case _assert_subject of
[_, _, _, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type6"/utf8>>,
line => 234})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4),
gleamgen@expression@constructor:new(Variant5),
gleamgen@expression@constructor:new(Variant6)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 255).
-spec with_custom_type7(
definition_details(),
gleamgen@types@custom:custom_type(LBE, {{{{{{{}, LBF}, LBG}, LBH}, LBI},
LBJ},
LBK,
LBL}, any()),
fun((gleamgen@types:generated_type(LBE), gleamgen@expression@constructor:construtor(LBE, LBF), gleamgen@expression@constructor:construtor(LBE, LBG), gleamgen@expression@constructor:construtor(LBE, LBH), gleamgen@expression@constructor:construtor(LBE, LBI), gleamgen@expression@constructor:construtor(LBE, LBJ), gleamgen@expression@constructor:construtor(LBE, LBK), gleamgen@expression@constructor:construtor(LBE, LBL)) -> module_())
) -> module_().
with_custom_type7(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant7, Variant6, Variant5, Variant4, Variant3, Variant2, Variant1] = case _assert_subject of
[_, _, _, _, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type7"/utf8>>,
line => 274})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4),
gleamgen@expression@constructor:new(Variant5),
gleamgen@expression@constructor:new(Variant6),
gleamgen@expression@constructor:new(Variant7)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 303).
-spec with_custom_type8(
definition_details(),
gleamgen@types@custom:custom_type(LCF, {{{{{{{{}, LCG}, LCH}, LCI}, LCJ},
LCK},
LCL},
LCM,
LCN}, any()),
fun((gleamgen@types:generated_type(LCF), gleamgen@expression@constructor:construtor(LCF, LCG), gleamgen@expression@constructor:construtor(LCF, LCH), gleamgen@expression@constructor:construtor(LCF, LCI), gleamgen@expression@constructor:construtor(LCF, LCJ), gleamgen@expression@constructor:construtor(LCF, LCK), gleamgen@expression@constructor:construtor(LCF, LCL), gleamgen@expression@constructor:construtor(LCF, LCM), gleamgen@expression@constructor:construtor(LCF, LCN)) -> module_())
) -> module_().
with_custom_type8(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant8,
Variant7,
Variant6,
Variant5,
Variant4,
Variant3,
Variant2,
Variant1] = case _assert_subject of
[_, _, _, _, _, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type8"/utf8>>,
line => 323})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4),
gleamgen@expression@constructor:new(Variant5),
gleamgen@expression@constructor:new(Variant6),
gleamgen@expression@constructor:new(Variant7),
gleamgen@expression@constructor:new(Variant8)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 354).
-spec with_custom_type9(
definition_details(),
gleamgen@types@custom:custom_type(LDJ, {{{{{{{{{}, LDK}, LDL}, LDM}, LDN},
LDO},
LDP},
LDQ},
LDR,
LDS}, any()),
fun((gleamgen@types:generated_type(LDJ), gleamgen@expression@constructor:construtor(LDJ, LDK), gleamgen@expression@constructor:construtor(LDJ, LDL), gleamgen@expression@constructor:construtor(LDJ, LDM), gleamgen@expression@constructor:construtor(LDJ, LDN), gleamgen@expression@constructor:construtor(LDJ, LDO), gleamgen@expression@constructor:construtor(LDJ, LDP), gleamgen@expression@constructor:construtor(LDJ, LDQ), gleamgen@expression@constructor:construtor(LDJ, LDR), gleamgen@expression@constructor:construtor(LDJ, LDS)) -> module_())
) -> module_().
with_custom_type9(Details, Type_, Handler) ->
_assert_subject = erlang:element(2, Type_),
[Variant9,
Variant8,
Variant7,
Variant6,
Variant5,
Variant4,
Variant3,
Variant2,
Variant1] = case _assert_subject of
[_, _, _, _, _, _, _, _, _] -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
value => _assert_fail,
module => <<"gleamgen/module"/utf8>>,
function => <<"with_custom_type9"/utf8>>,
line => 375})
end,
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
gleamgen@expression@constructor:new(Variant1),
gleamgen@expression@constructor:new(Variant2),
gleamgen@expression@constructor:new(Variant3),
gleamgen@expression@constructor:new(Variant4),
gleamgen@expression@constructor:new(Variant5),
gleamgen@expression@constructor:new(Variant6),
gleamgen@expression@constructor:new(Variant7),
gleamgen@expression@constructor:new(Variant8),
gleamgen@expression@constructor:new(Variant9)
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe = Type_,
gleamgen@types@custom:to_unchecked(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 408).
-spec with_custom_type_unchecked(
definition_details(),
gleamgen@types@custom:custom_type(LEQ, gleamgen@types:unchecked(), any()),
fun((gleamgen@types:generated_type(LEQ), list(gleamgen@expression@constructor:construtor(LEQ, gleamgen@types:unchecked()))) -> module_())
) -> module_().
with_custom_type_unchecked(Details, Type_, Handler) ->
Rest = Handler(
gleamgen@types:unchecked_ident(erlang:element(2, Details)),
begin
_pipe = erlang:element(2, Type_),
_pipe@1 = lists:reverse(_pipe),
gleam@list:map(_pipe@1, fun gleamgen@expression@constructor:new/1)
end
),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{custom_type,
begin
_pipe@2 = Type_,
gleamgen@types@custom:to_unchecked(_pipe@2)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 431).
-spec with_type_alias(
definition_details(),
gleamgen@types:generated_type(LEZ),
fun((gleamgen@types:generated_type(LEZ)) -> module_())
) -> module_().
with_type_alias(Details, Type_, Handler) ->
Rest = Handler(gleamgen@types:unchecked_ident(erlang:element(2, Details))),
erlang:setelement(
2,
Rest,
[{definition,
Details,
{type_alias,
begin
_pipe = Type_,
gleamgen_ffi:identity(_pipe)
end}} |
erlang:element(2, Rest)]
).
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 446).
-spec eof() -> module_().
eof() ->
{module, [], []}.
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 509).
-spec render_attribute(attribute()) -> glam@doc:document().
render_attribute(Attribute) ->
case Attribute of
external_erlang ->
glam@doc:from_string(<<"@external(erlang)"/utf8>>);
external_javascript ->
glam@doc:from_string(<<"@external(javascript)"/utf8>>);
{deprecated, Reason} ->
glam@doc:concat(
[glam@doc:from_string(<<"@deprecated(\""/utf8>>),
glam@doc:from_string(Reason),
glam@doc:from_string(<<"\")"/utf8>>)]
);
internal ->
glam@doc:from_string(<<"@internal"/utf8>>)
end.
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 523).
-spec render_function(
gleamgen@function:function_(gleamgen@types:unchecked(), gleamgen@types:unchecked()),
gleamgen@render:context(),
binary()
) -> gleamgen@render:rendered().
render_function(Func, Context, Name) ->
Rendered_args = begin
_pipe = erlang:element(2, Func),
_pipe@1 = gleam@list:map(
_pipe,
fun(_capture) ->
gleamgen@expression:render_attribute(_capture, Context)
end
),
gleamgen@render:pretty_list(_pipe@1)
end,
_pipe@2 = glam@doc:concat(
[glam@doc:from_string(<<"fn "/utf8>>),
glam@doc:from_string(Name),
Rendered_args,
{break, <<" "/utf8>>, <<""/utf8>>},
case gleamgen@types:render_type(erlang:element(3, Func)) of
{ok, Returned} ->
glam@doc:concat(
[glam@doc:from_string(<<"->"/utf8>>),
{break, <<" "/utf8>>, <<""/utf8>>},
erlang:element(2, Returned),
{break, <<" "/utf8>>, <<""/utf8>>}]
);
{error, _} ->
{concat, []}
end,
gleamgen@render:body(
erlang:element(
2,
gleamgen@expression:render(
erlang:element(4, Func),
erlang:setelement(3, Context, false)
)
),
true
)]
),
{render, _pipe@2}.
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 450).
-spec render(module_(), gleamgen@render:context()) -> gleamgen@render:rendered().
render(Module, Context) ->
Rendered_defs = gleam@list:map(
erlang:element(2, Module),
fun(Def) ->
_pipe = glam@doc:join(
gleam@list:map(
erlang:element(4, erlang:element(2, Def)),
fun render_attribute/1
),
{line, 1}
),
_pipe@1 = glam@doc:append(
_pipe,
case gleam@list:is_empty(
erlang:element(4, erlang:element(2, Def))
) of
true ->
{concat, []};
false ->
{line, 1}
end
),
_pipe@2 = glam@doc:append(
_pipe@1,
case erlang:element(3, erlang:element(2, Def)) of
true ->
glam@doc:concat(
[glam@doc:from_string(<<"pub"/utf8>>),
{break, <<" "/utf8>>, <<""/utf8>>}]
);
false ->
{concat, []}
end
),
glam@doc:append(_pipe@2, case erlang:element(3, Def) of
{constant, Value} ->
glam@doc:concat(
[glam@doc:from_string(<<"const "/utf8>>),
glam@doc:from_string(
erlang:element(2, erlang:element(2, Def))
),
{break, <<" "/utf8>>, <<""/utf8>>},
glam@doc:from_string(<<"="/utf8>>),
{break, <<" "/utf8>>, <<""/utf8>>},
erlang:element(
2,
gleamgen@expression:render(Value, Context)
)]
);
{custom_type, Type_} ->
glam@doc:concat(
[glam@doc:from_string(<<"type "/utf8>>),
glam@doc:from_string(
erlang:element(2, erlang:element(2, Def))
),
erlang:element(
2,
gleamgen@types@custom:render(Type_)
)]
);
{type_alias, Type_@1} ->
glam@doc:concat(
[glam@doc:from_string(<<"type "/utf8>>),
glam@doc:from_string(
erlang:element(2, erlang:element(2, Def))
),
{break, <<" "/utf8>>, <<""/utf8>>},
glam@doc:from_string(<<"="/utf8>>),
{break, <<" "/utf8>>, <<""/utf8>>},
begin
_pipe@3 = gleamgen@types:render_type(
Type_@1
),
_pipe@4 = gleam@result:map(
_pipe@3,
fun(V) -> erlang:element(2, V) end
),
gleam@result:unwrap(
_pipe@4,
glam@doc:from_string(<<"??"/utf8>>)
)
end]
);
{function, Func} ->
erlang:element(
2,
render_function(
Func,
Context,
erlang:element(2, erlang:element(2, Def))
)
)
end)
end
),
Rendered_imports = begin
_pipe@5 = erlang:element(3, Module),
_pipe@8 = gleam@list:map(_pipe@5, fun(X) -> _pipe@6 = X,
_pipe@7 = render_imported_module(_pipe@6),
gleamgen@render:to_string(_pipe@7) end),
_pipe@9 = gleam@list:sort(_pipe@8, fun gleam@string:compare/2),
_pipe@10 = gleam@list:map(_pipe@9, fun glam@doc:from_string/1),
_pipe@11 = glam@doc:join(_pipe@10, {line, 1}),
glam@doc:append(
_pipe@11,
case gleam@list:is_empty(erlang:element(3, Module)) of
true ->
{concat, []};
false ->
glam@doc:concat([{line, 1}, {line, 1}])
end
)
end,
_pipe@12 = Rendered_imports,
_pipe@13 = glam@doc:append(
_pipe@12,
glam@doc:concat_join(Rendered_defs, [{line, 1}, {line, 1}])
),
{render, _pipe@13}.
-file("/home/weasel/gleam/testing_gleamgen/gleamgen/src/gleamgen/module.gleam", 553).
-spec render_imported_module(gleamgen@import_:imported_module()) -> gleamgen@render:rendered().
render_imported_module(Module) ->
_pipe = glam@doc:concat(
[glam@doc:from_string(<<"import "/utf8>>),
glam@doc:from_string(
gleam@string:join(erlang:element(2, Module), <<"/"/utf8>>)
),
case erlang:element(3, Module) of
{some, Alias} ->
glam@doc:concat(
[{break, <<" "/utf8>>, <<""/utf8>>},
glam@doc:from_string(<<"as"/utf8>>),
{break, <<" "/utf8>>, <<""/utf8>>},
glam@doc:from_string(Alias)]
);
none ->
{concat, []}
end]
),
{render, _pipe}.