Using LFE

LFE may be used as a shell, for scripting; as a development tool via its REPL; as a library; and as a full programming language in its own right, with a compiler that generates .beam files for use by the Erlang VM. This page aims to bring to your fingertips the resources you will need most in your daily use of LFE in one or more of these.

LFE

The REPL

As you get to know LFE, you'll find that you'll do a lot of your prototyping in the REPL. There are three primary ways you can do this:

  1. With Erlang and rebar3 installed, running rebar3 lfe repl in a project directory will start up the LFE REPL and provide access to all your project modules, include files, and dependencies.
  2. If you git cloned the LFE repo to a machine, then running make and then ./bin/lfe will start up the LFE REPL.
  3. Lastly, you can run the LFE REPL with only docker on your machine via docker run -it lfex/lfe (no Erlang, no rebar3 necessary); for many people, this is the quickest, most pain-free way of trying out LFE.

In all of the above, once you are in the REPL, you have access to the (help) function which will print out some help text for running a bunch of top-level commands. Also, you may start typing a function call (e.g., (lists:) and then double-tap <TAB> to provide a list of available functions from the given module. Very often this obviates any need to look up the function you want to call!

Reference

When (help) and tab-completion aren't enough, it's time to break out the books. The core LFE reference set (man page source files in Markdown format) is your friend:

If you want to remind yourself on all that the LFE plugin can do:

More information on Docker usage is available here:

docs.lfe.io

The docs site for LFE is quite old and almost entirely out of date, but it's linked here since it still has some jewels that haven't been ported elsewhere:

There is a newer version of the docs site whose development has been stalled. Though not currently of much use, it's available here:

Erlang

Erlang Run-Time System Application (ERTS) Reference Manual - As an LFE programmer, this is one of the most powerful reference resources you can have at your fingertips. Once you get to the point to where you are ready to build production-ready applications, this will be a constant companion. In particular:

If you will be interfacing with other languages, then these resources will be of particular use:

rebar3

One of the things you might find yourself needing is specialised rebar3 plugins for your various LFE projects. You may write these in either Erlang or LFE (or, in fact, any BEAM language that has a rebar3 compiler). There are a ton of good resources on the rebar3 project site, including:

The source for the LFE rebar3 plugin is written in Erlang and viewable here:

If you want to see examples of rebar3 plugins written in LFE itself, be sure to checkout some of the other projects in that Github org: