• Stars
    star
    132
  • Rank 264,216 (Top 6 %)
  • Language
    Elixir
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 2 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
14,118
star
2

awesome-gleam

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

otp

📫 Fault tolerant multicore programs with actors
Gleam
311
star
4

stdlib

🎁 Gleam's standard library
Gleam
305
star
5

http

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

vscode-gleam

📟 Gleam support for VS Code
TypeScript
105
star
7

website

🏡 Gleam's website and guide
HTML
69
star
8

example-todomvc

📝 An example web application in Gleam
Gleam
66
star
9

gleam.vim

✌️ Gleam support for Vim/Neovim
Vim Script
64
star
10

example-echo-server

🔗 An example Gleam web application
Gleam
64
star
11

cowboy

🤠 A Gleam HTTP service adapter for the Cowboy web server
Gleam
53
star
12

tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
JavaScript
52
star
13

gleam-mode

🐙 Gleam support for Emacs
Emacs Lisp
48
star
14

erlang

🐙 Extra code for when running on Erlang
Gleam
47
star
15

language-tour

👩🏽‍💻 Learn Gleam in your browser
Gleam
45
star
16

httpc

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

elli

🍛 A Gleam HTTP service adapter for the Elli web server
Gleam
44
star
18

json

🐑 Work with JSON in Gleam!
Gleam
43
star
19

packages

📦 Search for Gleam packages
Gleam
41
star
20

example-lisp-interpreter

👾 A Lisp interpreter in Gleam!
Gleam
31
star
21

plug

🔌 A Gleam HTTP service adapter for the Plug web application interface
Elixir
31
star
22

hackney

🪝 Make requests to HTTP servers with Hackney
Gleam
29
star
23

javascript

🌼 Extra code for when running on JavaScript
Gleam
29
star
24

fetch

📡 Make requests to HTTP servers with fetch
Gleam
27
star
25

suggestions

📙 A place for ideas and feedback
26
star
26

crypto

⛓️ Crypto functionality for Gleam applications
Gleam
24
star
27

template-gleam-javascript

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

setup-erlang

👷 Erlang/OTP on GitHub Actions
PowerShell
22
star
29

hexpm-rust

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

setup-gleam

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

rebar_gleam

🧰 Build Gleam code with rebar3
Erlang
15
star
32

bitwise

🍓 Bitwise operations on integers
Gleam
10
star
33

developer-survey

🗺 Learning about the Gleam community
Gleam
10
star
34

gleam-highlight.js

🎨 Gleam syntax highlighting with Highlight.js
JavaScript
9
star
35

gleam-v0.17-example

JavaScript
7
star
36

branding

7
star
37

exercism-gleam

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

gleam-compiler-ci-test

Rust
5
star
39

should_assertions

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

package-interface

📦 Work with Gleam's package interfaces
Gleam
4
star
41

.github

📜 Organisation wide GitHub configuration files
2
star
42

hexpm

🪄 Decoders for the Hex API
Gleam
1
star