@@ -356,11 +356,7 @@ inspect(Data) when is_map(Data) ->
356
356
],
357
357
[" dict.from_list([" , lists :join (" , " , Fields ), " ])" ];
358
358
inspect (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 ));
364
360
inspect (Any ) when is_integer (Any ) ->
365
361
erlang :integer_to_list (Any );
366
362
inspect (Any ) when is_float (Any ) ->
@@ -386,10 +382,15 @@ inspect(Any) when is_tuple(Any) % Record constructors
386
382
andalso element (1 , Any ) =/= nil
387
383
->
388
384
[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 ;
393
394
inspect (Tuple ) when is_tuple (Tuple ) ->
394
395
Elements = lists :map (fun inspect /1 , erlang :tuple_to_list (Tuple )),
395
396
[" #(" , lists :join (" , " , Elements ), " )" ];
@@ -403,6 +404,12 @@ inspect(Any) when is_function(Any) ->
403
404
inspect (Any ) ->
404
405
[" //erl(" , io_lib :format (" ~p " , [Any ]), " )" ].
405
406
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 .
406
413
407
414
inspect_maybe_gleam_atom (<<>>, none , _ ) ->
408
415
{error , nil };
0 commit comments