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(KYP),
fun((gleamgen@expression:expression(KYP)) -> 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_(KYU, any()),
fun((gleamgen@expression:expression(KYU)) -> 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(KYZ, {{}, KZA}, any()),
fun((gleamgen@types:generated_type(KYZ), gleamgen@expression@constructor:construtor(KYZ, KZA)) -> 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(KZI, {{{}, KZJ}, KZK}, any()),
fun((gleamgen@types:generated_type(KZI), gleamgen@expression@constructor:construtor(KZI, KZJ), gleamgen@expression@constructor:construtor(KZI, KZK)) -> 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(KZU, {{{}, KZV}, KZW, KZX}, any()),
fun((gleamgen@types:generated_type(KZU), gleamgen@expression@constructor:construtor(KZU, KZV), gleamgen@expression@constructor:construtor(KZU, KZW), gleamgen@expression@constructor:construtor(KZU, KZX)) -> 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(LAJ, {{{{}, LAK}, LAL}, LAM, LAN}, any()),
fun((gleamgen@types:generated_type(LAJ), gleamgen@expression@constructor:construtor(LAJ, LAK), gleamgen@expression@constructor:construtor(LAJ, LAL), gleamgen@expression@constructor:construtor(LAJ, LAM), gleamgen@expression@constructor:construtor(LAJ, LAN)) -> 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(LBB, {{{{{}, LBC}, LBD}, LBE}, LBF, LBG}, any()),
fun((gleamgen@types:generated_type(LBB), gleamgen@expression@constructor:construtor(LBB, LBC), gleamgen@expression@constructor:construtor(LBB, LBD), gleamgen@expression@constructor:construtor(LBB, LBE), gleamgen@expression@constructor:construtor(LBB, LBF), gleamgen@expression@constructor:construtor(LBB, LBG)) -> 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(LBW, {{{{{{}, LBX}, LBY}, LBZ}, LCA},
LCB,
LCC}, any()),
fun((gleamgen@types:generated_type(LBW), gleamgen@expression@constructor:construtor(LBW, LBX), gleamgen@expression@constructor:construtor(LBW, LBY), gleamgen@expression@constructor:construtor(LBW, LBZ), gleamgen@expression@constructor:construtor(LBW, LCA), gleamgen@expression@constructor:construtor(LBW, LCB), gleamgen@expression@constructor:construtor(LBW, LCC)) -> 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(LCU, {{{{{{{}, LCV}, LCW}, LCX}, LCY},
LCZ},
LDA,
LDB}, any()),
fun((gleamgen@types:generated_type(LCU), gleamgen@expression@constructor:construtor(LCU, LCV), gleamgen@expression@constructor:construtor(LCU, LCW), gleamgen@expression@constructor:construtor(LCU, LCX), gleamgen@expression@constructor:construtor(LCU, LCY), gleamgen@expression@constructor:construtor(LCU, LCZ), gleamgen@expression@constructor:construtor(LCU, LDA), gleamgen@expression@constructor:construtor(LCU, LDB)) -> 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(LDV, {{{{{{{{}, LDW}, LDX}, LDY}, LDZ},
LEA},
LEB},
LEC,
LED}, any()),
fun((gleamgen@types:generated_type(LDV), gleamgen@expression@constructor:construtor(LDV, LDW), gleamgen@expression@constructor:construtor(LDV, LDX), gleamgen@expression@constructor:construtor(LDV, LDY), gleamgen@expression@constructor:construtor(LDV, LDZ), gleamgen@expression@constructor:construtor(LDV, LEA), gleamgen@expression@constructor:construtor(LDV, LEB), gleamgen@expression@constructor:construtor(LDV, LEC), gleamgen@expression@constructor:construtor(LDV, LED)) -> 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(LEZ, {{{{{{{{{}, LFA}, LFB}, LFC}, LFD},
LFE},
LFF},
LFG},
LFH,
LFI}, any()),
fun((gleamgen@types:generated_type(LEZ), gleamgen@expression@constructor:construtor(LEZ, LFA), gleamgen@expression@constructor:construtor(LEZ, LFB), gleamgen@expression@constructor:construtor(LEZ, LFC), gleamgen@expression@constructor:construtor(LEZ, LFD), gleamgen@expression@constructor:construtor(LEZ, LFE), gleamgen@expression@constructor:construtor(LEZ, LFF), gleamgen@expression@constructor:construtor(LEZ, LFG), gleamgen@expression@constructor:construtor(LEZ, LFH), gleamgen@expression@constructor:construtor(LEZ, LFI)) -> 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(LGG, gleamgen@types:unchecked(), any()),
fun((gleamgen@types:generated_type(LGG), list(gleamgen@expression@constructor:construtor(LGG, 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(LGP),
fun((gleamgen@types:generated_type(LGP)) -> 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}.