Quick Start
3 Using Libraries
3.1 OTP Modules
Taking advantage of the
Erlang stdlib is
straightforward. All you need to do is prepend the call with a :
and
adjust to use the LFE syntax vs. the Erlang syntax.
In fact, we've already seen an example of this in Section 2
when we called (: io format ...)
as part of a "Hello World."
Here's an example base64
usage from the Erlang stdlib
:
3.2 Processes in LFE
One of the first things that people want to do with LFE is examine the message passing syntax so that they can compare it with vanilla Erlang. Here's a small example of what this looks like in LFE:
If that was saved in a module called messenger
, then one could utilize it
thusly:
For more information on working with processes in LFE, be sure to view the tutorial.
Related to this, you can find details and discussion around OTP and creating your own servers in the OTP Servers tutorial.
3.3 Third-Party Libraries
Finally, accessing code that is written in third-party libraries is exactly the
same. Simply use the modules they have provided. If you started the LFE REPL
pointing to your third-party libraries with a -pa
(path) option, then all
you have to do is this:
That's it!