Thank you all I am very satisfied with this until further problems come up.
in .iex.exs
add
#Inspect overrides
import Kernel, except: [inspect: 1]
import Inspect.Algebra
alias Code.Identifier
#This makes [48, 49] print as [48, 49]
#IEx.configure(inspect: [charlists: :as_lists])
defimpl Inspect, for: List do
def inspect([], opts) do
color("[]", :list, opts)
end
def inspect(term, opts) do
%Inspect.Opts{
charlists: lists,
printable_limit: printable_limit
} = opts
open = color("[", :list, opts)
sep = color(",", :list, opts)
close = color("]", :list, opts)
cond do
lists == :as_charlists ->
inspected =
case Identifier.escape(IO.chardata_to_string(term), ?', printable_limit) do
{escaped, ""} -> [?', escaped, ?']
{escaped, _} -> [?', escaped, ?', " ++ ..."]
end
IO.iodata_to_binary(inspected)
keyword?(term) ->
container_doc(open, term, close, opts, &keyword/2, separator: sep, break: :strict)
true ->
container_doc(open, term, close, opts, &to_doc/2, separator: sep)
end
end
@doc false
def keyword({key, value}, opts) do
key = color(Identifier.inspect_as_key(key), :atom, opts)
concat(key, concat(" ", to_doc(value, opts)))
end
@doc false
def keyword?([{key, _value} | rest]) when is_atom(key) do
case Atom.to_charlist(key) do
'Elixir.' ++ _ -> false
_ -> keyword?(rest)
end
end
def keyword?([]), do: true
def keyword?(_other), do: false
end
#This makes 0.000412 print as 0.000412
defimpl Inspect, for: Float do
def inspect(term, opts) do
inspected = :erlang.float_to_binary(term, [:compact, { :decimals, 7 }])
color(inspected, :number, opts)
end
end
This doesnt break dialyzer upon compile unlike when I added this as a module to the project. This probably will need some work (maybe using Consolidation under Protocols) to work with releases or test environment. But works well for my analysis use case.