Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Gleam

< >

Gleam is a programming language created in 2016 by Louis Pilfold.

#70on PLDB 8Years Old 104Repos
Download source code:
git clone https://github.com/lpil/gleam
Homepage · REPL · Source Code · Subreddit · Twitter · Docs

Gleam is a statically typed functional programming language for building scalable concurrent systems. It compiles to Erlang and has straightforward interop with other BEAM languages such as Erlang, Elixir and LFE.


Example from the web:
import gleam/io pub fn main() { io.println("hello, friend!") }

Language features

Feature Supported Example Token
Decorators @deprecated("Use new_function instead") fn old_function() { Nil }
Lists let numbers = [1, 2, 3, 4, 5]
Booleans let is_awesome = True
Floats let pi = 3.14159
Union Types type IntOrFloat { AnInt(Int) AFloat(Float) } fn int_or_float(x: IntOrFloat) { case x { AnInt(1) -> "It's an integer: 1" AFloat(1.0) -> "It's a float: 1.0" } }
Module Pattern // Gleam’s file is a module and named by the file name (and its directory path). Since there is no special syntax to create a module, there can be only one module in a file. // in file main.gleam import wibble // if wibble was in a folder called `lib` the import would be `lib/wibble` pub fn main() { wibble.identity(1) }
Type Aliases pub type Headers = List(#(String, String)) let headers: Headers = [#("Content-Type", "application/json")]
Integers let age = 30
Line Comments // This is a line comment in Gleam
Comments // This is a single-line comment // Gleam doesn't have multi-line comments // Gleam has /// and //// comments which are used for attaching documentation to code. /// is used for documenting types and functions, and should be placed immediately before the type or function it is documenting. //// is used for documenting modules, and should be placed at the top of the module.
Strings "Hello world"
Print() Debugging io.println("Hello world")
File Imports import gleam/io import unix/cat as kitty import animal/cat.{Cat, stroke}
Semantic Indentation X // Gleam uses curly braces for blocks, not indentation

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v154.3.0