Mixing LFE and Erlang in the same project

107 views
Skip to first unread message

Mário Guimarães

unread,
Apr 4, 2016, 10:57:09 AM4/4/16
to lisp-flavo...@googlegroups.com
Hello,

I was looking for information regarding using LFE inside an Erlang project, but found nothing.

The idea is to have files written in Erlang calling functions in files written in LFE, and vice-versa.

How can this be done?

Thanks
Mário

PS: don't know if this is relevant, but I am using rebar3 in the project.

Mário Guimarães

unread,
Apr 4, 2016, 12:25:27 PM4/4/16
to Lisp Flavoured Erlang
Hello,

I have finally discovered what to do here

http://blog.lfe.io/tutorials/2016/03/25/0858-lfe-and-rebar3

Since then, I installed the follwoing tasks:

lfe <task>:
  compile        The LFE rebar3 compiler plugin
  lodox          Generate documentation from LFE source files.
  repl           The LFE rebar3 LFE REPL plugin.
  version        The LFE rebar3 version plugin.

As far I can tell, I have noticed the following issues:

1) everytime I run "rebar3 ..." I get a very annoying list like this:

===> Skipping lfe (from {git,"git://github.com/rvirding/lfe.git",
                                   {ref,
                                       "b84e9a8a1db6ffdd0cfe593fc8ad440ef72a5511"}}) as an app of the same name has already been fetched
===> Skipping clj (from {git,"git://github.com/lfex/clj.git",
                                    {tag,"0.3.0"}}) as an app of the same name has already been fetched
===> Skipping clj (from {git,"git://github.com/lfex/clj.git",
                                   {ref,
                                       "2184d0f1459922145b432cfe19ac6147169383d7"}}) as an app of the same name has already been fetched
.... (and so on, ....)

How can this be turned off?

2) I can enter the lfe shell doing "rebar3 lfe repl", but when I quit, this happens:

> (q)
ok
> {error_logger,{{2016,4,4},{17,23,27}},"Error in process ~p with exit value:~n~p~n",[<0.1331.0>,{terminated,[{io,put_chars,[standard_io,unicode,["1",58,32,"terminated",10]],[]},{lists,foreach,2,[{file,"lists.erl"},{line,1337}]},{lfe_shell,server_loop,2,[{file,"/Users/guimas/Documents/Projetos/Erlang/webapp/_build/default/plugins/lfe/src/lfe_shell.erl"},{line,116}]}]}]}
{error_logger,{{2016,4,4},{17,23,27}},"Error in process ~p with exit value:~n~p~n",[<0.1331.0>,{terminated,[{io,put_chars,[standard_io,unicode,["1",58,32,"terminated",10]],[]},{lists,foreach,2,[{file,"lists.erl"},{line,1337}]},{lfe_shell,server_loop,2,[{file,"/Users/guimas/Documents/Projetos/Erlang/webapp/_build/default/plugins/lfe/src/lfe_shell.erl"},{line,116}]}]}]}

3) For consistency with the default rebar3 tasks, we should be doing "rebar3 lfe shell" instead of "rebar3 lfe repl"

Regards
Mário

Fred Hebert

unread,
Apr 4, 2016, 2:07:36 PM4/4/16
to lisp-flavo...@googlegroups.com
On 04/04, Mário Guimarães wrote:
>
>1) everytime I run "rebar3 ..." I get a very annoying list like this:
>

This is a known issue, we're just a bit short on hands to fix bugs in
rebar3.
https://github.com/erlang/rebar3/issues/1105#issuecomment-192802395

Duncan McGreggor

unread,
Apr 4, 2016, 6:07:30 PM4/4/16
to Lisp Flavoured Erlang
On Mon, Apr 4, 2016 at 11:25 AM, Mário Guimarães <mario.luis...@gmail.com> wrote:
Hello,

I have finally discovered what to do here

http://blog.lfe.io/tutorials/2016/03/25/0858-lfe-and-rebar3


Yup, that's the answer to your question. (More below ...)
 
Since then, I installed the follwoing tasks:

lfe <task>:
  compile        The LFE rebar3 compiler plugin
  lodox          Generate documentation from LFE source files.
  repl           The LFE rebar3 LFE REPL plugin.
  version        The LFE rebar3 version plugin.

As far I can tell, I have noticed the following issues:

1) everytime I run "rebar3 ..." I get a very annoying list like this:

===> Skipping lfe (from {git,"git://github.com/rvirding/lfe.git",
                                   {ref,
                                       "b84e9a8a1db6ffdd0cfe593fc8ad440ef72a5511"}}) as an app of the same name has already been fetched
===> Skipping clj (from {git,"git://github.com/lfex/clj.git",
                                    {tag,"0.3.0"}}) as an app of the same name has already been fetched
