Standard Library
The Keel standard library provides essential modules for common programming tasks. Modules must be imported before use.
Importing Modules
-- Import specific functions
import List exposing map, filter
-- Or use qualified access
import List
List.map (|x| x * 2) [1, 2, 3]
Available Modules
| Module | Description |
|---|---|
| DataFrame | Polars-backed tabular data (read, filter, aggregate, join, window functions, expressions, labels, recode) |
| DataFrame.Expr | Composable column expressions — arithmetic, comparisons, aggregations, date extractors, type casts, window functions |
| Date | Date operations (create, parse, format, compare, arithmetic) |
| DateTime | UTC-based date and time operations (parse, format, manipulate, Date/Time interop) |
| Decimal | Arbitrary-precision decimal arithmetic (rounding, parsing, conversion) |
| Distribution | Probability distributions (Normal, Uniform, Poisson, etc.) with sampling, PDF/CDF, and statistical moments |
| Duration | Time span operations (create, convert, arithmetic, comparison) |
| Http | HTTP client with composable request builders |
| IO | Input/output, files, and environment |
| Json | JSON parsing, encoding, and field extraction |
| List | List manipulation (map, filter, fold, etc.) |
| Math | Mathematical functions (abs, sqrt, sin, etc.) |
| Maybe | Composable optional handling (map, andThen, withDefault) |
| Num | Partition aggregate helpers for windowMutate closures (mean, sum, rank, denseRank, rowNumber, quantile, cumulative, rolling, lag/lead, first, last, count) |
| Regex | Compiled regular expression patterns (compile, test, find, replace, split, captures) |
| Result | Composable error handling (map, andThen, withDefault) |
| String | String operations (split, join, trim, etc.) |
| Table | Cross-tabulation and summary tables for statistical analysis |
| Time | Time-of-day operations (create, parse, format, compare, arithmetic) |
| ValueLabel | Access and transform individual ValueLabel pairs (value, label, create, map, match) |
| ValueLabelSet | Bidirectional Int↔String mappings for statistical value labels (supports fromType for compile-time extraction from ValueLabel enums) |
Note: Keel 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
enum Maybe a = Just a | Nothing
Represents an optional value.
let present: Maybe Int = Just 42
let absent: Maybe Int = Nothing
case present of
Just n -> n
Nothing -> 0
Try itResult
enum Result a e = Ok a | Err e
Represents success or failure.
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
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.
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.