Standard Library
Kit's standard library provides core modules for fundamental programming tasks. All modules are automatically available without import statements. For additional functionality like databases, data formats, and more, see the Packages documentation.
Standard library functions can be accessed either as bare functions (e.g., map, filter)
or with their module prefix (e.g., List.map, String.split).
Use :info <Module> in the REPL to view documentation for any module,
including type definitions, function signatures, and descriptions. Try :info List
or :info Option to get started.
Type System
Kit's type system features for polymorphism and type-based dispatch:
Traits
Type-based polymorphism with Eq, Ord, Show, Default, and Num traits.
Refinements
Refinement types like PositiveInt, NonEmptyString, and NonEmptyList.
Core Types
Modules for working with Kit's primitive types:
Int
Integer operations, arithmetic, comparisons, and predicates like even? and odd?.
Float
Floating-point operations, conversions, and rounding functions.
Int64
64-bit signed integers for large values and system interop.
UInt32
32-bit unsigned integers for binary data and system interop.
Float32
32-bit floating-point for graphics, audio, and memory-efficient computation.
Bool
Boolean operations including and, or, and not.
String
String manipulation: split, join, trim, replace, case conversion, and more.
Char
Character operations: case conversion, classification, and Unicode support.
Collections
Core collection types for working with data:
List
Immutable lists with map, filter, fold, and many other functions.
Map
Immutable key-value maps with efficient lookup, insert, and update operations.
Set
Immutable sets with union, intersection, difference, and membership testing.
Tuple
Operations on tuples including fst, snd, and swap.
Record
Record operations: get, set, keys, values, and merge.
Seq
Lazy sequences for infinite and deferred computations with take, map, filter.
Vec
SIMD-accelerated vectors with push, pop, get, and indexed access.
For specialized collections like Bloom filters, SkipLists, and tree structures, see the Container module. For persistent (immutable) data structures with structural sharing, see the Persistent module.
Functional Patterns
Types for functional programming patterns:
Option
Represents optional values with Some and None. Safe handling of missing data.
Result
Error handling with Ok and Err. Functions for mapping and unwrapping.
Either
Values of two possible types with Left and Right. Unlike Result, both sides are equally valid.
Math and Numeric
Mathematical operations and numeric types:
Math
Mathematical constants (pi, e) and functions (sin, cos, sqrt, pow, log).
BigInt
Arbitrary precision integers for computations beyond standard Int range.
BigDecimal
Arbitrary precision decimals for exact financial and scientific calculations.
Rational
Exact fraction arithmetic with numerator and denominator operations.
Complex
Complex number arithmetic with real/imaginary parts and polar form.
I/O and System
Modules for interacting with the file system and environment:
StdOut
Write output to standard output with write and write-line.
StdErr
Write error messages to standard error with write and write-line.
File
Read and write files, check existence, and manage file operations.
Logging
Structured logging with levels, formats (JSON, Pretty), and context propagation.
Dir
Directory operations: list, create, remove, and traverse directories.
Glob
File pattern matching with glob patterns like *.kit and **/*.txt.
Path
Path manipulation: join, dirname, basename, extension operations.
Env
Access environment variables and system information.
Process
Process management: spawn, execute commands, and handle exit codes.
Date and Time
Modules for working with dates, times, and timestamps:
Time
Current time, timestamps, monotonic time, and CPU cycle counters.
DateTime
Date and time parsing, formatting, and component extraction.
Duration
Time spans: create from units, arithmetic, and conversion between units.
Interval
Time intervals with start/end times, overlap detection, and set operations.
Calendar
Calendar utilities: days in month, leap years, week/quarter calculations.
TimeZone
Timezone identifiers, UTC offsets, DST handling, and DateTimeError type.
Network
Modules for HTTP, TCP/UDP networking, and URL handling:
HTTP
HTTP client with GET, POST, PUT, DELETE, custom headers, and retry support.
Net
TCP and UDP socket networking for servers and clients.
URL
URL parsing, construction, and percent-encoding/decoding.
IP
IPv4 and IPv6 address parsing, validation, and classification.
Concurrency
Modules for concurrent and parallel programming:
Actor
Lightweight concurrent actors with mailboxes, state management, and message passing.
Channel
High-performance channels (SPSC, MPSC, SPMC, unbounded) for Go-style communication.
Supervisor
Supervision trees for managing actor lifecycles with restart strategies.
Parallel
Synchronous-looking parallel operations: run, map, all, first, any.
Pool
Actor pools with load balancing strategies (round-robin, random, least-loaded).
Node
Distributed actors across machines with location-transparent messaging.
Cluster
Cluster-wide operations for distributed systems and broadcasting.
Atomic
Low-level atomic operations for lock-free concurrent programming.
Encoding
Modules for data serialization and encoding formats:
JSON
Parse and generate JSON data with JSONL support.
TOML
Parse and generate TOML configuration files with type-safe getters.
CSV
Parse and generate CSV data with custom delimiters and file I/O.
Base64
Standard and URL-safe Base64 encoding and decoding.
Hex
Hexadecimal encoding and decoding for binary data.
UUID
Generate UUID v4 (random) and v7 (timestamp-based) identifiers.
Data
Modules for archives, compression, and advanced data structures:
Archive
Read and create Zip and Tar archives with streaming support.
Compress
Gzip, Zlib, and Deflate compression with checksum utilities.
Container
Advanced data structures: trees, heaps, queues, tries, and more.
Persistent
Immutable data structures with structural sharing (PVec, PMap, PSet).
Error Types
Structured error types for common operations:
IOError
Errors for file and I/O operations: FileNotFound, AccessDenied, and more.
ParseError
Errors for parsing operations: InvalidFormat, EmptyInput, Overflow.
ProcessError
Errors for process execution: ExecutionFailed, Timeout, ExitCode.
ValidationError
Errors for input validation: InvalidValue, MissingField, OutOfRange.
Utilities
Common utilities for development and profiling:
Debug
Debugging utilities: trace, tap, todo, unreachable, and source location.
Bench
Statistical benchmarking with warmup, iterations, and percentile metrics.
For YAML, XML, hashing, databases, and more advanced functionality, see the Packages documentation.
Runtime
Modules for Kit runtime and package information:
Kit
Kit language version, runtime mode, and environment information.
Package
Current package metadata: name, version, and dependency information.
SemanticVersion
Semantic version (SemVer) parsing, comparison, and manipulation.
CalendarVersion
Calendar version (CalVer) parsing, comparison, and manipulation.
Quick Reference
Most commonly used functions across all modules: