From 0bcd8c145988e7a5baf8983262e7d17b24159944 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sat, 11 Nov 2023 23:13:01 +0000 Subject: Improve string inspect map formatting --- src/gleam_stdlib.erl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index c6b5130..7414439 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -373,6 +373,12 @@ inspect(false) -> "False"; inspect(nil) -> "Nil"; +inspect(Data) when is_map(Data) -> + Fields = [ + [<<"#(">>, inspect(Key), <<", ">>, inspect(Value), <<")">>] + || {Key, Value} <- maps:to_list(Data) + ], + ["map.from_list([", lists:join(", ", Fields), "])"]; inspect(Atom) when is_atom(Atom) -> Binary = erlang:atom_to_binary(Atom), case inspect_maybe_gleam_atom(Binary, none, <<>>) of -- cgit v1.2.3