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.
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:
- With Erlang and
rebar3
installed, runningrebar3 lfe repl
in a project directory will start up the LFE REPL and provide access to all your project modules, include files, and dependencies. - If you
git clone
d the LFE repo to a machine, then runningmake
and then./bin/lfe
will start up the LFE REPL. - Lastly, you can run the LFE REPL with only docker on your machine via
docker run -it lfex/lfe
(no Erlang, norebar3
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:
- The LFE Guide
- The data types in LFE
- REPL functions, variables, and environment
- LFE formatting
- Common Lisp compatibility
- Clojure compatibility
Additionally, we have a large manual that is a work in progress and aims to provide a great deal of examples, context, and general instruction for LFE developers. That is available here:
The complete collection of published LFE books is avalable 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 fully migrated into the LFE Machine Manual:
There is a slightly newer version of the docs site whose development has been stalled. Though not currently of much use, it's available here:
Once all the usful content has been merged into the LFE Machine Manual, docs.lfe.io will redirect to this page and we'll delete this section ;-)
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:
- The erlang module
- The application module
- The supervisor module
- The gen_server, gen_event, and gen_statem modules
- The lists, maps, and proplists modules
- And many, many others ...
If you will be interfacing with other languages, then these resources will be of particular use:
- The Ports and Port Drivers reference and the Erlang Interop/Ports User Guide
- The Jinterface package and the Jinterface Reference Manual
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: