-module(argamak@format). -compile(no_auto_import). -export([float32/0, int32/0, float64/0, int64/0, uint64/0, uint32/0, bfloat16/0, float16/0, int16/0, uint16/0, int8/0, uint8/0, to_native/1, to_string/1]). -export_type([format/1, native/0]). -opaque format(JJW) :: bfloat16 | float16 | float32 | float64 | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | {gleam_phantom, JJW}. -opaque native() :: {bf, integer()} | {f, integer()} | {s, integer()} | {u, integer()}. -spec float32() -> format(float()). float32() -> float32. -spec int32() -> format(integer()). int32() -> int32. -spec float64() -> format(float()). float64() -> float64. -spec int64() -> format(integer()). int64() -> int64. -spec uint64() -> format(integer()). uint64() -> uint64. -spec uint32() -> format(integer()). uint32() -> uint32. -spec bfloat16() -> format(float()). bfloat16() -> bfloat16. -spec float16() -> format(float()). float16() -> float16. -spec int16() -> format(integer()). int16() -> int16. -spec uint16() -> format(integer()). uint16() -> uint16. -spec int8() -> format(integer()). int8() -> int8. -spec uint8() -> format(integer()). uint8() -> uint8. -spec to_native(format(any())) -> native(). to_native(Format) -> do_to_native(Format). -spec do_to_native(format(any())) -> native(). do_to_native(Format) -> case Format of float64 -> {f, 64}; int64 -> {s, 64}; uint64 -> {u, 64}; float32 -> {f, 32}; int32 -> {s, 32}; uint32 -> {u, 32}; bfloat16 -> {bf, 16}; float16 -> {f, 16}; int16 -> {s, 16}; uint16 -> {u, 16}; int8 -> {s, 8}; uint8 -> {u, 8} end. -spec to_string(format(any())) -> binary(). to_string(Format) -> {ok, String@1} = case argamak@util:record_to_string(Format) of {ok, String} -> {ok, String}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"argamak/format"/utf8>>, function => <<"to_string"/utf8>>, line => 146}) end, String@1.