===> Skipping clj (from {git,"git://github.com/lfex/clj.git",
                                   {ref,
                                       "2184d0f1459922145b432cfe19ac6147169383d7"}}) as an app of the same name has already been fetched
.... (and so on, ....)

How can this be turned off?

Fred has answered this -- I had asked the same question :-)
 

2) I can enter the lfe shell doing "rebar3 lfe repl", but when I quit, this happens:

> (q)
ok
> {error_logger,{{2016,4,4},{17,23,27}},"Error in process ~p with exit value:~n~p~n",[<0.1331.0>,{terminated,[{io,put_chars,[standard_io,unicode,["1",58,32,"terminated",10]],[]},{lists,foreach,2,[{file,"lists.erl"},{line,1337}]},{lfe_shell,server_loop,2,[{file,"/Users/guimas/Documents/Projetos/Erlang/webapp/_build/default/plugins/lfe/src/lfe_shell.erl"},{line,116}]}]}]}
{error_logger,{{2016,4,4},{17,23,27}},"Error in process ~p with exit value:~n~p~n",[<0.1331.0>,{terminated,[{io,put_chars,[standard_io,unicode,["1",58,32,"terminated",10]],[]},{lists,foreach,2,[{file,"lists.erl"},{line,1337}]},{lfe_shell,server_loop,2,[{file,"/Users/guimas/Documents/Projetos/Erlang/webapp/_build/default/plugins/lfe/src/lfe_shell.erl"},{line,116}]}]}]}

The lfe rebar3 repl plugin is actually in an early alpha stage -- there are a series of open tickets for it here:
 * https://github.com/lfe-rebar3/repl/issues

The lfe rebar3 repl plugin was created by mimicking what rebar3 Erlang shell plugin does, and I'm not sure how necessary that approach is for LFE. I would love to get Robert's opinion on that, if he gets a chance to review the code.

Those issues are community issues -- if you have the interest and inclination, PRs, code reviews, etc., are *very* welcome. We're a small community and thus stretched very thin, so any help is greatly appreciated.


3) For consistency with the default rebar3 tasks, we should be doing "rebar3 lfe shell" instead of "rebar3 lfe repl"

They are actually two different things. The Erlang shell does not provide full access to the language, and I do not believe it is a read-eval-print loop in the classic sense (Robert or Fred, please correct me if I am wrong!). The LFE repl really is a repl -- I believe you could even make your own simple one using analogs to (print (eval (read x))). What's more, you can define functions, macros, records, etc., in the LFE repl -- things you can't do (or do so easily) in the Erlang shell.

It may be helpful to read Rainer Joswig's thoughts (he's a well-known Common Lisp advocate and extremely knowledgeable) on this here:
 * http://stackoverflow.com/a/5673496

Whether something is considered a repl or a shell tends to be a matter of convention in individual communities. As for LFE and Erlang, though, there is a significant difference between the two: LFE provides more complete access to the features of the language and owes a great deal to its Lisp heritage, where repls originated.

Hope that helps,

d

 

Regards
Mário





segunda-feira, 4 de Abril de 2016 às 15:57:09 UTC+1, Mário Guimarães escreveu:
Hello,

I was looking for information regarding using LFE inside an Erlang project, but found nothing.

The idea is to have files written in Erlang calling functions in files written in LFE, and vice-versa.

How can this be done?

Thanks
Mário

PS: don't know if this is relevant, but I am using rebar3 in the project.

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-e...@googlegroups.com.
To post to this group, send email to lisp-flavo...@googlegroups.com.
Visit this group at https://groups.google.com/group/lisp-flavoured-erlang.
For more options, visit https://groups.google.com/d/optout.

Robert Virding

unread,
Apr 6, 2016, 9:05:28 PM4/6/16
to lisp-flavo...@googlegroups.com
Hi Mário,

What exactly is the problem? Is it to build a combined LFE/Erlang application using rebar3? Or is it in the code to get LEF and Erlang to call and use each other?

Robert

Mário Guimarães

unread,
Apr 7, 2016, 11:11:08 AM4/7/16
to lisp-flavo...@googlegroups.com
Hi Robert,

I am looking for a setup having Erlang + LFE + Yaws managed by Rebar3.

I want to code both in Erlang and LFE, having both call each other.

Is there any example of this already setup by someone that could be shared,
so that newcomers could start coding furiously right away?

What would be REALLY useful is an "Erlang-LFE-Yaws-Rebar3 Startup Kit for the Impatient".
With such a kit, starting coding a new application would be just a "copy the kit" distance away.

Is there something like this, or do I have to setup one?

Also: congratulations for LFE 1.0 !

