On this page
Runtime Errors
Halyard catches most errors at compile time through its type system. The errors on this page can only occur at runtime because they depend on values, environment, or external systems that are unknown during compilation.
Collection Bounds
Accessing a list or tuple element at an index that doesn't exist:
let items = [1, 2, 3]
items[10]
Compiled
Tuple index out of bounds with a literal index is caught at compile time:
let triple = (1, 2, 3)
triple.5
Compiled
Use List.nth for safe access that returns Maybe instead of crashing:
import List
let items = [10, 20, 30]
-- Safe access returns Maybe
case List.nth 1 items of
Just value -> value
Nothing -> 0
Division by Zero
When the divisor is a variable, the compiler cannot know its value:
let divisor = 0.0
10.0 / divisor
Compiled
Guard against zero divisors before dividing:
import String
fn safeDivide : Int -> Int -> String
fn safeDivide a b =
if b == 0 then
"Cannot divide by zero"
else
"Result: " ++ String.fromInt (a // b)
safeDivide 10 0
Dividing by a literal
0(e.g.x / 0) is caught at compile time.
Execution Limits
The VM limits the number of instructions to prevent infinite loops:
fn loop : Int -> Int
fn loop n = loop (n + 1)
loop 0 -- Execution limit exceeded
The allocation limit prevents creating data structures that are too large:
-- Allocating a list with millions of elements would hit the limit
IO Security
IO operations are disabled by default. Set environment variables to enable them:
| Error | Cause | Fix |
|---|---|---|
IO operations are disabled | IO not enabled | Set HALYARD_IO_DISABLED=0 |
Write operations are disabled | Read-only mode | Unset HALYARD_IO_READ_ONLY |
Access denied: path outside sandbox | Sandbox violation | Access files within HALYARD_IO_SANDBOX |
See IO Security for configuration details.
HTTP Security
HTTP requests are disabled by default:
| Error | Cause | Fix |
|---|---|---|
HTTP operations are disabled | HTTP not enabled | Set HALYARD_HTTP_DISABLED=0 |
HTTP request to host not allowed | Host not in allowlist | Add host to HALYARD_HTTP_ALLOWED_HOSTS |
HTTP error | Network failure | Check URL and connection |
DataFrame Errors
DataFrame operations can fail at runtime when working with external data:
| Error | Cause |
|---|---|
DataFrame file error | File not found or unreadable |
DataFrame operation error | Invalid operation on data (e.g. aggregating non-numeric column) |
Column name typos are caught at compile time when the schema is known (e.g. in the frame a
DataFrame.readCsvwith a literal path returns, once unwrapped with?or in theOkarm of acase).
Integer Overflow
Int is a 64-bit signed integer. When an arithmetic operation produces a value outside that range, the program stops with an Integer overflow runtime error. The result never wraps around, and it is never turned into a Float:
let big = 9223372036854775807
big - 1 -- 9223372036854775806
big + 1 -- Integer overflow: the result does not fit in Int
If your values can grow that large, compute with Decimal (exact) or Float (approximate) instead.
Summary
| Category | Compile-time | Runtime |
|---|---|---|
| Type mismatches | Caught for known types | Safety net for gradual typing |
| Division by zero | Literal 0 caught | Variable divisor |
| Collection bounds | Literal index on tuples | Variable index |
| Field access | Known record types | Open/dynamic records |
| IO/HTTP/DataFrame | Security config checked | File/network errors |
| Execution limits | -- | Always runtime |