Packages for Bend 2 that Base does not include. Each package has its own laws and its own hub version. Networking came first, so http and the packages under it are the most complete. ROADMAP.md is the backlog.
This project was called bend-net. The old hub names, bend-net-*, still resolve. They get no new versions.
Licensed under Apache-2.0. See LICENSE. Contributing. Security.
You need Bend 2.0.37 or newer and Bun 1.4.2. macOS or Linux, including WSL. Windows is not supported.
import Base
import [email protected]/bytes.bend as Bytes
def show(r: Bytes.Bytes & U32) -> IO(Unit):
(b, n) = r
IO.print(U32.show(n) ++ " " ++ Bytes.to_string(b))
def main() -> IO(Unit):
show(Bytes.length(Bytes.from_string("hi")))
bend fetches that import and checks it against the published hash. [email protected] is 0x185ae03c75e3e75be1171471f68b43cb. A name and its hash are the same package. A different version is a different type.
The kit is in alpha. Types, names, and entry points can change. There is no compatibility shim. A break raises the second number of VERSION, from 0.3.0.0 to 0.4.0.0, and the packages that import it move with it.
Each package has LAWS.bend and PROOF.bend. In that folder, bend PROOF.bend prints All terms check. when every law holds. Proofs do not cover .c and .js effects. Those effects run host code.
Import the version the callee imports when you pass it a value. The newest folder version is often a different type. Each package README names the pins in its entry file.
[email protected] imports its siblings by name: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], and [email protected]. Http.Body is [email protected].
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], and [email protected] import [email protected], and all but camber import [email protected]. A program that uses these versions together carries one copy of each C effect.
The effects load these libraries at run time. Set the override when the library is not on the default search path. On macOS, brew install openssl@3 covers TLS and crypto.
| Library | Used by | Override |
|---|---|---|
OpenSSL 3 libssl |
wire TLS, HTTPS in http and hairpin |
BEND_LIBSSL |
OpenSSL 3 libcrypto |
crypto, and signing or secure random through it |
BEND_LIBCRYPTO |
libsqlite3 |
sqlite |
BEND_LIBSQLITE |
libz |
zlib inflate and gzip, archive DEFLATE, http gzip |
BEND_LIBZ |
libzstd |
zlib and http zstd |
BEND_LIBZSTD |
libbrotlidec |
zlib and http brotli |
BEND_LIBBROTLIDEC |
files, process, dns, time, random, and tty call the OS through effects. They do not load one of those libraries. Proofs do not cover any of these effects.
A Socket, File, Cursor, or Client is used once. The call returns the handle beside the result. Pass that handle on.
Octet buffers are Bytes: four octets in each U32. Use String for short text, such as header fields, paths, URLs, and code points.
match takes a parameter, not a computed value. Match a Result in a helper.
A body over about 30 KB overflows bend file.bend. Build it with bend file.bend -o app.
Each package README has the import, one example, and the limits that change the call. bench/README.md records timings. CI does not run benches.
| Package | Import | What it does |
|---|---|---|
bytes |
[email protected]/bytes.bend |
Packed byte buffers, cursors, endian integers, search, hex, and base64. |
encoding |
[email protected]/encoding.bend |
UTF-8 between String and Bytes. |
unicode |
[email protected]/unicode.bend |
Unicode 17.0 category, NFC/NFD, case folding, and grapheme clusters. |
regex |
[email protected]/regex.bend |
Linear-time RE2 matching, with capture groups. |
parse |
[email protected]/parse.bend |
Parser combinators over text. parse/json.bend is a JSON grammar on them, not the json package. |
fmt |
[email protected]/fmt.bend |
A string builder, {} formatting, padding, and shortest F32 text. |
int |
[email protected]/int.bend |
U8, U16, U64, I32, and I64. U64 and I64 are slow. |
hash |
[email protected]/hash.bend |
FNV-1a, xxHash, SipHash-1-3, CRC-32, and Adler-32. Not cryptographic. |
| Package | Import | What it does |
|---|---|---|
f64 |
[email protected]/f64.bend |
IEEE 754 binary64 add, subtract, multiply, and divide. Soft-float on two U32 halves. |
bignum |
[email protected]/bigint.bend |
Exact integers, decimals, and rationals. Import decimal.bend or rational.bend for those types. |
json |
[email protected]/json.bend |
JSON values as RFC 8259, over Bytes. |
csv |
[email protected]/csv.bend |
RFC 4180 records over Bytes. |
cbor |
[email protected]/cbor.bend |
RFC 8949 encode and decode over Bytes. |
protobuf |
[email protected]/protobuf.bend |
Pure bounded proto3 messages over Bytes, with typed protoc code generation. |
tar |
[email protected]/tar.bend |
POSIX ustar and PAX archives over Bytes. |
archive |
[email protected]/archive.bend |
ZIP read: stored and DEFLATE entries, checked against CRC-32. |
zlib |
[email protected]/zlib.bend |
DEFLATE, gzip, and zlib, plus native gzip, zstd, and brotli. |
| Package | Import | What it does |
|---|---|---|
url |
[email protected]/url.bend |
RFC 3986 parse, resolve, and percent-encoding. |
netip |
[email protected]/netip.bend |
IPv4, IPv6, and CIDR values. No DNS. |
dns |
[email protected]/dns.bend |
DNS codec and host lookup. |
wire |
[email protected]/wire.bend |
TCP, UDP, and TLS sockets. |
http |
[email protected]/http.bend |
HTTP/1.1 and HTTP/2 client, and an HTTP/1.1 server. |
http2 |
[email protected]/http2.bend |
RFC 9113 frames and an HTTP/2 client. HPACK is hpack.bend. |
hairpin |
[email protected]/hairpin.bend |
An HTTP client: base URL, headers, pool, cookies, redirects, streams, and proven retries with a shared budget, deadlines, and a circuit breaker. |
retry |
[email protected]/retry.bend |
A pure retry policy: a shared attempt budget, a deadline, bounded backoff with jitter, and a circuit breaker, with proofs. |
websocket |
[email protected]/websocket.bend |
RFC 6455 client handshake and frames. |
multipart |
[email protected]/multipart.bend |
RFC 7578 form-data encode and decode. |
| Package | Import | What it does |
|---|---|---|
crypto |
[email protected]/crypto.bend |
Digests, HMAC, HKDF, AEAD, scrypt, RSA, and P-256 through OpenSSL 3. |
oauth2 |
[email protected]/oauth2.bend |
Client credentials, refresh, and authorization code with PKCE. |
authz |
[email protected]/authz.bend |
Pure authorization policies: deny-overrides, default deny, intersection, and fail-closed missing context. |
jwt |
[email protected]/jwt.bend |
HS256/384/512, RS256, and ES256, plus JWKS lookup. |
sigv4 |
[email protected]/sigv4.bend |
AWS Signature V4 and S3 over hairpin. |
webhooks |
[email protected]/webhooks.bend |
Standard Webhooks, Stripe, and GitHub signature checks. |
| Package | Import | What it does |
|---|---|---|
files |
[email protected]/files.bend |
POSIX paths, directories, and packed file IO. |
stream |
[email protected]/stream.bend |
Bounded copies between files and TCP/TLS sockets. |
process |
[email protected]/process.bend |
Commands with a child working directory and byte-exact stdin, stdout, and stderr. |
collections |
[email protected]/omap.bend |
Ordered maps, a hash map, a vector, a deque, a heap, and comparators. Import the file you need. |
time |
[email protected]/time.bend |
Clocks, dates, RFC 3339, HTTP-date, and TZif zones. |
random |
[email protected]/random.bend |
Seeded xoshiro128**. Not for cryptography. |
concurrency |
[email protected]/concurrency.bend |
Parallel map and reduce, a worker pool, select, and timeout. |
scheduler |
[email protected]/queue.bend |
Pure stable deadline queues, cancellation tokens, and bounded recurrence planning. |
resources |
[email protected]/resources.bend |
Bounded capacity pools with affine reservations: reserve, release, split, and combine. |
journal |
[email protected]/journal.bend |
An append-only journal: checksummed frames, fsync'd appends, and proven crash recovery of the committed prefix. |
runner |
[email protected]/runner.bend |
A durable job runner: a journaled queue, a bounded pool, retry with dead tickets, and a breaker per target, with proven replay and journal compaction. |
commands |
[email protected]/commands.bend |
Retry-safe commands: deduplication by id, recorded replies, and state, record, and outbox committed in one SQLite transaction, with proofs. |
cache |
[email protected]/cache.bend |
Cache validity: expiry, negative results, invalidation, and generation-safe fetch completion. |
notch |
[email protected]/notch.bend |
Leveled logfmt or JSON-lines logging. |
tty |
[email protected]/tty.bend |
Terminal size, color, and display width. |
router |
[email protected]/router.bend |
Prepared HTTP routes. Target parsing is target.bend. |
property |
[email protected]/property.bend |
Seeded generators, shrinking, and a property runner. |
lemmas |
[email protected]/lemmas.bend |
Proved laws that relate Word and U32 arithmetic to Nat, on top of bend-mathlib. |
| Package | Import | What it does |
|---|---|---|
sqlite |
[email protected]/sqlite.bend |
Prepared statements through libsqlite3. |
postgres |
[email protected]/postgres.bend |
Postgres protocol 3.0, SCRAM-SHA-256, and a pool. |
redis |
[email protected]/redis.bend |
Redis and Valkey over RESP3, with pipelining and a pool. |
llm |
[email protected]/llm.bend |
Anthropic Messages and OpenAI Chat Completions, including SSE. |
| Package | Import | What it does |
|---|---|---|
camber |
[email protected]/camber.bend |
Prepared HTTP applications, typed inputs, and bounded dependency owners. |
gateway |
[email protected]/gateway.bend |
A guarded read-through gateway: authorize, admit, serve from cache, and fetch on a miss, with proofs that every path gives its unit back. app.bend is the Camber app. |
For TOML 1.0, use Emerging-Patterns/eztoml (0xd79254973edee82bcf56616220876efe/main.bend, v0.5.0). For CLI arguments, use shake.
Each package is one folder. The folder name is the package name.
<package>/
<package>.bend entry file; its first comment line is the hub description
VERSION the hub version; CI publishes it on merge to main
LAWS.bend the claims
PROOF.bend a proof of each claim
check.bend native examples, when the package has them
effs/ .c and .js effects, when the package has them
bench/ timings, run by hand
http/smoke.bend does live fetches. llm/smoke.bend, postgres/smoke.bend, and redis/smoke.bend talk to a live service when their keys or server are set.
scripts/check.sh # every package
scripts/check.sh bytes http # some packages
scripts/packages.sh origin/maincheck.sh type-checks the entry file, then runs PROOF.bend and check.bend. CI checks each package a pull request changes. A change under .github/ or scripts/, and each push to main, checks every package. A package with effs/*.c, and webhooks, also runs scripts/native-check.sh. scripts/pins.sh fails a pull request whose changed packages import a sibling at a version other than its VERSION, or by hash; scripts/pins.allow lists the exceptions.
CI installs the Bend version pinned in scripts/install-bend.sh. To move to a new Bend, change VER and SHA in that script.
On each push to main, a package that passes its checks is published as bend-kit-<package>@<VERSION> unless that version is already on the hub. If the hub has that version with different files, the job fails and VERSION must rise. Pull requests run scripts/publish.sh --check and publish nothing.