# Library

The builtin modules, grouped by topic. Every function has its signature, a short description and a small example. Functions in the `String`, `List`, `Map`, `Set`, `Range`, `Int`, `Float`, `Result` and `JSON` modules whose first parameter has that type can also be called as methods: `String.upcase(s)` is the same as `s.upcase`. A family groups modules under one name, as Ruby's `OpenSSL::Cipher` does: [`OpenSSL.Cipher.aes_256_gcm_encrypt`](https://www.agentica-lang.com/agentica/library/text-and-data/crypto/index.md) is the function `aes_256_gcm_encrypt` of the member `Cipher` of the `OpenSSL` family, and only `OpenSSL` is a reserved name.

You can also look up any builtin from the command line with `agentica help NAME`; `agentica help` alone lists the namespaces and the builtin types, and `agentica help --json` prints every builtin and builtin type as one JSON array.

## Pages in this section

- [Data structures](https://www.agentica-lang.com/agentica/library/data-structures/index.md): Lists, maps, sets, queues, heaps, ranges, bytes, lazy pipelines and optional values, and when to use each.
- [List](https://www.agentica-lang.com/agentica/library/data-structures/list/index.md): Functions for List[T]. Each one is also a method on lists.
- [Map](https://www.agentica-lang.com/agentica/library/data-structures/map/index.md): Functions for Map[K, V]. Each one is also a method on maps.
- [Set](https://www.agentica-lang.com/agentica/library/data-structures/set/index.md): Functions for Set[T], a collection of distinct Int, String or Bytes values. Each one is also a method on sets.
- [Heap (std)](https://www.agentica-lang.com/agentica/library/data-structures/heap/index.md): The std/heap module, a priority queue of any type in the order you give.
- [Queue (std)](https://www.agentica-lang.com/agentica/library/data-structures/queue/index.md): The std/queue module, a first-in, first-out queue of strings.
- [Range](https://www.agentica-lang.com/agentica/library/data-structures/range/index.md): Ranges of Int values, and the Int loop methods times, upto and downto.
- [Lazy](https://www.agentica-lang.com/agentica/library/data-structures/lazy/index.md): Lazy pipelines over lists, ranges, endless sources, files and channels, run one item at a time by a terminal, with try in the blocks and a terminal that writes a file.
- [Bytes](https://www.agentica-lang.com/agentica/library/data-structures/bytes/index.md): Bytes, a compact immutable byte string, and the methods that read, cut, join and build it.
- [Optional](https://www.agentica-lang.com/agentica/library/data-structures/optional/index.md): A value that may be missing, with some and none.
- [Text and data](https://www.agentica-lang.com/agentica/library/text-and-data/index.md): Work with text and numbers, search and replace text with regular expressions, read and write JSON and TOML, encode URLs, escape HTML and handle cookies, find the media type of a file, read Unix time as a UTC date and RFC 3339 text, pack numbers into bytes, hash and sign bytes, and draw secure random bytes.
- [String](https://www.agentica-lang.com/agentica/library/text-and-data/string/index.md): Functions for text. Each one is also a method on String values.
- [Int and Float](https://www.agentica-lang.com/agentica/library/text-and-data/numbers/index.md): Convert between Int, Float and String, round, clamp and other number helpers, and work on the bits of an Int or a Float.
- [JSON](https://www.agentica-lang.com/agentica/library/text-and-data/json/index.md): Encode values as JSON, decode JSON into structs, and read dynamic JSON.
- [Binary data (std)](https://www.agentica-lang.com/agentica/library/text-and-data/binary/index.md): The std/binary module, which reads and writes binary numbers in a Bytes.
- [TOML (std)](https://www.agentica-lang.com/agentica/library/text-and-data/toml/index.md): The std/toml module, which reads and writes TOML 1.0 documents.
- [OpenSSL](https://www.agentica-lang.com/agentica/library/text-and-data/crypto/index.md): The OpenSSL family of builtins. OpenSSL.Digest hashes bytes with MD5, SHA-1, SHA-256 and SHA-512, OpenSSL.HMAC signs bytes with a key and compares MACs in constant time, OpenSSL.Cipher encrypts with AES-256-GCM and Triple DES CBC, OpenSSL.KDF hashes passwords with PBKDF2 and scrypt, OpenSSL.CMAC gives the MACs of payment formats, OpenSSL.RSA encrypts with a public key, and OpenSSL.Random draws secure random bytes, hex and UUIDs.
- [Zlib](https://www.agentica-lang.com/agentica/library/text-and-data/zlib/index.md): The Zlib builtins and the Lazy steps, which compress bytes, files and streams with DEFLATE, zlib and gzip.
- [Base64 and hex](https://www.agentica-lang.com/agentica/library/text-and-data/base64/index.md): The Base64 and OpenSSL.Digest builtins, which write bytes as base64 or hex text and read them back.
- [URI (std)](https://www.agentica-lang.com/agentica/library/text-and-data/uri/index.md): The std/uri module, which percent-encodes and decodes URL components and query strings.
- [HTML (std)](https://www.agentica-lang.com/agentica/library/text-and-data/html/index.md): The std/html module, which escapes and unescapes HTML text.
- [Cookie (std)](https://www.agentica-lang.com/agentica/library/text-and-data/cookie/index.md): The std/cookie module, which reads a Cookie request header and writes a Set-Cookie response header.
- [EAG templates (std)](https://www.agentica-lang.com/agentica/library/text-and-data/eag/index.md): The `<<~EAG` template heredoc and the std/eag module that it needs.
- [MIME (std)](https://www.agentica-lang.com/agentica/library/text-and-data/mime/index.md): The std/mime module, which gives the media type of a file from its name and tells which types are text.
- [Regex (std)](https://www.agentica-lang.com/agentica/library/text-and-data/regex/index.md): The std/regex module, which searches, extracts, replaces and splits text with regular expressions in linear time.
- [UTC (std)](https://www.agentica-lang.com/agentica/library/text-and-data/utc/index.md): The std/utc module, which turns Unix milliseconds into the civil date and time in UTC and into RFC 3339 text.
- [Errors](https://www.agentica-lang.com/agentica/library/errors/index.md): Report failures as Result values and read them.
- [Result](https://www.agentica-lang.com/agentica/library/errors/result/index.md): Build and read Result values.
- [Error](https://www.agentica-lang.com/agentica/library/errors/error/index.md): The record a failed Result holds.
- [Concurrency](https://www.agentica-lang.com/agentica/library/concurrency/index.md): Run work at the same time with tasks, pass values between tasks with channels, share state in ATS tables, cache computed text, and keep state in actors.
- [Task](https://www.agentica-lang.com/agentica/library/concurrency/task/index.md): Start, await (with or without a timeout), pause, cancel, monitor and count lightweight tasks, map a block over a list with bounded concurrency, hand a handle to a task, and find their crashes.
- [Channel](https://www.agentica-lang.com/agentica/library/concurrency/channel/index.md): Send values from one task to another through a bounded queue.
- [ATS](https://www.agentica-lang.com/agentica/library/concurrency/ats/index.md): Share a counter or a cache between tasks in one mutable table.
- [Cache (std)](https://www.agentica-lang.com/agentica/library/concurrency/cache/index.md): The std/cache module, a small contract for caches of strings that tasks share, and an in-memory implementation of it built on ATS.
- [Actor (std)](https://www.agentica-lang.com/agentica/library/concurrency/actor/index.md): The std/actor module, a task that owns its state and handles the messages of one inbox, with cast, call, send and await, stop and a receive timeout.
- [Supervisor (std)](https://www.agentica-lang.com/agentica/library/concurrency/supervisor/index.md): The std/supervisor module, a task that starts actors and starts again one that crashes, one for one, within a restart limit.
- [IO and system](https://www.agentica-lang.com/agentica/library/io-and-system/index.md): Standard input and output, files, other programs, the network, and the system.
- [IO](https://www.agentica-lang.com/agentica/library/io-and-system/io/index.md): Print to standard output and error, and read standard input.
- [File, Dir and Path](https://www.agentica-lang.com/agentica/library/io-and-system/files/index.md): Read and write files, list and create directories, and build paths.
- [Process](https://www.agentica-lang.com/agentica/library/io-and-system/process/index.md): Start other programs, talk to them through their input and output, and wait for them.
- [TCP, TLS and HTTP](https://www.agentica-lang.com/agentica/library/io-and-system/network/index.md): DNS lookups, TCP and TLS sockets and the HTTP/1.1 client and server of std/http.
- [System, Time and Random](https://www.agentica-lang.com/agentica/library/io-and-system/system/index.md): Program arguments, environment variables, exit codes, clocks and random numbers.
- [Logger](https://www.agentica-lang.com/agentica/library/io-and-system/logger/index.md): Levels, named handlers and text or JSON lines on stderr with std/logger.
- [Native code](https://www.agentica-lang.com/agentica/library/io-and-system/native/index.md): Call C functions of a native library with an extern block.
- [Types and resources](https://www.agentica-lang.com/agentica/library/io-and-system/native/types/index.md): The C types of an extern block, variadic functions, reading memory that C returns, owned buffers and typed memory, resources that own a C pointer and arenas that close them, out parameters, calls through C function pointers, callbacks that C calls, and C structs passed by value or through a pointer.
- [SQLite](https://www.agentica-lang.com/agentica/library/io-and-system/native/sqlite/index.md): A real library, SQLite through an extern block, with safe functions that return Result.
- [Compute calls](https://www.agentica-lang.com/agentica/library/io-and-system/native/compute/index.md): Run a long C call on the compute pool, so the other tasks keep running.
- [Waiting on a descriptor](https://www.agentica-lang.com/agentica/library/io-and-system/native/waiting/index.md): Park a task until a C library's socket or descriptor can be read or written.
- [Wrapping a C library](https://www.agentica-lang.com/agentica/library/io-and-system/native/wrapping/index.md): Hide the C habits of a library (return codes, out pointers, varargs) behind a normal Agentica API, and ship it in a package.
- [Native modules](https://www.agentica-lang.com/agentica/library/io-and-system/native/modules/index.md): Call C code written for Agentica with Agentica types, a whole result in one call.
- [Option parser (std)](https://www.agentica-lang.com/agentica/library/io-and-system/option-parser/index.md): The std/option_parser module, which reads the command line of a program into typed values, with defaults, choices, errors and a help text.
- [Archive](https://www.agentica-lang.com/agentica/library/io-and-system/archive/index.md): The Archive module, which extracts named files from TAR and ZIP archives.
- [Testing](https://www.agentica-lang.com/agentica/library/testing/index.md): Unit tests and Gherkin feature files, both run by agentica test, and the profile.
- [Test](https://www.agentica-lang.com/agentica/library/testing/test/index.md): Unit tests in the style of ExUnit, with assertions that return a Result.
- [BDD](https://www.agentica-lang.com/agentica/library/testing/bdd/index.md): Test programs with Gherkin feature files and the agentica test command.
- [Profile](https://www.agentica-lang.com/agentica/library/testing/profile/index.md): Measure sections of a program in steps and time, count the steps of a task, and write input for flame graphs.
- [Algorithms](https://www.agentica-lang.com/agentica/library/algorithms/index.md): Short runnable recipes for sorting, breadth-first search, memoization and recursion.
- [Code analysis (std)](https://www.agentica-lang.com/agentica/library/analysis/index.md): The std/analysis module, which answers the questions of check, outline, type-at, symbol and refs from a program.
