Get a list of all elixir modules in IEx
Asked Answered
S

2

5

To get a list of all functions on a module in IEx I can run:


Map.__info__(:functions)
# or
Enum.__info__(:functions)


Using the {Module}.__info__(:functions) format.

How can I get a list of all the standard lib modules?

Shaughn answered 19/10, 2019 at 7:44 Comment(0)
U
4

From IEx you can type : + Tab to get a list of all available modules.

Umeko answered 19/10, 2019 at 17:10 Comment(0)
P
6

If you want to get all loaded Elixir modules, without erlang modules, run the following in a clean IEx shell:

:code.all_loaded() 
|> Enum.filter(fn {mod, _} -> "#{mod}" =~ ~r{^[A-Z]} end)
|> Enum.map(fn {mod, _} -> mod end)

# [Exception, Application, Inspect.Atom, IEx.Pry, Logger.Config, Module, Keyword, ... ]

This will also include sub modules like IEx.Config, but you can filter them with some additional mapping:

:code.all_loaded() 
|> Enum.filter(fn {mod, _} -> "#{mod}" =~ ~r{^[A-Z]} end)
|> Enum.map(fn {mod, _} -> mod end)
|> Enum.map(fn mod -> hd(Module.split(mod)) end)
|> Enum.uniq

# ["Exception", "Application", "Inspect", "IEx", "Logger", "Module", "Keyword", ... ]
Phidias answered 19/10, 2019 at 10:21 Comment(5)
this seems to be what i'm looking for, however there are three dots on the ends that imply there's more to the list. how do i get the whole list?Shaughn
Output it with IO.inspect or IO.putsPhidias
:erlang.loaded() |> Enum.sort() |> inspect(limit: :infinity) |> IO.putsUmeko
There is no notion of “submodules” in Elixir. Actually, IEx.Pry and IEx are two absolutely different modules, knowing nothing about each other.Justification
after studying the iex source code I came up with this, that gives me more modules (MapSet for instance): :application.get_key(:elixir, :modules) |> inspect(limit: :infinity) |> IO.puts . I looked at github.com/elixir-lang/elixir/blob/…Blenheim
U
4

From IEx you can type : + Tab to get a list of all available modules.

Umeko answered 19/10, 2019 at 17:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.