• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Elixir
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚗️ Build Gleam code with mix

MixGleam

Hex Package Hex Docs Licence Build

An Elixir archive that teaches Mix how to work with Gleam code and dependencies!

Installation

Install the Gleam compiler onto your machine. Installation instructions can be found here.

Install or update the MixGleam archive from Hex:

$ mix archive.install hex mix_gleam

To install or update from source:

$ mix archive.uninstall mix_gleam # if this archive was previously installed
$ git clone https://github.com/gleam-lang/mix_gleam.git
$ cd mix_gleam
$ MIX_ENV=prod mix do archive.build, archive.install

Configure your Mix project to use the MixGleam archive to work with Gleam's compiler and Gleam dependencies:

# in mix.exs
# ...
  @app :my_gleam_app

  def project do
    [
      app: @app,
      # ...
      archives: [mix_gleam: "~> 0.6.1"],
      compilers: [:gleam | Mix.compilers()],
      aliases: [
        # Or add this to your aliases function
        "deps.get": ["deps.get", "gleam.deps.get"]
      ],
      erlc_paths: [
        "build/dev/erlang/#{@app}/_gleam_artefacts",
        # For Gleam < v0.25.0
        "build/dev/erlang/#{@app}/build"
      ],
      erlc_include_path: "build/dev/erlang/#{@app}/include",
      # ...
    ]
  end
# ...

To see an entire example mix.exs file you can adapt to your existing Mix project:

$ mix gleam.new --retro

If you want to write Gleam code in your project, it's a good idea to add gleam_stdlib and gleeunit to your project's dependencies:

# in mix.exs
# ...
  defp deps do
    [
      # ...
      {:gleam_stdlib, "~> 0.28"},
      {:gleeunit, "~> 0.10", only: [:dev, :test], runtime: false},
      # ...
    ]
  end
# ...

Make a src directory for your Gleam code to live in:

$ mkdir src

And add the build directory to your .gitignore file so Gleam's build artefacts are not included in your project.

To run Gleam tests from the test/ directory with :gleeunit, you can run:

$ mix gleam.test

Example

Check the test project for an example that contains both Elixir and Gleam code. See the Elixir and Gleam test files to find examples on calling Gleam code from Elixir, and vice-versa.

More Repositories

1

gleam

⭐️ A friendly language for building type-safe, scalable systems!
Rust
17,409
star
2

awesome-gleam

💯 A collection of Gleam libraries, projects, and resources
Gleam
1,225
star
3

stdlib

🎁 Gleam's standard library
Gleam
454
star
4

otp

📫 Fault tolerant multicore programs with actors
Gleam
413
star
5

http

🕸️ Types and functions for HTTP clients and servers!
Gleam
182
star
6

vscode-gleam

📟 Gleam support for VS Code
TypeScript
153
star
7

example-todomvc

📝 An example web application in Gleam
Gleam
119
star
8

gleam.vim

✌️ Gleam support for Vim/Neovim
Vim Script
100
star
9

website

🏡 Gleam's website and guide
HTML
90
star
10

json

🐑 Work with JSON in Gleam!
Gleam
86
star
11

language-tour

👩🏽‍💻 Learn Gleam in your browser
Gleam
82
star
12

gleam-mode

🐙 Gleam support for Emacs
Emacs Lisp
79
star
13

erlang

🐙 Extra code for when running on Erlang
Gleam
79
star
14

example-echo-server

🔗 An example Gleam web application
Gleam
75
star
15

tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
JavaScript
71
star
16

httpc

📡 Make requests to HTTP servers with httpc
Gleam
70
star
17

packages

📦 Search for Gleam packages
Gleam
67
star
18

cowboy

🤠 A Gleam HTTP service adapter for the Cowboy web server
Gleam
64
star
19

elli

🍛 A Gleam HTTP service adapter for the Elli web server
Gleam
60
star
20

javascript

🌼 Extra code for when running on JavaScript
Gleam
52
star
21

hackney

🪝 Make requests to HTTP servers with Hackney
Gleam
37
star
22

fetch

📡 Make requests to HTTP servers with fetch
Gleam
35
star
23

crypto

⛓️ Crypto functionality for Gleam applications
Gleam
34
star
24

plug

🔌 A Gleam HTTP service adapter for the Plug web application interface
Elixir
32
star
25

example-lisp-interpreter

👾 A Lisp interpreter in Gleam!
Gleam
32
star
26

suggestions

📙 A place for ideas and feedback
26
star
27

template-gleam-javascript

JavaScript support is built into the Gleam build tool, so this is no longer needed!
JavaScript
24
star
28

setup-erlang

👷 Erlang/OTP on GitHub Actions
PowerShell
22
star
29

hexpm-rust

⚗️ A Rust client for the Hex package manager
Rust
21
star
30

playground

Gleam
18
star
31

setup-gleam

👷‍♀️ Gleam on GitHub Actions
Shell
17
star
32

rebar_gleam

🧰 Build Gleam code with rebar3
Erlang
15
star
33

gleam-highlight.js

🎨 Gleam syntax highlighting with Highlight.js
JavaScript
11
star
34

developer-survey

🗺 Learning about the Gleam community
Gleam
11
star
35

bitwise

🍓 Bitwise operations on integers
Gleam
10
star
36

gleam-v0.17-example

JavaScript
7
star
37

branding

7
star
38

exercism-gleam

Exercises to be ported to https://github.com/exercism/gleam
Rust
6
star
39

package-interface

📦 Work with Gleam's package interfaces
Gleam
5
star
40

gleam-compiler-ci-test

Rust
5
star
41

should_assertions

☝️ EUnit compatible assertion functions for use in tests
Gleam
5
star
42

.github

📜 Organisation wide GitHub configuration files
2
star
43

hexpm

🪄 Decoders for the Hex API
Gleam
1
star