Otter Nonsense

Gleam v0.3 released!

Gleam has reached v0.3! Let’s take a look at some of the new features introduced since v0.1.

Module namespaces

Modules can now be namespaced, allowing use of short, convenient module names without the risk of collisions with other Gleam or Erlang modules.

To use a namespace create a directory with the name of your namespace inside the src/ directory and put your modules in there. As an example, if I’m making the hot new food delivery app snackr I might choose to have a directory structure like this:

src/
└── snackr
    ├── customer.gleam
    ├── payment.gleam
    └── food
        ├── falafel.gleam
        ├── pizza.gleam
        └── salad.gleam

Once created these modules can be brought into scope using the import statement.

import snackr/customer
import snackr/food/falafel

fn eat_lunch(louis) {
  customer:eat(louis, falafel:new())
}

It’s now possible to use multiple modules with the same name, so for convenience modules can be given a name when imported.

import space/rocket as spaceship
import salad/rocket as leafy_green

Type annotations

Gleam’s type inference doesn’t require any annotations to understand the types of all your code and provide full type safety, but we might still want to add some for documentation, or to specify more restrictive types then Gleam might otherwise infer.

It looks a little something like this:

fn is_empty(list: List(a)) -> Bool {
  list == []
}

Easier installation

Precompiled Gleam binaries for Linux and OSX can now be downloaded from the Gleam GitHub release page so it’s no longer required to install Rust on your machine and build the compiler from source.

Victor Borja has kindly created an asdf version manager plugin for Gleam, so for asdf users installing Gleam is as easy as asdf install gleam v0.3.0.

For Docker fans the Gleam compiler has been packaged as a Docker image tagged as lpil/gleam.

Easier project creation

Previously Gleam projects were created using a rebar3 plugin. This worked but was one more thing to install, and there was to good way of ensuring that you have an up to date version of the plugin to match your Gleam installation.

Now project creation is handled by the gleam binary itself, so to get started with Gleam run gleam new my_cool_project and it’ll generate all that’s required.

If you’ve got rebar_gleam installed it’s safe to delete it from your ~/.config/rebar3/rebar.config as it’s no longer used.

The rest

In addition to these features there’s been a number of other improvements to the quality of the error messages, the generated code, and a handful of bug fixes. 😊

If you want to try out the new version of Gleam head over to the installation page. I’d love to hear how you find it and get your feedback so Gleam can continue to improve.

Code BEAM lite Berlin

On the 11th of October 2019 I’ll be speaking at Code BEAM lite Berlin about Gleam. If you’re attending (or are in Berlin but not attending) say Hello!