Thanks
Mário

Mário Guimarães

unread,
Apr 7, 2016, 11:37:33 AM4/7/16
to lisp-flavo...@googlegroups.com
Hi Duncan,


> Those issues are community issues -- if you have the interest and inclination, PRs, code reviews, etc., are
> *very* welcome. We're a small community and thus stretched very thin, so any help is greatly appreciated.

I had to spend the last months learning and teaching Haskell, so I did not had time to spend on Erlang / LFE. That being said, I would love to contribute to the community one day, but right now I have not enough experience with Erlang / LFE.

Thanks
Mário

Duncan M. McGreggor

unread,
Apr 7, 2016, 11:41:56 AM4/7/16
to lisp-flavo...@googlegroups.com
Mário,

I'm traveling right now but will be able to give you this soon (within a day or two). I can update the lfe-yaws-rest-starter project to use rebar3 -- that should get you most of the way there.

This actually dovetails nicely with another pending task I have for the community: a 0.0 "release" of dragon (i.e. some docs on how to do web dev *now*).

d

Sent from my iPhone

Duncan M. McGreggor

unread,
Apr 7, 2016, 11:43:59 AM4/7/16
to lisp-flavo...@googlegroups.com
No worries! Whenever you do, we're eager to accept them :-)

d

Sent from my iPhone

Duncan McGreggor

unread,
Apr 8, 2016, 8:29:35 PM4/8/16
to Lisp Flavoured Erlang
Okay Mário, this should get you started:
 * https://github.com/lfex/yaws-sample-app

That's based on the Docker LFE/YAWS web app project, but it uses rebar3, all the latest releases of libs, and makes several other changes.

I need to update the Docker LFE/YAWS repo to take advantage of this now ... and, of course, put some text behind this (in tutorial form).

Let me know if you have any questions or run into any problems (you can also open tickets in that repo, if you think you find some bugs, etc.).

d

Duncan McGreggor

unread,
Apr 8, 2016, 8:52:57 PM4/8/16
to Lisp Flavoured Erlang
I've renamed the repo:
 * https://github.com/lfex/lfeyawsdemo

It now also uses LFE logjam, showing ANSI colored output by default.

d

Duncan McGreggor

unread,
Apr 9, 2016, 2:30:50 AM4/9/16
to Lisp Flavoured Erlang
I've just finished overhauling the Docker LFE+YAWS sample app. If you don't want to install YAWS, LFE, Erlang, etc., on your machine but are okay having Docker installed, you can run the web app with just the following (it has been pushed to Docker hub):

docker run -p 5099:5099 -t lfex/lfe-yaws-sample-app

The repo is here:
 * https://github.com/lfex/docker-lfe-yaws-sample-app

Both the Dockerhub image and the github repo use rebar3 now.

Bonus: the latest updates to the sample app use the new theme that's being developed for v3 of the LFE docs site.

d

Mário Guimarães

unread,
Apr 9, 2016, 12:17:33 PM4/9/16
to lisp-flavo...@googlegroups.com
Hi Duncan,

thanks for the repo!
After some struggle, I managed to install and run successfully using your instructions on https://github.com/lfex/lfeyawsdemo

The struggle was due to the fact that I was missing some tools on my OSX. After installing them, I tested building Yaws by myself and I succeeded. I just had to do:

cd _build/default/lib/yaws
autoreconf -fi
rebar get-deps compile

However, after this, doing "make run" results in this:

$ make run
===> Verifying dependencies...
===> Compiling lfeyawsdemo
 ~~>     Finding .lfe files ...
make[2]: *** No targets specified and no makefile found.  Stop.
make[1]: *** [yaws] Error 2
make: *** [compile] Error 2

but doing this by hand it runs the demo:

_build/default/lib/yaws/bin/yaws -i -pa `rebar3 path -s" -pa "` --conf priv/etc/yaws.conf --id lfeyawsdemo

Anyway, having the pre-requisite tools, I git cloned again the lfeyawsdemo repo, and did "make run" to start again, and this time everything worked. Know, on the new repo, "make run" always works. I attach the log of this second attempt, as it lists several warnings due to deprecated stuff that you or Robert might want to check.

I did not get the chance to try the Docker image, but I'll do sometime later.

As a suggestion, it would be interesting to see this demo evolving into a "LFE + Erlang SDK" which would include all the useful content you are producing, like examples, and the documentation like the Hyperglot table, the "Casting Spels" document, the "User Manual", etc.

Know, let's learn this, and start some good coding.

Thans
Mário

PS: attached you will find the log of "make run" in the second attempt. Hope this is useful to you.
lfeyawsdemo.log
Reply all
Reply to author
Forward
0 new messages