gs
- A lightweight Gleam library that introduces the Stream
type for handling lazy value sequences. The library offers comprehensive functionality for creating, transforming, and processing streams, enabling efficient manipulation of sequential data.
A Stream
consists of a Source element that generates data, followed by zero or more Pipe elements that transform the data, and concludes with a Sink element that consumes the data to produce a result.
The Source is a lazy data structure that represents a sequence of values. It enables on-demand evaluation, making it highly efficient for processing large or infinite data sets. The library includes several built-in sources, such as from_list, from_range, and from_tick, which all follow the naming convention of starting with from_.
The Pipe elements are functions that transform the data in the stream. They can be used to map, or filter the data, among other operations like executing side effects. The library provides a variety of built-in pipe functions, such as map, filter, and take, which can be combined to create complex data processing pipelines.
The Sink is a function that processes data from a stream to generate a result. It can collect data into a list, subject or fold in a single value. Additionally, a Sink can terminate an infinite stream by consuming elements until a specific termination condition is met, such as to_nil_error_terminated.
Add gs
to your Gleam project:
gleam add gs
Check out the /examples
directory for sample implementations.
Further documentation can be found at https://hexdocs.pm/gs.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
gleam run # Run the project
gleam test # Run the tests