@@ -356,11 +356,7 @@ inspect(Data) when is_map(Data) ->
356356 ],
357357 [" dict.from_list([" , lists :join (" , " , Fields ), " ])" ];
358358inspect (Atom ) when is_atom (Atom ) ->
359- Binary = erlang :atom_to_binary (Atom ),
360- case inspect_maybe_gleam_atom (Binary , none , <<>>) of
361- {ok , Inspected } -> Inspected ;
362- {error , _ } -> [" atom.create_from_string(\" " , Binary , " \" )" ]
363- end ;
359+ erlang :element (2 , inspect_atom (Atom ));
364360inspect (Any ) when is_integer (Any ) ->
365361 erlang :integer_to_list (Any );
366362inspect (Any ) when is_float (Any ) ->
@@ -386,10 +382,15 @@ inspect(Any) when is_tuple(Any) % Record constructors
386382 andalso element (1 , Any ) =/= nil
387383->
388384 [Atom | ArgsList ] = erlang :tuple_to_list (Any ),
389- Args = lists :join (<<" , " >>,
390- lists :map (fun inspect /1 , ArgsList )
391- ),
392- [inspect (Atom ), " (" , Args , " )" ];
385+ InspectedArgs = lists :map (fun inspect /1 , ArgsList ),
386+ case inspect_atom (Atom ) of
387+ {gleam_atom , GleamAtom } ->
388+ Args = lists :join (<<" , " >>, InspectedArgs ),
389+ [GleamAtom , " (" , Args , " )" ];
390+ {erlang_atom , ErlangAtom } ->
391+ Args = lists :join (<<" , " >>, [ErlangAtom | InspectedArgs ]),
392+ [" #(" , Args , " )" ]
393+ end ;
393394inspect (Tuple ) when is_tuple (Tuple ) ->
394395 Elements = lists :map (fun inspect /1 , erlang :tuple_to_list (Tuple )),
395396 [" #(" , lists :join (" , " , Elements ), " )" ];
@@ -403,6 +404,12 @@ inspect(Any) when is_function(Any) ->
403404inspect (Any ) ->
404405 [" //erl(" , io_lib :format (" ~p " , [Any ]), " )" ].
405406
407+ inspect_atom (Atom ) ->
408+ Binary = erlang :atom_to_binary (Atom ),
409+ case inspect_maybe_gleam_atom (Binary , none , <<>>) of
410+ {ok , Inspected } -> {gleam_atom , Inspected };
411+ {error , _ } -> {erlang_atom , [" atom.create_from_string(\" " , Binary , " \" )" ]}
412+ end .
406413
407414inspect_maybe_gleam_atom (<<>>, none , _ ) ->
408415 {error , nil };
0 commit comments