ex_stdlib

View Source

Elixir-inspired standard library modules implemented in Erlang.

Overview

This project provides Erlang implementations of useful modules from Elixir's standard library, bringing modern functional programming patterns and concurrent programming abstractions to Erlang.

Modules

Core Modules

  • agent - Simple state management abstraction around GenServer
  • task - Asynchronous task execution with async/await, await_many/yield_many and async_stream
  • task_supervisor - Dynamic supervisor for tasks, with linked and unlinked async tasks
  • registry - Local, decentralized key-value process storage for service discovery and pub-sub (usable as {via, registry, Name})
  • process - Convenient process management utilities and wrappers
  • keyword - Keyword list operations and utilities inspired by Elixir
  • uri - URI parsing, manipulation, and encoding/decoding utilities
  • base - Base16, Base32, and Base64 encoding/decoding with multiple variants
  • path - Cross-platform file system path manipulation and utilities
  • function - Function utilities including composition, currying, and memoization
  • dynamic_supervisor - Dynamic supervisor optimized for millions of children
  • partition_supervisor - Supervisor that starts multiple partitions of the same child
  • version - Semantic version parsing, comparison and requirement matching (~> 1.2, >= 1.0.0 and < 2.0.0)
  • tuple - Tuple utilities
  • bitwise - Bitwise operations

Features

  • Type-safe: Complete -spec annotations for all functions
  • Well-documented: Comprehensive EDoc documentation with examples
  • Battle-tested: Extensive test suites covering edge cases and error conditions
  • Production-ready: Follows OTP best practices and Erlang coding conventions

Quick Start

Build

rebar3 compile

Run Tests

rebar3 eunit

Examples

See the examples/ directory for usage examples, or start an Erlang shell:

erl -pa _build/default/lib/ex_stdlib/ebin
% Agent example - simple state management
{ok, Agent} = agent:start_link(fun() -> 0 end).
agent:update(Agent, fun(State) -> State + 1 end).
1 = agent:get(Agent, fun(State) -> State end).

% Task example - async/await
Task = task:async(fun() -> expensive_computation() end).
OtherResult = do_other_work().
TaskResult = task:await(Task).

Project Structure

ex_stdlib/
├── src/                 # Core library modules
├── test/               # EUnit test suites
├── examples/           # Usage examples
└── _build/             # Compiled artifacts

Documentation

For detailed API documentation, see individual module documentation in the source files or generate with:

rebar3 edoc