stdlib

GitHub release test Nix-compatible

Mirrors: GitHub | Codeberg

This is a port of Gleam’s standard library (https://github.com/gleam-lang/stdlib) to Glistix’s Nix target. Documentation is available on HexDocs.

Note: This is a Glistix project, and as such may require the Glistix compiler to be used.

Installation

For the most recent instructions, please see the Glistix handbook.

This fork is available on Hex and already installed by default on any new Glistix projects using glistix new.

For existing projects, you can use this fork by running glistix add gleam_stdlib followed by adding the line below to your Glistix project’s gleam.toml file (as of Glistix v0.7.0):

[glistix.preview.patch]
# ... Existing patches ...
# Add this line:
gleam_stdlib = { name = "glistix_stdlib", version = ">= 0.34.0 and < 2.0.0" }

This ensures transitive dependencies on gleam_stdlib will also use the patch.

Keep in mind that patches only have an effect on end users’ projects - they are ignored when publishing a package to Hex, so end users are responsible for any patches their dependencies may need.

If your project or package is only meant for the Nix target, you can also use this fork in [dependencies] directly through glistix add glistix_stdlib in order to not rely on patching. However, the patch above is still going to be necessary for end users to fix other dependencies which depend on gleam_stdlib.

Inconsistencies and missing features on Nix

Compared to the standard library for other targets, the following functions were not yet implemented on the Nix target and will lead to a crash upon usage (contributions welcome):

Additionally, the following functions currently have an inconsistent implementation on the Nix target compared to the Erlang and JavaScript targets:

Usage

Import the modules you want to use and write some code!

import gleam/string

pub fn greet(name: String) -> String {
  string.concat(["Hello ", name, "!"])
}

Targets

Supports Erlang, JavaScript and Nix (requires Glistix).

Compatibility

For Erlang and JavaScript targets, the same disclaimer as gleam_stdlib applies:

“This library is compatible with all versions of Erlang/OTP, NodeJS, and major browsers that are currently supported by their maintainers. If you have a compatibility issue with any platform open an issue and we’ll see what we can do to help.”

Regarding Nix, in principle we aim to support as many Nix 2.x versions as possible. Most of the initial work has been done on Nix 2.18, but should be compatible with prior versions (we haven’t yet tested to which extent). Let us know if you have any trouble by opening an issue.

Search Document