-module(glance_printer). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([print/1]). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 252). -spec pretty_tuple(list(glam@doc:document())) -> glam@doc:document(). pretty_tuple(Elements) -> Comma_separated_elements = begin _pipe = Elements, glam@doc:join( _pipe, glam@doc:concat( [glam@doc:from_string(<<","/utf8>>), {break, <<" "/utf8>>, <<""/utf8>>}] ) ) end, _pipe@1 = glam@doc:concat( [glam@doc:from_string(<<"#("/utf8>>), {break, <<""/utf8>>, <<""/utf8>>}] ), _pipe@2 = glam@doc:append(_pipe@1, Comma_separated_elements), _pipe@3 = glance_printer@internal@doc_extras:nest(_pipe@2), _pipe@4 = glam@doc:append( _pipe@3, glam@doc:concat( [glance_printer@internal@doc_extras:trailing_comma(), glam@doc:from_string(<<")"/utf8>>)] ) ), glam@doc:group(_pipe@4). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 265). -spec pretty_list( list(glam@doc:document()), gleam@option:option(glam@doc:document()) ) -> glam@doc:document(). pretty_list(Elements, Tail) -> Tail@1 = begin _pipe = Tail, gleam@option:map( _pipe, fun(_capture) -> glam@doc:prepend(_capture, glam@doc:from_string(<<".."/utf8>>)) end ) end, Comma_separated_items = begin _pipe@1 = Elements, _pipe@2 = gleam@list:append(_pipe@1, gleam@option:values([Tail@1])), glam@doc:concat_join( _pipe@2, [glam@doc:from_string(<<","/utf8>>), {break, <<" "/utf8>>, <<""/utf8>>}] ) end, _pipe@3 = glam@doc:concat( [glam@doc:from_string(<<"["/utf8>>), {break, <<""/utf8>>, <<""/utf8>>}] ), _pipe@4 = glam@doc:append(_pipe@3, Comma_separated_items), _pipe@5 = glance_printer@internal@doc_extras:nest(_pipe@4), _pipe@6 = glam@doc:append_docs( _pipe@5, [{break, <<""/utf8>>, <<""/utf8>>}, glam@doc:from_string(<<"]"/utf8>>)] ), glam@doc:group(_pipe@6). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 456). -spec pretty_binary_operator(glance:binary_operator()) -> glam@doc:document(). pretty_binary_operator(Operator) -> case Operator of 'and' -> glam@doc:from_string(<<"&&"/utf8>>); 'or' -> glam@doc:from_string(<<"||"/utf8>>); eq -> glam@doc:from_string(<<"=="/utf8>>); not_eq -> glam@doc:from_string(<<"!="/utf8>>); lt_int -> glam@doc:from_string(<<"<"/utf8>>); lt_eq_int -> glam@doc:from_string(<<"<="/utf8>>); lt_float -> glam@doc:from_string(<<"<."/utf8>>); lt_eq_float -> glam@doc:from_string(<<"<=."/utf8>>); gt_eq_int -> glam@doc:from_string(<<">="/utf8>>); gt_int -> glam@doc:from_string(<<">"/utf8>>); gt_eq_float -> glam@doc:from_string(<<">=."/utf8>>); gt_float -> glam@doc:from_string(<<">."/utf8>>); pipe -> glam@doc:from_string(<<"|>"/utf8>>); add_int -> glam@doc:from_string(<<"+"/utf8>>); add_float -> glam@doc:from_string(<<"+."/utf8>>); sub_int -> glam@doc:from_string(<<"-"/utf8>>); sub_float -> glam@doc:from_string(<<"-."/utf8>>); mult_int -> glam@doc:from_string(<<"*"/utf8>>); mult_float -> glam@doc:from_string(<<"*."/utf8>>); div_int -> glam@doc:from_string(<<"/"/utf8>>); div_float -> glam@doc:from_string(<<"/."/utf8>>); remainder_int -> glam@doc:from_string(<<"%"/utf8>>); concatenate -> glam@doc:from_string(<<"<>"/utf8>>) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 510). -spec pretty_bitstring_option( glance:bit_string_segment_option(JDT), fun((JDT) -> glam@doc:document()) ) -> glam@doc:document(). pretty_bitstring_option(Bitstring_option, Fun) -> case Bitstring_option of binary_option -> glam@doc:from_string(<<"binary"/utf8>>); int_option -> glam@doc:from_string(<<"int"/utf8>>); float_option -> glam@doc:from_string(<<"float"/utf8>>); bit_string_option -> glam@doc:from_string(<<"bit_string"/utf8>>); utf8_option -> glam@doc:from_string(<<"utf8"/utf8>>); utf16_option -> glam@doc:from_string(<<"utf16"/utf8>>); utf32_option -> glam@doc:from_string(<<"utf32"/utf8>>); utf8_codepoint_option -> glam@doc:from_string(<<"utf8_codepoint"/utf8>>); utf16_codepoint_option -> glam@doc:from_string(<<"utf16_codepoint"/utf8>>); utf32_codepoint_option -> glam@doc:from_string(<<"utf32_codepoint"/utf8>>); signed_option -> glam@doc:from_string(<<"signed"/utf8>>); unsigned_option -> glam@doc:from_string(<<"unsigned"/utf8>>); big_option -> glam@doc:from_string(<<"big"/utf8>>); little_option -> glam@doc:from_string(<<"little"/utf8>>); native_option -> glam@doc:from_string(<<"native"/utf8>>); {size_value_option, N} -> _pipe = [glam@doc:from_string(<<"size("/utf8>>), Fun(N), glam@doc:from_string(<<")"/utf8>>)], glam@doc:concat(_pipe); {size_option, N@1} -> glam@doc:from_string(gleam@int:to_string(N@1)); {unit_option, N@2} -> glam@doc:from_string( <<<<"unit("/utf8, (gleam@int:to_string(N@2))/binary>>/binary, ")"/utf8>> ) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 484). -spec pretty_bitstring( list({JDP, list(glance:bit_string_segment_option(JDP))}), fun((JDP) -> glam@doc:document()) ) -> glam@doc:document(). pretty_bitstring(Segments, To_doc) -> Segments@1 = begin _pipe@3 = (gleam@list:map( Segments, fun(Segment) -> {Expr, Options} = Segment, Options@1 = begin _pipe = Options, _pipe@1 = gleam@list:map( _pipe, fun(_capture) -> pretty_bitstring_option(_capture, To_doc) end ), glam@doc:join(_pipe@1, glam@doc:from_string(<<"-"/utf8>>)) end, _pipe@2 = [To_doc(Expr), glam@doc:from_string(<<":"/utf8>>), Options@1], glam@doc:concat(_pipe@2) end )), glam@doc:concat_join( _pipe@3, [glam@doc:from_string(<<","/utf8>>), glam@doc:flex_break(<<" "/utf8>>, <<""/utf8>>)] ) end, _pipe@4 = [glam@doc:from_string(<<"<<"/utf8>>), {break, <<""/utf8>>, <<""/utf8>>}], _pipe@5 = glam@doc:concat(_pipe@4), _pipe@6 = glam@doc:append(_pipe@5, Segments@1), _pipe@7 = glance_printer@internal@doc_extras:nest(_pipe@6), _pipe@8 = glam@doc:append_docs( _pipe@7, [glance_printer@internal@doc_extras:trailing_comma(), glam@doc:from_string(<<">>"/utf8>>)] ), glam@doc:group(_pipe@8). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 698). -spec pretty_field(glance:field(JEA), fun((JEA) -> glam@doc:document())) -> glam@doc:document(). pretty_field(Field, A_to_doc) -> {field, Label, Type_} = Field, _pipe = case Label of {some, L} -> glam@doc:from_string(<>); none -> {concat, []} end, glam@doc:append(_pipe, A_to_doc(Type_)). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 759). -spec pretty_public(glance:publicity()) -> glam@doc:document(). pretty_public(Publicity) -> case Publicity of public -> glam@doc:from_string(<<"pub "/utf8>>); private -> {concat, []} end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 768). -spec pretty_assignment_name(glance:assignment_name()) -> glam@doc:document(). pretty_assignment_name(Assignment_name) -> case Assignment_name of {named, Str} -> glam@doc:from_string(Str); {discarded, Str@1} -> glam@doc:from_string(<<"_"/utf8, Str@1/binary>>) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 796). -spec pretty_as(gleam@option:option(binary())) -> glam@doc:document(). pretty_as(Name) -> case Name of {some, Str} -> glam@doc:from_string(<<" as "/utf8, Str/binary>>); none -> {concat, []} end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 160). -spec pretty_pattern(glance:pattern()) -> glam@doc:document(). pretty_pattern(Pattern) -> case Pattern of {pattern_int, Val} -> glam@doc:from_string(Val); {pattern_float, Val} -> glam@doc:from_string(Val); {pattern_variable, Val} -> glam@doc:from_string(Val); {pattern_string, Val@1} -> glam@doc:from_string( <<<<"\""/utf8, Val@1/binary>>/binary, "\""/utf8>> ); {pattern_discard, Val@2} -> glam@doc:from_string(<<"_"/utf8, Val@2/binary>>); {pattern_tuple, Elements} -> _pipe = Elements, _pipe@1 = gleam@list:map(_pipe, fun pretty_pattern/1), pretty_tuple(_pipe@1); {pattern_list, Elements@1, Tail} -> pretty_list( gleam@list:map(Elements@1, fun pretty_pattern/1), gleam@option:map(Tail, fun pretty_pattern/1) ); {pattern_assignment, Pattern@1, Name} -> _pipe@2 = [pretty_pattern(Pattern@1), pretty_as({some, Name})], glam@doc:concat(_pipe@2); {pattern_concatenate, Left, Right} -> _pipe@3 = [glam@doc:from_string( <<<<"\""/utf8, Left/binary>>/binary, "\" <> "/utf8>> ), pretty_assignment_name(Right)], glam@doc:concat(_pipe@3); {pattern_bit_string, Segments} -> pretty_bitstring(Segments, fun pretty_pattern/1); {pattern_constructor, Module, Constructor, Arguments, With_spread} -> Module@1 = begin _pipe@4 = Module, _pipe@5 = gleam@option:map(_pipe@4, fun glam@doc:from_string/1), gleam@option:unwrap(_pipe@5, {concat, []}) end, Arguments@1 = gleam@list:map( Arguments, fun(_capture) -> pretty_field(_capture, fun pretty_pattern/1) end ), Arguments@2 = begin _pipe@6 = case With_spread of true -> gleam@list:append( Arguments@1, [glam@doc:from_string(<<".."/utf8>>)] ); false -> Arguments@1 end, glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@6 ) end, _pipe@7 = [Module@1, glam@doc:from_string(Constructor), Arguments@2], glam@doc:concat(_pipe@7) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 124). -spec pretty_statement(glance:statement()) -> glam@doc:document(). pretty_statement(Statement) -> case Statement of {expression, Expression} -> pretty_expression(Expression); {assignment, Kind, Pattern, Annotation, Value} -> Let_declaration = case Kind of 'let' -> glam@doc:from_string(<<"let "/utf8>>); assert -> glam@doc:from_string(<<"let assert "/utf8>>) end, _pipe = [Let_declaration, pretty_pattern(Pattern), pretty_type_annotation(Annotation), glam@doc:from_string(<<" = "/utf8>>), pretty_expression(Value)], glam@doc:concat(_pipe); {use, Patterns, Function} -> Patterns@1 = begin _pipe@1 = Patterns, _pipe@2 = gleam@list:map(_pipe@1, fun pretty_pattern/1), glam@doc:join(_pipe@2, glam@doc:from_string(<<", "/utf8>>)) end, _pipe@3 = [glam@doc:from_string(<<"use "/utf8>>), Patterns@1, glam@doc:from_string(<<" <- "/utf8>>), pretty_expression(Function)], glam@doc:concat(_pipe@3) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 287). -spec pretty_expression(glance:expression()) -> glam@doc:document(). pretty_expression(Expression) -> case Expression of {int, Str} -> glam@doc:from_string(Str); {float, Str} -> glam@doc:from_string(Str); {variable, Str} -> glam@doc:from_string(Str); {string, Val} -> glam@doc:from_string( <<<<"\""/utf8, Val/binary>>/binary, "\""/utf8>> ); {negate_int, Expr} -> _pipe = [glam@doc:from_string(<<"-"/utf8>>), pretty_expression(Expr)], glam@doc:concat(_pipe); {negate_bool, Expr@1} -> _pipe@1 = [glam@doc:from_string(<<"!"/utf8>>), pretty_expression(Expr@1)], glam@doc:concat(_pipe@1); {block, Statements} -> pretty_block(Statements); {panic, Msg} -> case Msg of {some, Expr@2} -> glam@doc:concat( [glam@doc:from_string(<<"panic as "/utf8>>), pretty_expression(Expr@2)] ); none -> glam@doc:from_string(<<"panic"/utf8>>) end; {todo, Msg@1} -> case Msg@1 of {some, Expr@3} -> glam@doc:concat( [glam@doc:from_string(<<"todo as "/utf8>>), pretty_expression(Expr@3)] ); none -> glam@doc:from_string(<<"todo"/utf8>>) end; {tuple, Expressions} -> _pipe@2 = Expressions, _pipe@3 = gleam@list:map(_pipe@2, fun pretty_expression/1), pretty_tuple(_pipe@3); {list, Elements, Rest} -> pretty_list( gleam@list:map(Elements, fun pretty_expression/1), gleam@option:map(Rest, fun pretty_expression/1) ); {fn, Arguments, Return, Body} -> pretty_fn(Arguments, Return, Body); {record_update, Module, Constructor, Record, Fields} -> Module@1 = case Module of {some, Str@1} -> glam@doc:from_string(Str@1); none -> {concat, []} end, Record@1 = begin _pipe@4 = [glam@doc:from_string(<<".."/utf8>>), pretty_expression(Record)], glam@doc:concat(_pipe@4) end, Fields@1 = begin _pipe@6 = gleam@list:map( Fields, fun(Field) -> {Name, Expr@4} = Field, _pipe@5 = [glam@doc:from_string( <> ), pretty_expression(Expr@4)], glam@doc:concat(_pipe@5) end ), _pipe@7 = gleam@list:prepend(_pipe@6, Record@1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@7 ) end, _pipe@8 = [Module@1, glam@doc:from_string(Constructor), Fields@1], glam@doc:concat(_pipe@8); {field_access, Container, Label} -> _pipe@9 = [pretty_expression(Container), glam@doc:from_string(<<"."/utf8, Label/binary>>)], glam@doc:concat(_pipe@9); {call, Function, Arguments@1} -> Arguments@2 = begin _pipe@10 = Arguments@1, _pipe@11 = gleam@list:map( _pipe@10, fun(_capture) -> pretty_field(_capture, fun pretty_expression/1) end ), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@11 ) end, _pipe@12 = [pretty_expression(Function), Arguments@2], glam@doc:concat(_pipe@12); {tuple_index, Tuple, Index} -> _pipe@13 = [pretty_expression(Tuple), glam@doc:from_string( <<"."/utf8, (gleam@int:to_string(Index))/binary>> )], glam@doc:concat(_pipe@13); {fn_capture, Label@1, Function@1, Arguments_before, Arguments_after} -> Arguments_before@1 = gleam@list:map( Arguments_before, fun(_capture@1) -> pretty_field(_capture@1, fun pretty_expression/1) end ), Arguments_after@1 = gleam@list:map( Arguments_after, fun(_capture@2) -> pretty_field(_capture@2, fun pretty_expression/1) end ), Placeholder = case Label@1 of {some, Str@2} -> glam@doc:from_string(<>); none -> glam@doc:from_string(<<"_"/utf8>>) end, In_parens = begin _pipe@14 = Arguments_before@1, _pipe@15 = gleam@list:append(_pipe@14, [Placeholder]), _pipe@16 = gleam@list:append(_pipe@15, Arguments_after@1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@16 ) end, _pipe@17 = [pretty_expression(Function@1), In_parens], glam@doc:concat(_pipe@17); {bit_string, Segments} -> pretty_bitstring(Segments, fun pretty_expression/1); {'case', Subjects, Clauses} -> Subjects@1 = begin _pipe@18 = Subjects, _pipe@19 = gleam@list:map(_pipe@18, fun pretty_expression/1), glam@doc:join(_pipe@19, glam@doc:from_string(<<", "/utf8>>)) end, Clauses@1 = begin _pipe@24 = (gleam@list:map( Clauses, fun(_use0) -> {clause, Lolo_patterns, Guard, Body@1} = _use0, Lolo_patterns@1 = gleam@list:map( Lolo_patterns, fun(_capture@3) -> gleam@list:map(_capture@3, fun pretty_pattern/1) end ), Lolo_patterns@2 = begin _pipe@20 = gleam@list:map( Lolo_patterns@1, fun(_capture@4) -> glam@doc:join( _capture@4, glam@doc:from_string(<<", "/utf8>>) ) end ), glam@doc:join( _pipe@20, glam@doc:from_string(<<" | "/utf8>>) ) end, Guard@1 = begin _pipe@21 = gleam@option:map( Guard, fun pretty_expression/1 ), _pipe@22 = gleam@option:map( _pipe@21, fun(_capture@5) -> glam@doc:prepend( _capture@5, glam@doc:from_string(<<" if "/utf8>>) ) end ), gleam@option:unwrap(_pipe@22, {concat, []}) end, _pipe@23 = [Lolo_patterns@2, Guard@1, glam@doc:from_string(<<" -> "/utf8>>), pretty_expression(Body@1)], glam@doc:concat(_pipe@23) end )), glam@doc:join(_pipe@24, {line, 1}) end, _pipe@25 = glam@doc:from_string(<<"case "/utf8>>), _pipe@26 = glam@doc:append(_pipe@25, Subjects@1), _pipe@27 = glam@doc:append_docs( _pipe@26, [glam@doc:from_string(<<" {"/utf8>>), {line, 1}] ), _pipe@28 = glam@doc:append(_pipe@27, Clauses@1), _pipe@29 = glance_printer@internal@doc_extras:nest(_pipe@28), glam@doc:append_docs( _pipe@29, [{line, 1}, glam@doc:from_string(<<"}"/utf8>>)] ); {binary_operator, Name@1, Left, Right} -> _pipe@30 = [pretty_expression(Left), glance_printer@internal@doc_extras:nbsp(), pretty_binary_operator(Name@1), glance_printer@internal@doc_extras:nbsp(), pretty_expression(Right)], glam@doc:concat(_pipe@30) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 237). -spec pretty_block(list(glance:statement())) -> glam@doc:document(). pretty_block(Statements) -> Statements@1 = begin _pipe = Statements, _pipe@1 = gleam@list:map(_pipe, fun pretty_statement/1), glam@doc:join(_pipe@1, {line, 1}) end, _pipe@2 = glam@doc:concat([glam@doc:from_string(<<"{"/utf8>>), {line, 1}]), _pipe@3 = glam@doc:append(_pipe@2, Statements@1), _pipe@4 = glance_printer@internal@doc_extras:nest(_pipe@3), glam@doc:append_docs( _pipe@4, [{line, 1}, glam@doc:from_string(<<"}"/utf8>>)] ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 72). -spec pretty_attribute(glance:attribute()) -> glam@doc:document(). pretty_attribute(Attribute) -> {attribute, Name, Arguments} = Attribute, Arguments@1 = begin _pipe = Arguments, _pipe@1 = gleam@list:map(_pipe, fun pretty_expression/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, _pipe@2 = [glam@doc:from_string(<<"@"/utf8, Name/binary>>), Arguments@1], glam@doc:concat(_pipe@2). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 61). -spec pretty_definition( glance:definition(JDH), fun((JDH) -> glam@doc:document()) ) -> glam@doc:document(). pretty_definition(Definition, Inner_to_doc) -> {definition, Attributes, Definition@1} = Definition, _pipe = Attributes, _pipe@1 = gleam@list:map(_pipe, fun pretty_attribute/1), _pipe@2 = gleam@list:append(_pipe@1, [Inner_to_doc(Definition@1)]), glam@doc:join(_pipe@2, {line, 1}). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 710). -spec pretty_import(glance:definition(glance:import())) -> glam@doc:document(). pretty_import(Import_) -> pretty_definition( Import_, fun(_use0) -> {import, Module, Alias, Unqualified_types, Unqualified_values} = _use0, Unqualified_values@1 = begin _pipe = Unqualified_values, gleam@list:map( _pipe, fun(Uq) -> glam@doc:concat( [glam@doc:from_string(erlang:element(2, Uq)), pretty_as(erlang:element(3, Uq))] ) end ) end, Unqualified_types@1 = begin _pipe@1 = Unqualified_types, gleam@list:map( _pipe@1, fun(Uq@1) -> glam@doc:concat( [glam@doc:from_string(<<"type "/utf8>>), glam@doc:from_string(erlang:element(2, Uq@1)), pretty_as(erlang:element(3, Uq@1))] ) end ) end, Unqualifieds = case gleam@list:append( Unqualified_types@1, Unqualified_values@1 ) of [] -> {concat, []}; Lst -> _pipe@2 = Lst, _pipe@3 = glam@doc:concat_join( _pipe@2, [glam@doc:from_string(<<","/utf8>>), glam@doc:flex_break(<<" "/utf8>>, <<""/utf8>>)] ), _pipe@4 = glam@doc:group(_pipe@3), _pipe@5 = glam@doc:prepend( _pipe@4, glam@doc:concat( [glam@doc:from_string(<<".{"/utf8>>), {break, <<""/utf8>>, <<""/utf8>>}] ) ), _pipe@6 = glance_printer@internal@doc_extras:nest(_pipe@5), _pipe@7 = glam@doc:append( _pipe@6, glam@doc:concat( [glance_printer@internal@doc_extras:trailing_comma(), glam@doc:from_string(<<"}"/utf8>>)] ) ), glam@doc:group(_pipe@7) end, Import_stmt = begin _pipe@8 = glam@doc:from_string( <<"import "/utf8, Module/binary>> ), glam@doc:append(_pipe@8, Unqualifieds) end, case Alias of {some, Alias@1} -> _pipe@9 = Import_stmt, _pipe@10 = glam@doc:append( _pipe@9, glam@doc:from_string(<<" as "/utf8>>) ), glam@doc:append(_pipe@10, pretty_assignment_name(Alias@1)); none -> Import_stmt end end ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 786). -spec pretty_return_signature(gleam@option:option(glance:type())) -> glam@doc:document(). pretty_return_signature(Type_) -> case Type_ of {some, T} -> _pipe = [glam@doc:from_string(<<" -> "/utf8>>), pretty_type(T)], glam@doc:concat(_pipe); none -> {concat, []} end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 611). -spec pretty_type(glance:type()) -> glam@doc:document(). pretty_type(Type_) -> case Type_ of {named_type, Name, Module, Parameters} -> Parameters@1 = case Parameters of [] -> {concat, []}; _ -> _pipe = Parameters, _pipe@1 = gleam@list:map(_pipe, fun pretty_type/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, _pipe@2 = Module, _pipe@3 = gleam@option:map( _pipe@2, fun(Mod) -> <> end ), _pipe@4 = gleam@option:map(_pipe@3, fun glam@doc:from_string/1), _pipe@5 = gleam@option:unwrap(_pipe@4, {concat, []}), _pipe@6 = glam@doc:append(_pipe@5, glam@doc:from_string(Name)), glam@doc:append(_pipe@6, Parameters@1); {tuple_type, Elements} -> _pipe@7 = Elements, _pipe@8 = gleam@list:map(_pipe@7, fun pretty_type/1), pretty_tuple(_pipe@8); {function_type, Parameters@2, Return} -> _pipe@9 = glam@doc:from_string(<<"fn"/utf8>>), _pipe@12 = glam@doc:append( _pipe@9, begin _pipe@10 = Parameters@2, _pipe@11 = gleam@list:map(_pipe@10, fun pretty_type/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@11 ) end ), glam@doc:append(_pipe@12, pretty_return_signature({some, Return})); {variable_type, Name@1} -> glam@doc:from_string(Name@1); {hole_type, Name@2} -> glam@doc:from_string(Name@2) end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 586). -spec pretty_type_alias(glance:definition(glance:type_alias())) -> glam@doc:document(). pretty_type_alias(Type_alias) -> pretty_definition( Type_alias, fun(_use0) -> {type_alias, Name, Publicity, Parameters, Aliased} = _use0, Parameters@1 = case Parameters of [] -> {concat, []}; _ -> _pipe = Parameters, _pipe@1 = gleam@list:map(_pipe, fun glam@doc:from_string/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, _pipe@2 = pretty_public(Publicity), _pipe@3 = glam@doc:append( _pipe@2, glam@doc:from_string(<<"type "/utf8, Name/binary>>) ), _pipe@4 = glam@doc:append(_pipe@3, Parameters@1), _pipe@5 = glam@doc:append( _pipe@4, glam@doc:from_string(<<" ="/utf8>>) ), _pipe@6 = glam@doc:append(_pipe@5, {line, 1}), _pipe@7 = glance_printer@internal@doc_extras:nest(_pipe@6), glam@doc:append(_pipe@7, pretty_type(Aliased)) end ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 690). -spec pretty_variant(glance:variant()) -> glam@doc:document(). pretty_variant(Variant) -> {variant, Name, Fields} = Variant, _pipe = Fields, _pipe@1 = gleam@list:map( _pipe, fun(_capture) -> pretty_field(_capture, fun pretty_type/1) end ), _pipe@2 = glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ), glam@doc:prepend(_pipe@2, glam@doc:from_string(Name)). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 647). -spec pretty_custom_type(glance:definition(glance:custom_type())) -> glam@doc:document(). pretty_custom_type(Type_) -> pretty_definition( Type_, fun(_use0) -> {custom_type, Name, Publicity, Opaque_, Parameters, Variants} = _use0, Opaque_@1 = case Opaque_ of true -> <<"opaque "/utf8>>; false -> <<""/utf8>> end, Parameters@1 = case Parameters of [] -> {concat, []}; _ -> _pipe = Parameters, _pipe@1 = gleam@list:map(_pipe, fun glam@doc:from_string/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, Variants@1 = begin _pipe@2 = Variants, _pipe@3 = gleam@list:map(_pipe@2, fun pretty_variant/1), glam@doc:join(_pipe@3, {line, 1}) end, Type_body = begin _pipe@4 = glam@doc:concat( [glam@doc:from_string(<<"{"/utf8>>), {line, 1}] ), _pipe@5 = glam@doc:append(_pipe@4, Variants@1), _pipe@6 = glance_printer@internal@doc_extras:nest(_pipe@5), _pipe@7 = glam@doc:append_docs( _pipe@6, [{line, 1}, glam@doc:from_string(<<"}"/utf8>>)] ), glam@doc:group(_pipe@7) end, _pipe@8 = [pretty_public(Publicity), glam@doc:from_string( <<<>/binary, Name/binary>> ), Parameters@1, glance_printer@internal@doc_extras:nbsp(), Type_body], glam@doc:concat(_pipe@8) end ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 776). -spec pretty_type_annotation(gleam@option:option(glance:type())) -> glam@doc:document(). pretty_type_annotation(Type_) -> case Type_ of {some, T} -> _pipe = [glam@doc:from_string(<<": "/utf8>>), pretty_type(T)], glam@doc:concat(_pipe); none -> {concat, []} end. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 112). -spec pretty_function_parameter(glance:function_parameter()) -> glam@doc:document(). pretty_function_parameter(Parameter) -> {function_parameter, Label, Name, Type_} = Parameter, Label@1 = case Label of {some, L} -> glam@doc:from_string(<>); none -> {concat, []} end, _pipe = [Label@1, pretty_assignment_name(Name), pretty_type_annotation(Type_)], glam@doc:concat(_pipe). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 83). -spec pretty_function(glance:definition(glance:function_())) -> glam@doc:document(). pretty_function(Function) -> pretty_definition( Function, fun(_use0) -> {function, Name, Publicity, Parameters, Return, Statements, _} = _use0, Parameters@1 = begin _pipe = Parameters, _pipe@1 = gleam@list:map(_pipe, fun pretty_function_parameter/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, Statements@1 = case Statements of [] -> {concat, []}; _ -> _pipe@2 = [glance_printer@internal@doc_extras:nbsp(), pretty_block(Statements)], glam@doc:concat(_pipe@2) end, _pipe@3 = [pretty_public(Publicity), glam@doc:from_string(<<"fn "/utf8, Name/binary>>), Parameters@1, pretty_return_signature(Return), Statements@1], glam@doc:concat(_pipe@3) end ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 220). -spec pretty_constant(glance:definition(glance:constant())) -> glam@doc:document(). pretty_constant(Constant) -> pretty_definition( Constant, fun(_use0) -> {constant, Name, Publicity, Annotation, Value} = _use0, _pipe = [pretty_public(Publicity), glam@doc:from_string(<<"const "/utf8, Name/binary>>), pretty_type_annotation(Annotation), glam@doc:from_string(<<" ="/utf8>>), {break, <<" "/utf8>>, <<""/utf8>>}, pretty_expression(Value)], glam@doc:concat(_pipe) end ). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 32). -spec print(glance:module_()) -> binary(). print(Module) -> {module, Imports, Custom_types, Type_aliases, Constants, Functions} = Module, Imports@1 = begin _pipe = Imports, _pipe@1 = gleam@list:reverse(_pipe), _pipe@2 = gleam@list:map(_pipe@1, fun pretty_import/1), glam@doc:join(_pipe@2, {line, 1}) end, The_rest = begin _pipe@3 = [gleam@list:map(Custom_types, fun pretty_custom_type/1), gleam@list:map(Type_aliases, fun pretty_type_alias/1), gleam@list:map(Constants, fun pretty_constant/1), gleam@list:map(Functions, fun pretty_function/1)], _pipe@4 = gleam@list:filter( _pipe@3, fun(Lst) -> not gleam@list:is_empty(Lst) end ), _pipe@5 = gleam@list:map(_pipe@4, fun gleam@list:reverse/1), gleam@list:map( _pipe@5, fun(_capture) -> glam@doc:join(_capture, glam@doc:lines(2)) end ) end, <<(begin _pipe@6 = [Imports@1 | The_rest], _pipe@7 = glam@doc:join(_pipe@6, glam@doc:lines(2)), _pipe@8 = glam@doc:to_string(_pipe@7, 81), gleam@string:trim(_pipe@8) end)/binary, "\n"/utf8>>. -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 578). -spec pretty_fn_parameter(glance:fn_parameter()) -> glam@doc:document(). pretty_fn_parameter(Fn_parameter) -> {fn_parameter, Name, Type_} = Fn_parameter, _pipe = [pretty_assignment_name(Name), pretty_type_annotation(Type_)], glam@doc:concat(_pipe). -file("/Users/benjamin/Personal/glance_printer/src/glance_printer.gleam", 540). -spec pretty_fn( list(glance:fn_parameter()), gleam@option:option(glance:type()), list(glance:statement()) ) -> glam@doc:document(). pretty_fn(Arguments, Return, Body) -> Arguments@1 = begin _pipe = Arguments, _pipe@1 = gleam@list:map(_pipe, fun pretty_fn_parameter/1), glance_printer@internal@doc_extras:comma_separated_in_parentheses( _pipe@1 ) end, Body@1 = case Body of [] -> glam@doc:from_string(<<"{}"/utf8>>); [Statement] -> _pipe@2 = glam@doc:concat( [glam@doc:from_string(<<"{"/utf8>>), {break, <<" "/utf8>>, <<""/utf8>>}] ), _pipe@3 = glam@doc:append(_pipe@2, pretty_statement(Statement)), _pipe@4 = glance_printer@internal@doc_extras:nest(_pipe@3), _pipe@5 = glam@doc:append_docs( _pipe@4, [{break, <<" "/utf8>>, <<""/utf8>>}, glam@doc:from_string(<<"}"/utf8>>)] ), glam@doc:group(_pipe@5); Multiple_statements -> pretty_block(Multiple_statements) end, _pipe@6 = [glam@doc:from_string(<<"fn"/utf8>>), Arguments@1, pretty_return_signature(Return), glance_printer@internal@doc_extras:nbsp(), Body@1], glam@doc:concat(_pipe@6).