phtrivier

phtrivier

I’m trying to integrate an alpaca module with an Elixir umbrella application.

I have no idea how to tackle this, but I think I have the various pieces of the puzzle:

  • a rebar3 project can contain a mix of erlang (.erl) and alpaca (.alp) files
  • the alpaca files can export functions in modules:

E.g, with this module in a my_module.alp file:

module my_module

-- one function that takes a single argument will be publicly accessible:
export double/1

let double x =
  let add a b = a + b in
  add x x

It should export an erlang module named alpaca_my_module, with the double/1 function

  • the rebar3 project will compile the .alp file if it has a rebar.config file like this:
{erl_opts, [debug_info]}.
{deps, []}.

{shell, [
  % {config, "config/sys.config"},
    {apps, [alpatest]}
]}.

{plugins, [
    {rebar_prv_alpaca, ".*", {git, "https://github.com/alpaca-lang/rebar_prv_alpaca.git", {branch, "master"}}}
]}.

{provider_hooks, [{post, [{compile, {alpaca, compile}}]}]}.

When running rebar3 compile in an alpaca project, I manage to produce a file like ./_build/default/lib/alpatest/ebin/alpaca_my_module.beam

  • mix seems to have built-in support for building elixir projects. I’m in an umbrella project, so I tried doing something like this:
project/
  apps/
         my_alpaca_app/
             src/
                 .... . erl
                 my_module.alp
             rebar.config
             mix.exs
          an_elixir_app
             lib/
                foo.ex
  • The mix.exs file for the my_alpaca application is a default one (I have not even changed the list of compilers.)

  • I want to call the double function in my elixir application. So the mix.exs file for my_elixir_app mentions it as an “in_umbrella” dependency:

defp deps() do 
  [ { :my_alpaca_app, in_umbrella: true} ....
  • When I run mix compile in my elixir app, it seems like the erlang part of my_alpaca project is build ; but the alp one is not build (the alpaca_my_module.beam file is not created.)

So my understanding is that mix ignores the rebar.config file entirely.
Does it looks like a good lead ? How would I tell mix to use it ?

  • The next step would be to call the erlang / alp function in my elixir code:
def foo() do
  x = :alpaca_my_module.double(42)
  ... 
end

Should this be the right syntax ?

Showing Posts 1 to 6

OvermindDL1

OvermindDL1

If it’s not a mix project then it shouldn’t be in am umbrella, use a path dependency or so instead and see if that works?

Yep yep. :slight_smile:

wojtekmach

wojtekmach

Hex Core Team

I have a toy project that has Elixir, Erlang, LFE, and Gleam child apps all in the same umbrella: GitHub - wojtekmach/hello_beam: Elixir, Erlang, Gleam & LFE code all in the same project! · GitHub and so by that token Alpaca should work too if it’s built by rebar3. If you get it working a PR to hello_beam would be very appreciated! :slight_smile:

phtrivier

phtrivier OP

I should have make it clear, but what I’m trying to do is to have only mix projects in my umbrella.

What I really want is to be able to run “mix compile” as usual, and have both the alpaca and elixir code be compiled properly.

OvermindDL1

    October 3

If it’s not a mix project then it shouldn’t be in am umbrella, use a path dependency or so instead and see if that works?

phtrivier:
Should this be the right syntax ?

Yep yep. :slight_smile:

OvermindDL1

OvermindDL1

Sounds like you could make a Mix compiler for alpaca then? They aren’t actually very hard at all. :slight_smile:

phtrivier

phtrivier OP

I do not doubt they’re easy, but I have no idea how to do them. Is there a doc somewhere ?

wojtekmach

wojtekmach

Hex Core Team
— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews