Modules

File = module. Each .silt file is a module named after the file:

-- File: math.silt
pub fn add(a, b) = a + b
fn internal_helper(x) = x * 2   -- private

Private by default. Only pub items are exported. When a pub type has enum variants, all constructors are exported too.

Three import forms:

import math                  -- qualified: math.add(1, 2)
import math.{ add, Point }   -- direct: add(1, 2)
import math as m              -- aliased: m.add(1, 2)

Built-in modules are registered in the global environment (no .silt files needed):

ModuleKey Functions
ioinspect, read_file, write_file, read_line, args
listmap, filter, fold, each, find, zip, …
mapget, set, delete, contains, keys, values, …
setnew, from_list, to_list, contains, insert, …
stringsplit, join, trim, contains, replace, length
intparse, abs, min, max, to_float, to_string
floatparse, round, ceil, floor, abs, to_int, to_string
resultis_ok, is_err, map_ok, map_err, unwrap_or, flatten, flat_map
optionis_some, is_none, map, unwrap_or, to_result, flat_map
regexis_match, find, find_all, replace, replace_all_with
jsonparse, stringify, pretty
testassert, assert_eq, assert_ne
channelnew, send, receive, close, select, each
taskspawn, join, cancel
envget, set
mathsqrt, pow, exp, log, log10, sin, cos, tan, random, pi, e, …
timenow, today, date, format, parse, add_days, weekday, sleep
fsexists, is_file, is_dir, list_dir, mkdir, remove, copy, rename
httpget, request, serve, segments

Notable Standard Library Details

Circular imports are detected and rejected with a clear error message.