Current section

Files

Jump to
roundabout src roundabout@common.erl
Raw

src/roundabout@common.erl

-module(roundabout@common).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/roundabout/common.gleam").
-export([string_join/0, pipe_join/0, case_arrow/0, get_function_name/2, get_type_name/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/roundabout/common.gleam", 13).
?DOC(
" Join two strings with <>\n"
" We allow breaking just before\n"
).
-spec string_join() -> glam@doc:document().
string_join() ->
_pipe = glam@doc:flex_break(<<" "/utf8>>, <<""/utf8>>),
glam@doc:append(_pipe, glam@doc:from_string(<<"<> "/utf8>>)).
-file("src/roundabout/common.gleam", 18).
-spec pipe_join() -> glam@doc:document().
pipe_join() ->
_pipe = glam@doc:flex_break(<<" "/utf8>>, <<""/utf8>>),
glam@doc:append(_pipe, glam@doc:from_string(<<"|> "/utf8>>)).
-file("src/roundabout/common.gleam", 23).
-spec case_arrow() -> glam@doc:document().
case_arrow() ->
_pipe = glam@doc:from_string(<<" ->"/utf8>>),
glam@doc:append(_pipe, glam@doc:flex_break(<<" "/utf8>>, <<""/utf8>>)).
-file("src/roundabout/common.gleam", 35).
-spec get_function_name_do(
list(binary()),
list(roundabout@node:info()),
roundabout@node:info()
) -> list(binary()).
get_function_name_do(Collected, Ancestors, Info) ->
Next = gleam@list:prepend(
Collected,
roundabout@type_name:snake(erlang:element(2, Info))
),
case Ancestors of
[Next_ancestor | Rest_ancestors] ->
get_function_name_do(Next, Rest_ancestors, Next_ancestor);
_ ->
Next
end.
-file("src/roundabout/common.gleam", 29).
?DOC(false).
-spec get_function_name(list(roundabout@node:info()), roundabout@node:info()) -> binary().
get_function_name(Ancestors, Info) ->
_pipe = get_function_name_do([], Ancestors, Info),
_pipe@1 = gleam@list:filter(_pipe, fun(Seg) -> Seg /= <<""/utf8>> end),
gleam@string:join(_pipe@1, <<"_"/utf8>>).
-file("src/roundabout/common.gleam", 56).
-spec get_type_name_do(
list(binary()),
list(roundabout@node:info()),
roundabout@node:info()
) -> list(binary()).
get_type_name_do(Collected, Ancestors, Info) ->
Next = gleam@list:prepend(
Collected,
roundabout@type_name:name(erlang:element(2, Info))
),
case Ancestors of
[Next_ancestor | Rest_ancestors] ->
get_type_name_do(Next, Rest_ancestors, Next_ancestor);
_ ->
Next
end.
-file("src/roundabout/common.gleam", 51).
?DOC(false).
-spec get_type_name(list(roundabout@node:info()), roundabout@node:info()) -> binary().
get_type_name(Ancestors, Info) ->
_pipe = get_type_name_do([], Ancestors, Info),
gleam@string:join(_pipe, <<""/utf8>>).