Introduction
Elara’s standard library provides essential modules and functions for common programming tasks. The standard library is automatically available when you import thePrelude module, which re-exports commonly used functionality.
Core Modules
The standard library is organized into focused modules:Prelude
Core utilities and operators imported by default
List
Functions for working with linked lists
String
String manipulation and concatenation
Option
Optional values for safe null handling
Result
Error handling with Result types
Elara.Prim
Primitive types and operations
Importing Modules
To use standard library modules in your code, import them at the top of your file:The
Prelude module is typically imported in most Elara programs as it provides essential operators and utilities.Design Philosophy
Functional First
Elara’s standard library is designed with functional programming principles:- Immutability: All data structures are immutable by default
- Pure Functions: Functions have no side effects (except IO operations)
- Type Safety: Strong static typing catches errors at compile time
- Composability: Functions are designed to work together seamlessly
Minimal and Focused
Each module provides a focused set of functions:List Module
List Module
Operations for working with linked lists including
append, zip, reverse, flatten, and more.String Module
String Module
String concatenation, conversion between strings and character lists, and joining.
Option Module
Option Module
Safe handling of nullable values with
Some and None constructors.Result Module
Result Module
Error handling with
Ok and Err constructors, including map and bind operations.Common Patterns
Pipeline Operator
The pipeline operator|> from Prelude enables readable data transformations:
Pattern Matching
All standard library types support pattern matching:Function Composition
Compose functions using the>> operator:
Primitive Types
Elara provides these primitive types inElara.Prim:
| Type | Description |
|---|---|
Int | Integer numbers |
Float | Floating-point numbers |
Char | Single characters |
String | Text strings |
Bool | Boolean values (True or False) |
Unit | The unit type () |
IO a | IO operations that produce values of type a |
Next Steps
Prelude
Learn about core operators and utilities
List Operations
Master list manipulation functions
Error Handling
Handle errors with Result types
Examples
See the standard library in action