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 lfe replin a project directory will start up the LFE REPL and provide access to all your project modules, include files, and dependencies.
- If you
git cloned the LFE repo to a machine, then running
./bin/lfewill 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, no
rebar3necessary); 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!
(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
If you want to remind yourself on all that the LFE plugin can do:
More information on Docker usage is available here:
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 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
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: