-module(roundabout@type_name). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/roundabout/type_name.gleam"). -export([new/1, unsafe/1, name/1, snake/1]). -export_type([type_name/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -opaque type_name() :: {type_name, binary()}. -file("src/roundabout/type_name.gleam", 10). ?DOC(false). -spec new(binary()) -> {ok, type_name()} | {error, binary()}. new(Name) -> Re@1 = case gleam@regexp:from_string(<<"^[A-Z][a-zA-Z0-9]*$"/utf8>>) of {ok, Re} -> Re; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"roundabout/type_name"/utf8>>, function => <<"new"/utf8>>, line => 11, value => _assert_fail, start => 167, 'end' => 228, pattern_start => 178, pattern_end => 184}) end, Candidate = justin:pascal_case(Name), case gleam@regexp:check(Re@1, Candidate) of true -> {ok, {type_name, Candidate}}; false -> {error, <<"Invalid type name "/utf8, Name/binary>>} end. -file("src/roundabout/type_name.gleam", 22). ?DOC(false). -spec unsafe(binary()) -> type_name(). unsafe(Value) -> {type_name, Value}. -file("src/roundabout/type_name.gleam", 27). ?DOC(false). -spec name(type_name()) -> binary(). name(Input) -> erlang:element(2, Input). -file("src/roundabout/type_name.gleam", 32). ?DOC(false). -spec snake(type_name()) -> binary(). snake(Input) -> _pipe = erlang:element(2, Input), justin:snake_case(_pipe).