Equivalent of Elixir's inspect feature in Erlang Shell?

In Elixir I can do the following

Last login: Mon Jul 16 20:05:01 on ttys001
Nathaniels-MacBook-Pro:Documents nathanielsuchy$ iex
Erlang/OTP 21 [erts-10.0.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Interactive Elixir (1.6.6) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> x = 5
5
iex(2)> i x
Term
  5
Data type
  Integer
Reference modules
  Integer
Implemented protocols
  IEx.Info, Inspect, String.Chars, List.Chars
iex(3)> 

In Erlang the “i” alias to an inspect function does not exist. Is there a way I can get the same info about a variable in the Erlang shell as I do in Elixir’s shell?

You could load Elixir’s standard library and IEx into the Erlang shell in order to use IEx.Helpers.i/1 directly:

code:add_path("/usr/local/lib/elixir/lib/elixir/ebin/").
code:add_path("/usr/local/lib/elixir/lib/iex/ebin/").
'Elixir.IEx.Helpers':i('foo').
2 Likes

Closest thing is erlang:display(Foo) I think.

5 Likes

That just displays the content, @wmnnd’s was closest to what I needed. It’s not ideal importing much of Elixir into Erlang but for debugging purposes its fine :stuck_out_tongue: