IEx.Helpers

Welcome to Interactive Elixir. You are currently seeing the documentation for the module IEx.Helpers which provides many helpers to make Elixir's shell more joyful to work with.

This message was triggered by invoking the helper h(), usually referred to as h/0 (since it expects 0 arguments).

There are many other helpers available:

Help for functions in this module can be consulted directly from the command line, as an example, try:

h(c/2)

You can also retrieve the documentation for any module or function. Try these:

h(Enum)
h(Enum.reverse/1)

To learn more about IEx as a whole, just type h(IEx).

Source

Summary

c(files, path \\ ".")

Expects a list of files to compile and a path to write their object code to. It returns the name of the compiled modules

cd(directory)

Changes the current working directory to the given path

clear()

Clear the console screen

flush()

Flushes all messages sent to the shell and prints them out

h()

Prints the documentation for IEx.Helpers

h(string)

Prints the documentation for the given module or for the given function/arity pair

import_file(path)

Evaluates the contents of the file at path as if it were directly typed into the shell. path has to be a literal binary

l(module)

Load the given module's beam code (and ensures any previous old version was properly purged before)

ls(path \\ ".")

Produces a simple list of a directory's contents. If path points to a file, prints its full path

pwd()

Prints the current working directory

r(module)

Recompiles and reloads the specified module's source file

respawn()

Respawns the current shell by starting a new process and a new scope. Returns true if it worked

s(module)

Similar to t/1, only for specs

t(module)

When given a module, prints specifications (or simply specs) for all the types defined in it

v()

Prints the history of expressions evaluated during the session along with their results

v(n)

Retrieves the nth expression's value from the history

Functions

c(files, path \\ ".")

Expects a list of files to compile and a path to write their object code to. It returns the name of the compiled modules.

When compiling one file, there is no need to wrap it in a list.

Examples

c ["foo.ex", "bar.ex"], "ebin"
#=> [Foo,Bar]

c "baz.ex"
#=> [Baz]
Source
cd(directory)

Changes the current working directory to the given path.

Source
clear()

Clear the console screen.

Source
flush()

Flushes all messages sent to the shell and prints them out.

Source
h()

Prints the documentation for IEx.Helpers.

Source
l(module)

Load the given module's beam code (and ensures any previous old version was properly purged before).

Source
ls(path \\ ".")

Produces a simple list of a directory's contents. If path points to a file, prints its full path.

Source
pwd()

Prints the current working directory.

Source
r(module)

Recompiles and reloads the specified module's source file.

Please note that all the modules defined in the same file as module are recompiled and reloaded.

Source
respawn()

Respawns the current shell by starting a new process and a new scope. Returns true if it worked.

Source
v()

Prints the history of expressions evaluated during the session along with their results.

Source
v(n)

Retrieves the nth expression's value from the history.

Use negative values to lookup expression values relative to the current one. For instance, v(-1) returns the result of the last evaluated expression.

Source

Macros

h(string)

Prints the documentation for the given module or for the given function/arity pair.

Examples

h(Enum)
#=> Prints documentation for Enum

It also accepts functions in the format fun/arity and module.fun/arity, for example:

h receive/1
h Enum.all?/2
h Enum.all?

The h helper also accepts strings representing a function name, useful for retrieving information about operators:

h "*"
h "+"
h "<>"
Source
import_file(path)

Evaluates the contents of the file at path as if it were directly typed into the shell. path has to be a literal binary.

A leading ~ in path is automatically expanded.

Examples

# ~/file.exs
value = 13

# in the shell
iex(1)> import_file "~/file.exs"
13
iex(2)> value
13
Source
s(module)

Similar to t/1, only for specs.

When given a module, prints the list of all specs defined in the module.

When given a particular spec name (with optional arity), prints its spec.

Examples

s(Enum)
s(Enum.all?)
s(Enum.all?/2)
s(list_to_atom)
s(list_to_atom/1)
Source
t(module)

When given a module, prints specifications (or simply specs) for all the types defined in it.

When given a particular type name, prints its spec.

Examples

t(Enum)
t(Enum.t/0)
t(Enum.t)
Source