Hot on the heels of Gleam v0.13 comes another release, Gleam v0.14! As always, let’s take a look at some of the highlights.

Dialyzer & Erlang typespecs

Many dynamically typed BEAM languages support Erlang’s typespecs, type annotations that can be analysed with the Dialyzer tool. While not as powerful or reliable as Gleam’s type system it can be a useful tool for finding problems with your Erlang or Elixir code. Dialyzer doesn’t require typespecs but it can work better if they are added to the code.

Starting with this release Gleam will generate typespecs for all functions and Erlang type definitions for all declared types within a Gleam program, giving you one extra tool to help you write robust and reliable code when using Gleam alongside Elixir or Erlang.

For a quick example, here’s some code in Gleam:

pub type LinkedList(element) {
  Node(element, LinkedList(element))

pub fn is_empty(list) {
  list == Empty

pub fn map(list, fun) {
  case list {
    Empty -> Empty
    Node(i, list) -> Node(fun(i), map(list, fun))

And here’s the Erlang code and typespecs it compiles to:


-export([is_empty/1, map/2]).

-type linked_list(H) :: empty | {node, H, linked_list(H)}.

-spec is_empty(linked_list(any())) -> boolean().
is_empty(List) ->
    List =:= empty.

-spec map(linked_list(R), fun((R) -> U)) -> linked_list(U).
map(List, Fun) ->
    case List of
        empty ->

        {node, I, List@1} ->
            {node, Fun(I), map(List@1, Fun)}

No annotations are required at all in your Gleam code to get full typespec coverage, Gleam’s compiler reuses the type information from its powerful type inference algorithm to determine the correct typespecs.

Thank you Greg for this brilliant new feature!

Erlang escripts

Erlang projects are unusual in that typically instead of having a main function as the entrypoint of your application you define a tree of actors to come online and process items of work while your program is running.

This can be a powerful way to write long-lived services that make use of the runtime’s fault tolerance features, but it does not lend itself well to short-lived programs such as command line scripts. It can be confusing to newcomers from other languages too.

For these short lived programs Erlang escripts are typically used. These are lightweight Erlang programs that have a main function as an entrypoint.

To make it easier to use these from Gleam the gleam new command now has an escript template that can be used to create an escript project without any further configuration required.

gleam new my_script --template escript

A world class developer experience is a key goal of the Gleam project. Further tooling improvements are right around the corner!

Night mode

Gleam has the ability to render HTML documentation for your code, ready to upload to Hexdocs.

Thanks to Tynan Beatty the documentation is looking better than ever! There’s too many improvements to list but the big one is they now have a night mode! If you’re a night owl like me I’m sure you will enjoy the lower contrast dark tones when doing some late evening coding.

A screenshot of Gleam's rendered docs showing a beautiful dark theme

Better errors, again

At the risk of sounding like a broken record Gleam’s error messages have been improved yet again. Here’s an example of one of the improvements:


error: Syntax error
    ┌─ /src/thing.gleam:115:18
115 │ pub fn overlappedBy(compare, a, b) -> Bool {
    │                  ^^ I was not expecting this.

Expected one of: "("


error: Syntax error
    ┌─ /src/thing.gleam:115:18
115 │ pub fn overlappedBy(compare, a, b) -> Bool {
    │                  ^^ This is not a valid name.

Hint: Names start with a lowercase letter and contain a-z, 0-9, or _.
Try: overlapped_by

Thank you to Samuel Mercier and Andy Thompson for these.

Static bit string validation

Bit string syntax is a feature that Gleam inherits from Erlang. It provides a way to declartively and concisely construct and manipulate raw bits of data through literals and pattern matching.

With this Gleam release we apply further static analysis to bit string literals and patterns used in Gleam programs to catch invalid or incorrect code.

Here’s an example of one of the errors that may be reported:

error: Syntax error
  ┌─ /Users/a/parser_test/src/a.gleam:2:20
2 │   <<1:size(1)-unit(0)>>
  │                    ^ This is not a valid BitString unit value.

Hint: unit must be an integer literal >= 1 and <= 256

Thank you Greg for this bit string safety net.

Docker images

Up until now Peter Saxton has been very kindly building Gleam docker images for use in Memo and the wider community.

With this release he has ported his build automation over to the Gleam repo so we have automation creation of OCI/Docker images built and published automatically with each release.

We are building these variants:

For all the images see the Gleam image registry. Thanks Peter!

Other stuff

These are just some of the highlights, but there’s plenty more improvements made to the compiler and the standard library since the last release. For all the details check out the changelog files:

Discord chat

It’s time to plug the Gleam Discord server again! The community continues to grow and it would be great to have you there too, so please click on the button below.

Discord chat

Try it out

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

Want to view some existing Gleam projects? Head on over to the awesome-gleam list. Looking for something to build in Gleam? Check out the suggestions tracker.

Supporting Gleam

If you would like to help make strongly typed programming on the Erlang virtual machine a production-ready reality please consider sponsoring Gleam via the GitHub Sponsors program.

⭐ Or alternatively give us a star on GitHub! ⭐

This release would not have been possible without the support of all the people who have sponsored and contributed to it, so a huge thank you to them.

Thanks for reading! Have fun! 💜