DEV Community

Discussion on: Mixing Gleam & Elixir

Collapse
 
chazsconi profile image
chazsconi

Nice article. This has allowed me to add a bit of gleam to my existing Elixir project.

I found that if I want to use gleam libraries I need to put them in a rebar.config in the project root so that the project compiles, but then also add them to the mix.exs so that they are available at run time. Do you have any ideas for avoiding this duplication?

Collapse
 
michaeljones profile image
Michael Jones

Thanks for the comment. I'm sorry to say that I've not gone much further on this so I actually can't help you with your issue. I'm excited by Gleam but I'm still trying to figure out how to fit it into my projects.

I asked on the Elixir Forum Gleam thread about further interop between Phoenix, Ecto & Gleam but lpil, the Gleam creator, suggests that this might be quite hard due to Elixir macros. I'm keen to explore more but I haven't found the time.

Collapse
 
chazsconi profile image
chazsconi

OK - thanks for the reply! I'll let you know if I find out more myself.

Thread Thread
 
crowdhailer profile image
Peter Saxton

I contributed a fix to Gleam that means it now finds gleam source for dependencies in a mix project github.com/gleam-lang/gleam/pull/596

Also instead of defining your own compiler module an alias will do aliases: ["compile.gleam": "cmd gleam build"]

I put a working example here github.com/midas-framework/elixir_...

Thread Thread
 
chazsconi profile image
chazsconi

Great! Works perfectly. Thanks Peter!

Thread Thread
 
crowdhailer profile image
Peter Saxton

There is now. github.com/gleam-lang/mix_gleam

Which should work even better.

I've also updated the elixir with gleam example