How is `to_doc/2` imported into `Inspect.Map`?

If you paste the whole code from

defimpl Inspect, for: Map do
# ...
end

into an Elixir shell, you will get “undefined function color/3” and a bunch or errors for other undefined functions.

I wonder how that code has access to color/3, concat/2, container_doc/6 and to_doc/2.

I’ll ping @josevalim , hope you don’t mind <3 !

1 Like

lib/elixir/lib/inspect.ex imports the Inspect.Algebra module at the top of the file:

3 Likes

l knew you could alias outside of a module, but import no …

Thank you :slight_smile: