Skip to content
Halyard
Project
Source code on Codeberg (opens in new tab)

Search

Menu

Standard Library

The Halyard standard library provides essential modules for common programming tasks. Modules must be imported before use.

Importing Modules

halyard
-- Import specific functions
import List exposing map, filter

-- Or use qualified access
import List

List.map (|x| x * 2) [1, 2, 3]

Available Modules

ModuleDescription
DataFramePolars-backed tabular data (read, filter, aggregate, join, window functions, expressions, labels, recode)
DataFrame.ExprComposable column expressions — arithmetic, comparisons, aggregations, date extractors, type casts, window functions
DateDate operations (create, parse, format, compare, arithmetic)
DateTimeUTC-based date and time operations (parse, format, manipulate, Date/Time interop)
DecimalArbitrary-precision decimal arithmetic (rounding, parsing, conversion)
DistributionProbability distributions (Normal, Uniform, Poisson, etc.) with sampling, PDF/CDF, and statistical moments
DurationTime span operations (create, convert, arithmetic, comparison)
HttpHTTP client with composable request builders
IOInput/output, files, and environment
JsonJSON parsing, encoding, and field extraction
ListList manipulation (map, filter, fold, etc.)
MathMathematical functions (abs, sqrt, sin, etc.)
MaybeComposable optional handling (map, andThen, withDefault)
RegexCompiled regular expression patterns (compile, test, find, replace, split, captures)
ResultComposable error handling (map, andThen, withDefault)
StringString operations (split, join, trim, etc.)
TableCross-tabulation and summary tables for statistical analysis
TimeTime-of-day operations (create, parse, format, compare, arithmetic)
ValueLabelAccess and transform individual ValueLabel pairs (value, label, create, map, match)
ValueLabelSetBidirectional Int↔String mappings for statistical value labels (supports fromType for compile-time extraction from ValueLabel enums)

Note: Halyard also supports tasks for composing programs from multiple files at compile time. This is a language keyword using run "file" { ... } and task expecting/exposing declarations, not a stdlib module.

Note: File system operations in the IO module, HTTP requests, and DataFrame file operations are disabled by default for security. See the IO Security Guide for configuration options.

Built-in Types

These types are always available without imports:

Maybe

halyard
enum Maybe a = Just a | Nothing

Represents an optional value.

halyard
let present: Maybe Int = Just 42
let absent: Maybe Int = Nothing

case present of
    Just n -> n
    Nothing -> 0

Result

halyard
enum Result a e = Ok a | Err e

Represents success or failure.

halyard
let success: Result Int String = Ok 42
let failure: Result Int String = Err "not found"

case success of
    Ok n -> n
    Err msg -> 0

ValueLabel

halyard
enum ValueLabel = ValueLabel Int String

Carries an (Int, String) pair inside enum variants — the integer code and its human-readable label. Used for survey data, coded variables, and any domain where values have both numeric codes and descriptive names.

halyard
enum Gender
    = Male (ValueLabel 1 "Male")
    | Female (ValueLabel 2 "Female")

When you construct a ValueLabel variant (e.g., Gender::Male), the integer and label are auto-supplied from the type definition. See the types guide for details, ValueLabel for accessor and transform functions, and ValueLabelSet for extracting mappings at compile time.