{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "Slug",
  "home_page_url": "https://sluglang.org/",
  "feed_url": "https://sluglang.org/feed.json",
  "language": "en-US",
  "description": "a small opinionated programming language!",
  "icon": "https://sluglang.org/assets/no_shell.jpeg",
  
  "authors": [{
    "name": "Knuckles"
  }],
  "items": [
    {
      "id": "https://sluglang.org/libraries/watch",
      "url": "https://sluglang.org/libraries/watch",
      "title": "watch",
      "content_html": "<h2 id=\"watch\">watch</h2>\n\n<p>Slug Watch — file watcher and command runner</p>\n\n<p>Monitors directories for file changes and automatically reruns a\ncommand when changes are detected. Useful for development workflows\nwhere you want to automatically rebuild, test, or restart your\napplication when source files are modified.</p>\n\n<p>Usage:</p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>slug watch <span class=\"o\">[</span>options] &lt;cmd&gt; <span class=\"o\">[</span>args...]\n</code></pre></div></div>\n\n<p>Options:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">-h, --help</code>        show this screen</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">-v, --version</code>     show version</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--exts</code>            file extensions to monitor, may be passed multiple times (default: .slug .toml)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--roots</code>           root directories to monitor, may be passed multiple times (default: .)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--clear</code>           clear the terminal on restart (default: false)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--showTime</code>        show execution time of the command (default: true)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--pollMs</code>          how often to check for file changes in ms (default: 200)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--debounceMs</code>      debounce window for file change events in ms (default: 150)</li>\n</ul>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "watch",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/test",
      "url": "https://sluglang.org/libraries/test",
      "title": "test",
      "content_html": "<h2 id=\"test\">test</h2>\n\n<p>Slug Test — unit test runner</p>\n\n<p>Discovers and runs <code class=\"language-plaintext highlighter-rouge\">@test</code> and <code class=\"language-plaintext highlighter-rouge\">@testWith</code> tagged functions in the\ngiven source files, reporting passes, failures, and errors.</p>\n\n<p>Usage:</p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>slug <span class=\"nb\">test</span> <span class=\"o\">[</span>options] &lt;<span class=\"nb\">test </span>files...&gt;\n</code></pre></div></div>\n\n<p>Test examples:</p>\n<pre><code class=\"language-slug\">@test\nval simpleTest = fn() {\n  assert(1 + 1 == 2)\n}\n\n@testWith(\n  [1, 2, 3], 3,\n  [7, 9, 8], 9,\n  [4, 5, 3], 5\n)\nval max = fn(a, ...b) { ... }\n</code></pre>\n\n<p>Options:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">-h, --help</code>      show this screen</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">-v, --version</code>   show version</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--verbose</code>       show passing tests as well as failures</li>\n</ul>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "test",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-xkcd-colours",
      "url": "https://sluglang.org/libraries/slug-xkcd-colours",
      "title": "colours (slug.xkcd)",
      "content_html": "<h2 id=\"slugxkcdcolours\">slug.xkcd.colours</h2>\n\n<p>slug.xkcd.colours — xkcd colour survey colour index</p>\n\n<p>A map of ~950 colour names to their hex values, sourced from the\n<a href=\"https://blog.xkcd.com/2010/05/03/color-survey-results/\">xkcd colour survey</a>.</p>\n\n<p>Keys are camelCase symbol names (e.g. <code class=\"language-plaintext highlighter-rouge\">:electricLime</code>, <code class=\"language-plaintext highlighter-rouge\">:neonBlue</code>).\nValues are hex colour strings (e.g. <code class=\"language-plaintext highlighter-rouge\">\"#a8ff04\"</code>).</p>\n\n<p>Used by <code class=\"language-plaintext highlighter-rouge\">slug.term.colour</code> for <code class=\"language-plaintext highlighter-rouge\">xkcd</code> and <code class=\"language-plaintext highlighter-rouge\">bgXkcd</code> colour functions.</p>\n\n<pre><code class=\"language-slug\">val { xkcd } = import(\"slug.term.colour\")\n\n\"Hello!\" /&gt; xkcd(:electricLime) /&gt; println\n</code></pre>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"xkcdcolourindex\"><code class=\"language-plaintext highlighter-rouge\">XkcdColourIndex</code></h4>\n\n<pre><code class=\"language-slug\">map slug.xkcd.colours#XkcdColourIndex\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.xkcd.colours",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-web-views",
      "url": "https://sluglang.org/libraries/slug-web-views",
      "title": "views (slug.web)",
      "content_html": "<h2 id=\"slugwebviews\">slug.web.views</h2>\n\n<p>slug.web.views — Mustache template rendering for web responses</p>\n\n<p>Loads and renders Mustache templates from the filesystem, with support\nfor partials, layouts, HTMX fragment rendering, and template caching\nin production mode.</p>\n\n<h2 id=\"directory-structure\">Directory structure</h2>\n\n<p>Templates are loaded from a root directory (default <code class=\"language-plaintext highlighter-rouge\">\"views\"</code>):</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>views/\n  pages/\n    home.mustache          -- main page template\n    home/\n      content.mustache     -- page-specific partial\n  layouts/\n    main.mustache          -- shared layout\n  partials/\n    nav.mustache           -- shared partial\n    nav/\n      item.mustache        -- nested partial\n</code></pre></div></div>\n\n<h2 id=\"partial-name-resolution\">Partial name resolution</h2>\n\n<p>Inside a template, partials are referenced by logical name:</p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">layouts.main</code> → <code class=\"language-plaintext highlighter-rouge\">views/layouts/main.mustache</code></li>\n  <li><code class=\"language-plaintext highlighter-rouge\">partials.nav.item</code> → <code class=\"language-plaintext highlighter-rouge\">views/partials/nav/item.mustache</code></li>\n  <li><code class=\"language-plaintext highlighter-rouge\">content</code> (in <code class=\"language-plaintext highlighter-rouge\">pages/home</code>) → <code class=\"language-plaintext highlighter-rouge\">views/pages/home/content.mustache</code></li>\n</ul>\n\n<p>Dots in partial names are converted to path separators.\nIf a partial cannot be found in the view-specific directory, it falls\nback to <code class=\"language-plaintext highlighter-rouge\">views/partials/</code>.</p>\n\n<h2 id=\"htmx-fragment-rendering\">HTMX fragment rendering</h2>\n\n<p>When <code class=\"language-plaintext highlighter-rouge\">renderReply</code> receives a request with an <code class=\"language-plaintext highlighter-rouge\">HX-Request</code> header, it\nrenders only the fragment specified by <code class=\"language-plaintext highlighter-rouge\">Reply.fragment</code> (or the\n<code class=\"language-plaintext highlighter-rouge\">HX-Target</code> header if <code class=\"language-plaintext highlighter-rouge\">fragment</code> is nil) rather than the full page.</p>\n\n<h2 id=\"dev-vs-production-mode\">Dev vs production mode</h2>\n\n<p>In dev mode (<code class=\"language-plaintext highlighter-rouge\">cfg(\"dev\", true)</code>), templates are re-read from disk on\nevery request. In production mode, templates are cached after the first\nload. Toggle with <code class=\"language-plaintext highlighter-rouge\">cfg(\"dev\", false)</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#newroot\"><code class=\"language-plaintext highlighter-rouge\">new(root)</code></a></li>\n  <li><a href=\"#renderv-name-data\"><code class=\"language-plaintext highlighter-rouge\">render(v, name, data)</code></a></li>\n  <li><a href=\"#renderreplyvx-req-reply\"><code class=\"language-plaintext highlighter-rouge\">renderReply(vx, req, reply)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"newroot\"><code class=\"language-plaintext highlighter-rouge\">new(root)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.views#new(root:str = \"views\"):Views\n</code></pre>\n\n<p>creates a new <code class=\"language-plaintext highlighter-rouge\">Views</code> instance with the given template root directory.</p>\n\n<p>In dev mode templates are reloaded on every request. In production they\nare cached after first load. Dev mode is enabled by default unless\n<code class=\"language-plaintext highlighter-rouge\">cfg(\"dev\", false)</code> is set.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">root</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"views\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"renderv-name-data\"><code class=\"language-plaintext highlighter-rouge\">render(v, name, data)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.views#render(v, name, data = {}):str\n</code></pre>\n\n<p>renders a page template by name and returns the HTML string.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">name</code> is the page name without the <code class=\"language-plaintext highlighter-rouge\">.mustache</code> extension, resolved\nunder <code class=\"language-plaintext highlighter-rouge\">views/pages/</code>. Partials are loaded relative to <code class=\"language-plaintext highlighter-rouge\">views/pages/&lt;name&gt;/</code>\nwith fallback to <code class=\"language-plaintext highlighter-rouge\">views/layouts/</code> and <code class=\"language-plaintext highlighter-rouge\">views/partials/</code>.</p>\n\n<pre><code class=\"language-slug\">val views = new()\nviews /&gt; render(\"home\", { title: \"Hello\", user: currentUser })\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"renderreplyvx-req-reply\"><code class=\"language-plaintext highlighter-rouge\">renderReply(vx, req, reply)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.views#renderReply(vx, req, reply):Response\n</code></pre>\n\n<p>renders a <code class=\"language-plaintext highlighter-rouge\">Reply</code> into an HTML <code class=\"language-plaintext highlighter-rouge\">Response</code>, with HTMX fragment support.</p>\n\n<p>If the request has an <code class=\"language-plaintext highlighter-rouge\">HX-Request</code> header, renders only the fragment\nspecified by <code class=\"language-plaintext highlighter-rouge\">Reply.fragment</code> (or <code class=\"language-plaintext highlighter-rouge\">HX-Target</code> if <code class=\"language-plaintext highlighter-rouge\">fragment</code> is nil).\nOtherwise renders the full page view.</p>\n\n<p>The response status and extra headers from the <code class=\"language-plaintext highlighter-rouge\">Reply</code> are applied to\nthe final <code class=\"language-plaintext highlighter-rouge\">Response</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">vx</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">req</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">reply</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.web.views",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-web-server",
      "url": "https://sluglang.org/libraries/slug-web-server",
      "title": "server (slug.web)",
      "content_html": "<h2 id=\"slugwebserver\">slug.web.server</h2>\n\n<p>slug.web.server — HTTP/1.1 server</p>\n\n<p>A pure-Slug HTTP/1.1 server built on <code class=\"language-plaintext highlighter-rouge\">slug.io.tcp</code> and structured\nconcurrency. Each connection is handled in a spawned task within a\nnursery with a connection limit.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { serve }  = import(\"slug.web.server\")\nval { router, get, withLog } = import(\"slug.web.routes\")\nval { html } = import(\"slug.web.response\")\n\nval r = router()\n/&gt; get(\"/\", fn(req) { html(\"&lt;h1&gt;Hello&lt;/h1&gt;\") })\n\nserve(r /&gt; withLog /&gt; handle)\n</code></pre>\n\n<h2 id=\"configuration\">Configuration</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">addr</code> and <code class=\"language-plaintext highlighter-rouge\">port</code> default to <code class=\"language-plaintext highlighter-rouge\">cfg(\"address\", \"0.0.0.0\")</code> and\n<code class=\"language-plaintext highlighter-rouge\">cfg(\"port\", 8080)</code>. Override via config or pass directly:</p>\n\n<pre><code class=\"language-slug\">serve(app, \"127.0.0.1\", 3000)\n</code></pre>\n\n<h2 id=\"connection-handling\">Connection handling</h2>\n\n<ul>\n  <li>Up to 1000 concurrent connections (nursery limit)</li>\n  <li>Up to 100 requests per connection (keep-alive)</li>\n  <li>10 second idle timeout per connection</li>\n  <li>Request bodies up to 2MB are read into memory as strings</li>\n  <li>Larger bodies throw <code class=\"language-plaintext highlighter-rouge\">ServerError</code> — use <code class=\"language-plaintext highlighter-rouge\">withMaxBody</code> middleware</li>\n</ul>\n\n<h2 id=\"app-function-contract\">App function contract</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">app</code> must be a <code class=\"language-plaintext highlighter-rouge\">fn(request) -&gt; Response</code>. Use <code class=\"language-plaintext highlighter-rouge\">slug.web.routes#handle</code>\nto dispatch to a router, or write a plain function for simple cases.</p>\n\n<p>@effects(‘io net’)</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"serveapp-addr-port\"><code class=\"language-plaintext highlighter-rouge\">serve(app, addr, port)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.server#serve(app:fn, addr:str = cfg(address, 0.0.0.0), port:num = cfg(port, 8080)):any\n</code></pre>\n\n<p>starts an HTTP/1.1 server and blocks until it is shut down.</p>\n\n<p>Binds to <code class=\"language-plaintext highlighter-rouge\">addr:port</code>, accepts connections in a loop, and spawns a\ntask for each connection within a nursery limited to 1000 concurrent\nconnections. Each connection supports up to 100 keep-alive requests.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">app</code> receives a <code class=\"language-plaintext highlighter-rouge\">Request</code> and must return a <code class=\"language-plaintext highlighter-rouge\">Response</code>.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">app</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">addr</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">cfg(address, 0.0.0.0)</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">port</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">cfg(port, 8080)</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:ServerError}</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.web.server",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-web-routes",
      "url": "https://sluglang.org/libraries/slug-web-routes",
      "title": "routes (slug.web)",
      "content_html": "<h2 id=\"slugwebroutes\">slug.web.routes</h2>\n\n<p>slug.web.routes — HTTP router and middleware</p>\n\n<p>Pattern-based HTTP routing with composable middleware wrappers.\nRoutes are registered on a <code class=\"language-plaintext highlighter-rouge\">Router</code> and dispatched via <code class=\"language-plaintext highlighter-rouge\">handle</code>.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { router, get, post, handle, withLog, withRecover } = import(\"slug.web.routes\")\nval { html, jsonOk, notFound } = import(\"slug.web.response\")\n\nval r = router()\n/&gt; get(\"/\",           fn(req) { html(\"&lt;h1&gt;Hello&lt;/h1&gt;\") })\n/&gt; get(\"/users/:id\",  fn(req) { jsonOk({ id: req.params[\"id\"] }) })\n/&gt; post(\"/users\",     fn(req) { jsonOk(req.body) })\n\nval app = r /&gt; handle /&gt; withLog /&gt; withRecover\n</code></pre>\n\n<h2 id=\"route-patterns\">Route patterns</h2>\n\n<ul>\n  <li>Exact match: <code class=\"language-plaintext highlighter-rouge\">\"/users\"</code> matches only <code class=\"language-plaintext highlighter-rouge\">/users</code></li>\n  <li>Named param: <code class=\"language-plaintext highlighter-rouge\">\"/users/:id\"</code> captures the segment as <code class=\"language-plaintext highlighter-rouge\">req.params[\"id\"]</code></li>\n  <li>Wildcard mount: <code class=\"language-plaintext highlighter-rouge\">\"/static/*\"</code> matches any path starting with <code class=\"language-plaintext highlighter-rouge\">/static/</code>\nand captures the remainder as <code class=\"language-plaintext highlighter-rouge\">req.params[\"*\"]</code></li>\n</ul>\n\n<h2 id=\"middleware\">Middleware</h2>\n\n<p>Middleware wraps a handler function <code class=\"language-plaintext highlighter-rouge\">fn(req) -&gt; Response</code> and returns\na new handler with the same signature. Chain middleware with <code class=\"language-plaintext highlighter-rouge\">/&gt;</code>:</p>\n\n<pre><code class=\"language-slug\">val app = fn(req) { handle(req, r) }\n/&gt; withLog\n/&gt; withRecover\n/&gt; withMaxBody(512_000)\n/&gt; withRequestId\n</code></pre>\n\n<h2 id=\"subrouters\">Subrouters</h2>\n\n<p>Mount a child router at a prefix with <code class=\"language-plaintext highlighter-rouge\">mountRouter</code>. The child router\nsees paths relative to the mount point:</p>\n\n<pre><code class=\"language-slug\">val api = router()\n/&gt; get(\"/users\",    usersHandler)\n/&gt; get(\"/users/:id\", userHandler)\n\nval r = router()\n/&gt; mountRouter(\"/api\", api)\n</code></pre>\n\n<h2 id=\"static-files\">Static files</h2>\n\n<pre><code class=\"language-slug\">val r = router()\n/&gt; mount(\"/static\", static(\"public\"))\n</code></pre>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#getmap-key\"><code class=\"language-plaintext highlighter-rouge\">get(map, key)</code></a></li>\n  <li><a href=\"#handlerequest-r\"><code class=\"language-plaintext highlighter-rouge\">handle(request, r)</code></a></li>\n  <li><a href=\"#headr-pattern-handler\"><code class=\"language-plaintext highlighter-rouge\">head(r, pattern, handler)</code></a></li>\n  <li><a href=\"#isrouterx\"><code class=\"language-plaintext highlighter-rouge\">isRouter(x)</code></a></li>\n  <li><a href=\"#mountr-prefix-handler\"><code class=\"language-plaintext highlighter-rouge\">mount(r, prefix, handler)</code></a></li>\n  <li><a href=\"#mountrouterr-prefix-childrouter\"><code class=\"language-plaintext highlighter-rouge\">mountRouter(r, prefix, childRouter)</code></a></li>\n  <li><a href=\"#postr-pattern-handler\"><code class=\"language-plaintext highlighter-rouge\">post(r, pattern, handler)</code></a></li>\n  <li><a href=\"#router\"><code class=\"language-plaintext highlighter-rouge\">router()</code></a></li>\n  <li><a href=\"#staticdir-cachetimeseconds\"><code class=\"language-plaintext highlighter-rouge\">static(dir, cacheTimeSeconds)</code></a></li>\n  <li><a href=\"#subrouterrouter\"><code class=\"language-plaintext highlighter-rouge\">subrouter(router)</code></a></li>\n  <li><a href=\"#withheaderhandler-header-value\"><code class=\"language-plaintext highlighter-rouge\">withHeader(handler, header, value)</code></a></li>\n  <li><a href=\"#withloghandler\"><code class=\"language-plaintext highlighter-rouge\">withLog(handler)</code></a></li>\n  <li><a href=\"#withmaxbodyh-maxbytes\"><code class=\"language-plaintext highlighter-rouge\">withMaxBody(h, maxBytes)</code></a></li>\n  <li><a href=\"#withrecoverh\"><code class=\"language-plaintext highlighter-rouge\">withRecover(h)</code></a></li>\n  <li><a href=\"#withrequestidhandler-newrequestid\"><code class=\"language-plaintext highlighter-rouge\">withRequestId(handler, newRequestId)</code></a></li>\n  <li><a href=\"#withtimeouth-ms\"><code class=\"language-plaintext highlighter-rouge\">withTimeout(h, ms)</code></a></li>\n  <li><a href=\"#withtracecontexthandler-newtraceid-newspanid\"><code class=\"language-plaintext highlighter-rouge\">withTraceContext(handler, newTraceId, newSpanId)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"getmap-key\"><code class=\"language-plaintext highlighter-rouge\">get(map, key)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#get(map:map, key):any\nfn slug.web.routes#get(r, pattern:str, handler:fn):Router\n</code></pre>\n\n<p>registers a <code class=\"language-plaintext highlighter-rouge\">GET</code> route on <code class=\"language-plaintext highlighter-rouge\">r</code> and returns the updated router.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">get({}, :k)  // =&gt; nil\nget({:k: 1}, :k)  // =&gt; 1\n</code></pre>\n\n<hr />\n\n<h4 id=\"handlerequest-r\"><code class=\"language-plaintext highlighter-rouge\">handle(request, r)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#handle(request, r):Response\n</code></pre>\n\n<p>dispatches <code class=\"language-plaintext highlighter-rouge\">request</code> through the router’s routes and returns a <code class=\"language-plaintext highlighter-rouge\">Response</code>.</p>\n\n<p>Returns a 404 Not Found response if no route matches.\nRoute handlers receive the request with <code class=\"language-plaintext highlighter-rouge\">params</code> populated from URL pattern segments.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">request</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"headr-pattern-handler\"><code class=\"language-plaintext highlighter-rouge\">head(r, pattern, handler)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#head(r, pattern:str, handler:fn):Router\n</code></pre>\n\n<p>registers a <code class=\"language-plaintext highlighter-rouge\">HEAD</code> route on <code class=\"language-plaintext highlighter-rouge\">r</code> and returns the updated router.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isrouterx\"><code class=\"language-plaintext highlighter-rouge\">isRouter(x)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#isRouter(x):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">x</code> is a <code class=\"language-plaintext highlighter-rouge\">Router</code> struct instance.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">x</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"mountr-prefix-handler\"><code class=\"language-plaintext highlighter-rouge\">mount(r, prefix, handler)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#mount(r, prefix:str, handler:fn):Router\n</code></pre>\n\n<p>mounts <code class=\"language-plaintext highlighter-rouge\">handler</code> at <code class=\"language-plaintext highlighter-rouge\">prefix/*</code>, matching any method.</p>\n\n<p>The path remainder after the prefix is available as <code class=\"language-plaintext highlighter-rouge\">req.params[\"*\"]</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">prefix</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"mountrouterr-prefix-childrouter\"><code class=\"language-plaintext highlighter-rouge\">mountRouter(r, prefix, childRouter)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#mountRouter(r, prefix:str, childRouter):Router\n</code></pre>\n\n<p>mounts a child <code class=\"language-plaintext highlighter-rouge\">Router</code> at <code class=\"language-plaintext highlighter-rouge\">prefix</code>, handling paths relative to the prefix.</p>\n\n<p>Equivalent to <code class=\"language-plaintext highlighter-rouge\">mount(r, prefix, subrouter(childRouter))</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">prefix</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">childRouter</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"postr-pattern-handler\"><code class=\"language-plaintext highlighter-rouge\">post(r, pattern, handler)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#post(r, pattern:str, handler:fn):Router\n</code></pre>\n\n<p>registers a <code class=\"language-plaintext highlighter-rouge\">POST</code> route on <code class=\"language-plaintext highlighter-rouge\">r</code> and returns the updated router.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"router\"><code class=\"language-plaintext highlighter-rouge\">router()</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#router():Router\n</code></pre>\n\n<p>creates an empty <code class=\"language-plaintext highlighter-rouge\">Router</code>.</p>\n\n<hr />\n\n<h4 id=\"staticdir-cachetimeseconds\"><code class=\"language-plaintext highlighter-rouge\">static(dir, cacheTimeSeconds)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#static(dir, cacheTimeSeconds = 3600):fn\n</code></pre>\n\n<p>returns a handler that serves static files from <code class=\"language-plaintext highlighter-rouge\">dir</code>.</p>\n\n<p>Intended for use with <code class=\"language-plaintext highlighter-rouge\">mount</code>: <code class=\"language-plaintext highlighter-rouge\">mount(\"/static\", static(\"public\"))</code>.\nFiles are served with the appropriate <code class=\"language-plaintext highlighter-rouge\">Content-Type</code> based on extension\nand cached for <code class=\"language-plaintext highlighter-rouge\">cacheTimeSeconds</code> seconds (default 1 hour).</p>\n\n<p>Returns 404 for missing files, path traversal attempts (<code class=\"language-plaintext highlighter-rouge\">..</code>), and\nnon-GET/HEAD requests. <code class=\"language-plaintext highlighter-rouge\">HEAD</code> requests return headers without a body.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">dir</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">cacheTimeSeconds</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">3600</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"subrouterrouter\"><code class=\"language-plaintext highlighter-rouge\">subrouter(router)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#subrouter(router):fn\n</code></pre>\n\n<p>wraps a <code class=\"language-plaintext highlighter-rouge\">Router</code> as a handler function for use with <code class=\"language-plaintext highlighter-rouge\">mount</code>.</p>\n\n<p>Strips the mount prefix from the path and clears the <code class=\"language-plaintext highlighter-rouge\">\"*\"</code> param\nbefore dispatching to the inner router.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">router</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withheaderhandler-header-value\"><code class=\"language-plaintext highlighter-rouge\">withHeader(handler, header, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withHeader(handler:fn, header:str, value:str):fn\nfn slug.web.routes#withHeader(res, key:str, value:str):Response\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> to add a fixed response header to every response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">header</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withloghandler\"><code class=\"language-plaintext highlighter-rouge\">withLog(handler)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withLog(handler):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> with request/response logging to stdout.</p>\n\n<p>Logs timestamp, method, elapsed time (ms), status code, path, and\nany request ID / trace ID / span ID present on the request.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withmaxbodyh-maxbytes\"><code class=\"language-plaintext highlighter-rouge\">withMaxBody(h, maxBytes)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withMaxBody(h, maxBytes = 1048576):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> to enforce a maximum request body size.</p>\n\n<p>Checks <code class=\"language-plaintext highlighter-rouge\">Content-Length</code> for <code class=\"language-plaintext highlighter-rouge\">POST</code>, <code class=\"language-plaintext highlighter-rouge\">PUT</code>, and <code class=\"language-plaintext highlighter-rouge\">PATCH</code> requests.\nReturns 413 Payload Too Large if the declared size exceeds <code class=\"language-plaintext highlighter-rouge\">maxBytes</code>.\nDefault limit is 1MB (1_048_576 bytes).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">h</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">maxBytes</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1048576</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withrecoverh\"><code class=\"language-plaintext highlighter-rouge\">withRecover(h)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withRecover(h):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> so that any thrown error returns a 500 Server Error response.</p>\n\n<p>Use as the outermost middleware layer to prevent unhandled errors from\ncrashing the connection.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">h</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withrequestidhandler-newrequestid\"><code class=\"language-plaintext highlighter-rouge\">withRequestId(handler, newRequestId)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withRequestId(handler:fn, newRequestId:fn = fn() : str {randomHexString(32)}):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> to attach a request ID to every request and response.</p>\n\n<p>Uses the incoming <code class=\"language-plaintext highlighter-rouge\">X-Request-Id</code> header if present, otherwise generates\na new random hex ID. The ID is attached to <code class=\"language-plaintext highlighter-rouge\">req.requestId</code> and returned\nas the <code class=\"language-plaintext highlighter-rouge\">X-Request-Id</code> response header.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">newRequestId</code></td>\n      <td>fn</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">fn() : str {randomHexString(32)}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withtimeouth-ms\"><code class=\"language-plaintext highlighter-rouge\">withTimeout(h, ms)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withTimeout(h, ms):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> with a timeout of <code class=\"language-plaintext highlighter-rouge\">ms</code> milliseconds.</p>\n\n<p>If the handler does not return within the timeout, a <code class=\"language-plaintext highlighter-rouge\">TimeoutError</code> is thrown.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">h</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">ms</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withtracecontexthandler-newtraceid-newspanid\"><code class=\"language-plaintext highlighter-rouge\">withTraceContext(handler, newTraceId, newSpanId)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.routes#withTraceContext(handler, newTraceId:fn = fn() {randomHexString(32)}, newSpanId:fn = fn() {randomHexString(16)}):fn\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">handler</code> to propagate W3C <code class=\"language-plaintext highlighter-rouge\">traceparent</code> trace context.</p>\n\n<p>Extracts or generates a <code class=\"language-plaintext highlighter-rouge\">traceId</code> and creates a new <code class=\"language-plaintext highlighter-rouge\">spanId</code> for each\nrequest. Attaches both to <code class=\"language-plaintext highlighter-rouge\">req.traceId</code> and <code class=\"language-plaintext highlighter-rouge\">req.spanId</code>. Returns the\n<code class=\"language-plaintext highlighter-rouge\">traceparent</code> header on the response for downstream propagation.</p>\n\n<p>Format: <code class=\"language-plaintext highlighter-rouge\">00-&lt;traceId&gt;-&lt;spanId&gt;-01</code></p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handler</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">newTraceId</code></td>\n      <td>fn</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">fn() {randomHexString(32)}</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">newSpanId</code></td>\n      <td>fn</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">fn() {randomHexString(16)}</code></td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.web.routes",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-web-response",
      "url": "https://sluglang.org/libraries/slug-web-response",
      "title": "response (slug.web)",
      "content_html": "<h2 id=\"slugwebresponse\">slug.web.response</h2>\n\n<p>slug.web.response — HTTP response construction and formatting</p>\n\n<p>Provides the <code class=\"language-plaintext highlighter-rouge\">Response</code> and <code class=\"language-plaintext highlighter-rouge\">Reply</code> structs, constructor helpers for\nall common HTTP status codes, header management, cookie support,\nHTMX helpers, and HTTP wire-format serialisation.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { ok, html, jsonOk, notFound, redirect, withHeader } = import(\"slug.web.response\")\n\n// simple text response\nok(\"Hello, World!\")\n\n// HTML response\nhtml(\"&lt;h1&gt;Hello&lt;/h1&gt;\")\n\n// JSON response\njsonOk({ name: \"Alice\", age: 30 })\n\n// chaining modifiers\nok(\"done\")\n/&gt; withHeader(\"x-custom\", \"value\")\n/&gt; noCache\n</code></pre>\n\n<h2 id=\"response-struct\">Response struct</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">Response{ status, headers, body }</code> — header names are always lowercase.\nUse <code class=\"language-plaintext highlighter-rouge\">withHeader</code>, <code class=\"language-plaintext highlighter-rouge\">withHeaders</code>, <code class=\"language-plaintext highlighter-rouge\">addHeader</code>, and <code class=\"language-plaintext highlighter-rouge\">withoutHeader</code> to\nmanage headers rather than constructing the map directly.</p>\n\n<h2 id=\"reply-struct\">Reply struct</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">Reply</code> is a higher-level descriptor used with the views layer.\nIt carries a view name, optional HTMX fragment name, template data,\nstatus code, and extra headers. Pass a <code class=\"language-plaintext highlighter-rouge\">Reply</code> to <code class=\"language-plaintext highlighter-rouge\">renderReply</code> in\n<code class=\"language-plaintext highlighter-rouge\">slug.web.views</code> to produce a <code class=\"language-plaintext highlighter-rouge\">Response</code>.</p>\n\n<h2 id=\"cookie-options\">Cookie options</h2>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">cookie</code> function accepts an <code class=\"language-plaintext highlighter-rouge\">opts</code> map with optional keys:\n<code class=\"language-plaintext highlighter-rouge\">path</code>, <code class=\"language-plaintext highlighter-rouge\">domain</code>, <code class=\"language-plaintext highlighter-rouge\">maxAge</code>, <code class=\"language-plaintext highlighter-rouge\">expires</code>, <code class=\"language-plaintext highlighter-rouge\">secure</code> (bool), <code class=\"language-plaintext highlighter-rouge\">httpOnly</code> (bool),\n<code class=\"language-plaintext highlighter-rouge\">sameSite</code> (<code class=\"language-plaintext highlighter-rouge\">\"Lax\"</code> | <code class=\"language-plaintext highlighter-rouge\">\"Strict\"</code> | <code class=\"language-plaintext highlighter-rouge\">\"None\"</code>).</p>\n\n<h2 id=\"htmx\">HTMX</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">hxTrigger</code>, <code class=\"language-plaintext highlighter-rouge\">hxRedirect</code>, and <code class=\"language-plaintext highlighter-rouge\">hxRetarget</code> add the corresponding\nHTMX response headers (<code class=\"language-plaintext highlighter-rouge\">HX-Trigger</code>, <code class=\"language-plaintext highlighter-rouge\">HX-Redirect</code>, <code class=\"language-plaintext highlighter-rouge\">HX-Retarget</code>).</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#reply\">Reply</a></li>\n  <li><a href=\"#response\">Response</a></li>\n  <li><a href=\"#acceptedbody\"><code class=\"language-plaintext highlighter-rouge\">accepted(body)</code></a></li>\n  <li><a href=\"#addheaderres-key-value\"><code class=\"language-plaintext highlighter-rouge\">addHeader(res, key, value)</code></a></li>\n  <li><a href=\"#badrequestbody\"><code class=\"language-plaintext highlighter-rouge\">badRequest(body)</code></a></li>\n  <li><a href=\"#bodyres\"><code class=\"language-plaintext highlighter-rouge\">body(res)</code></a></li>\n  <li><a href=\"#cachesecondsres-seconds\"><code class=\"language-plaintext highlighter-rouge\">cacheSeconds(res, seconds)</code></a></li>\n  <li><a href=\"#clearcookieres-name-opts\"><code class=\"language-plaintext highlighter-rouge\">clearCookie(res, name, opts)</code></a></li>\n  <li><a href=\"#conflictbody\"><code class=\"language-plaintext highlighter-rouge\">conflict(body)</code></a></li>\n  <li><a href=\"#cookiename-value-opts\"><code class=\"language-plaintext highlighter-rouge\">cookie(name, value, opts)</code></a></li>\n  <li><a href=\"#createdbody\"><code class=\"language-plaintext highlighter-rouge\">created(body)</code></a></li>\n  <li><a href=\"#forbiddenbody\"><code class=\"language-plaintext highlighter-rouge\">forbidden(body)</code></a></li>\n  <li><a href=\"#formatheadres\"><code class=\"language-plaintext highlighter-rouge\">formatHead(res)</code></a></li>\n  <li><a href=\"#formatresponseres\"><code class=\"language-plaintext highlighter-rouge\">formatResponse(res)</code></a></li>\n  <li><a href=\"#hasheaderres-key\"><code class=\"language-plaintext highlighter-rouge\">hasHeader(res, key)</code></a></li>\n  <li><a href=\"#headersres\"><code class=\"language-plaintext highlighter-rouge\">headers(res)</code></a></li>\n  <li><a href=\"#htmlmarkup\"><code class=\"language-plaintext highlighter-rouge\">html(markup)</code></a></li>\n  <li><a href=\"#hxredirectres-location\"><code class=\"language-plaintext highlighter-rouge\">hxRedirect(res, location)</code></a></li>\n  <li><a href=\"#hxretargetres-selector\"><code class=\"language-plaintext highlighter-rouge\">hxRetarget(res, selector)</code></a></li>\n  <li><a href=\"#hxtriggerres-eventname\"><code class=\"language-plaintext highlighter-rouge\">hxTrigger(res, eventName)</code></a></li>\n  <li><a href=\"#isformattedresponsex\"><code class=\"language-plaintext highlighter-rouge\">isFormattedResponse(x)</code></a></li>\n  <li><a href=\"#isresponsex\"><code class=\"language-plaintext highlighter-rouge\">isResponse(x)</code></a></li>\n  <li><a href=\"#jsonokvalue\"><code class=\"language-plaintext highlighter-rouge\">jsonOk(value)</code></a></li>\n  <li><a href=\"#nocacheres\"><code class=\"language-plaintext highlighter-rouge\">noCache(res)</code></a></li>\n  <li><a href=\"#nocontent\"><code class=\"language-plaintext highlighter-rouge\">noContent()</code></a></li>\n  <li><a href=\"#notfoundbody\"><code class=\"language-plaintext highlighter-rouge\">notFound(body)</code></a></li>\n  <li><a href=\"#okbody\"><code class=\"language-plaintext highlighter-rouge\">ok(body)</code></a></li>\n  <li><a href=\"#payloadtoolargebody\"><code class=\"language-plaintext highlighter-rouge\">payloadTooLarge(body)</code></a></li>\n  <li><a href=\"#redirectlocation\"><code class=\"language-plaintext highlighter-rouge\">redirect(location)</code></a></li>\n  <li><a href=\"#redirectpermanentlocation\"><code class=\"language-plaintext highlighter-rouge\">redirectPermanent(location)</code></a></li>\n  <li><a href=\"#renderresponseres\"><code class=\"language-plaintext highlighter-rouge\">renderResponse(res)</code></a></li>\n  <li><a href=\"#responsestatus-body\"><code class=\"language-plaintext highlighter-rouge\">response(status, body)</code></a></li>\n  <li><a href=\"#servererrorbody\"><code class=\"language-plaintext highlighter-rouge\">serverError(body)</code></a></li>\n  <li><a href=\"#setcookieres-name-value-opts\"><code class=\"language-plaintext highlighter-rouge\">setCookie(res, name, value, opts)</code></a></li>\n  <li><a href=\"#statusres\"><code class=\"language-plaintext highlighter-rouge\">status(res)</code></a></li>\n  <li><a href=\"#texttxt\"><code class=\"language-plaintext highlighter-rouge\">text(txt)</code></a></li>\n  <li><a href=\"#unauthorizedbody\"><code class=\"language-plaintext highlighter-rouge\">unauthorized(body)</code></a></li>\n  <li><a href=\"#withbodyres-body\"><code class=\"language-plaintext highlighter-rouge\">withBody(res, body)</code></a></li>\n  <li><a href=\"#withconncloseres\"><code class=\"language-plaintext highlighter-rouge\">withConnClose(res)</code></a></li>\n  <li><a href=\"#withconnkeepaliveres\"><code class=\"language-plaintext highlighter-rouge\">withConnKeepAlive(res)</code></a></li>\n  <li><a href=\"#withcontenttyperes-ct\"><code class=\"language-plaintext highlighter-rouge\">withContentType(res, ct)</code></a></li>\n  <li><a href=\"#withheaderres-key-value\"><code class=\"language-plaintext highlighter-rouge\">withHeader(res, key, value)</code></a></li>\n  <li><a href=\"#withheadersres-headersmap\"><code class=\"language-plaintext highlighter-rouge\">withHeaders(res, headersMap)</code></a></li>\n  <li><a href=\"#withstatusres-status\"><code class=\"language-plaintext highlighter-rouge\">withStatus(res, status)</code></a></li>\n  <li><a href=\"#withoutheaderres-key\"><code class=\"language-plaintext highlighter-rouge\">withoutHeader(res, key)</code></a></li>\n</ul>\n\n<h3 id=\"structs\">Structs</h3>\n\n<h4 id=\"reply\"><code class=\"language-plaintext highlighter-rouge\">Reply</code></h4>\n<pre><code class=\"language-slug\">struct slug.web.response#Reply{view:str, fragment:str, data:map = {}, status:num = 200, headers:map = {}}\n</code></pre>\n\n<p>higher-level view descriptor for use with <code class=\"language-plaintext highlighter-rouge\">slug.web.views#renderReply</code>.</p>\n\n<p>Set <code class=\"language-plaintext highlighter-rouge\">fragment</code> to render an HTMX partial instead of the full page.\nExtra <code class=\"language-plaintext highlighter-rouge\">headers</code> are merged into the final response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">view</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">fragment</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">status</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">200</code></td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n      <td> </td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"response\"><code class=\"language-plaintext highlighter-rouge\">Response</code></h4>\n<pre><code class=\"language-slug\">struct slug.web.response#Response{status:num, headers:map, body}\n</code></pre>\n\n<p>raw HTTP response value. Construct via the helper functions, not directly.</p>\n\n<p>Header names are always normalised to lowercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">status</code></td>\n      <td>num</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td> </td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n  </tbody>\n</table>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"acceptedbody\"><code class=\"language-plaintext highlighter-rouge\">accepted(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#accepted(body:str):Response\n</code></pre>\n\n<p>202 Accepted response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"addheaderres-key-value\"><code class=\"language-plaintext highlighter-rouge\">addHeader(res, key, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#addHeader(res, key:str, value:str):Response\n</code></pre>\n\n<p>adds a header value without replacing existing values for the same key.</p>\n\n<p>Upgrades a single string value to a list when a second value is added.\nThis is the correct way to set multiple <code class=\"language-plaintext highlighter-rouge\">Set-Cookie</code> headers.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"badrequestbody\"><code class=\"language-plaintext highlighter-rouge\">badRequest(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#badRequest(body:str):Response\n</code></pre>\n\n<p>400 Bad Request response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bodyres\"><code class=\"language-plaintext highlighter-rouge\">body(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#body(res):any\n</code></pre>\n\n<p>returns the body of a response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cachesecondsres-seconds\"><code class=\"language-plaintext highlighter-rouge\">cacheSeconds(res, seconds)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#cacheSeconds(res, seconds:num):Response\n</code></pre>\n\n<p>sets <code class=\"language-plaintext highlighter-rouge\">Cache-Control: public, max-age=&lt;seconds&gt;</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">seconds</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"clearcookieres-name-opts\"><code class=\"language-plaintext highlighter-rouge\">clearCookie(res, name, opts)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#clearCookie(res, name:str, opts:map):Response\n</code></pre>\n\n<p>expires a cookie immediately by setting <code class=\"language-plaintext highlighter-rouge\">Max-Age=0</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">opts</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"conflictbody\"><code class=\"language-plaintext highlighter-rouge\">conflict(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#conflict(body:str):Response\n</code></pre>\n\n<p>409 Conflict response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cookiename-value-opts\"><code class=\"language-plaintext highlighter-rouge\">cookie(name, value, opts)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#cookie(name:str, value:str, opts:map):str\n</code></pre>\n\n<p>builds a <code class=\"language-plaintext highlighter-rouge\">Set-Cookie</code> header value string.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">opts</code> may contain: <code class=\"language-plaintext highlighter-rouge\">path</code>, <code class=\"language-plaintext highlighter-rouge\">domain</code>, <code class=\"language-plaintext highlighter-rouge\">maxAge</code>, <code class=\"language-plaintext highlighter-rouge\">expires</code>,\n<code class=\"language-plaintext highlighter-rouge\">secure</code> (bool), <code class=\"language-plaintext highlighter-rouge\">httpOnly</code> (bool), <code class=\"language-plaintext highlighter-rouge\">sameSite</code> (<code class=\"language-plaintext highlighter-rouge\">\"Lax\"|\"Strict\"|\"None\"</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">opts</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"createdbody\"><code class=\"language-plaintext highlighter-rouge\">created(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#created(body:str):Response\n</code></pre>\n\n<p>201 Created response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"forbiddenbody\"><code class=\"language-plaintext highlighter-rouge\">forbidden(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#forbidden(body:str):Response\n</code></pre>\n\n<p>403 Forbidden response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"formatheadres\"><code class=\"language-plaintext highlighter-rouge\">formatHead(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#formatHead(res):str\n</code></pre>\n\n<p>formats the response head (status line + headers) as an HTTP/1.1 string.</p>\n\n<p>Automatically adds <code class=\"language-plaintext highlighter-rouge\">Content-Length</code> if not already present.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"formatresponseres\"><code class=\"language-plaintext highlighter-rouge\">formatResponse(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#formatResponse(res):FormattedResponse\n</code></pre>\n\n<p>formats a response into a <code class=\"language-plaintext highlighter-rouge\">FormattedResponse{ head, body }</code>.</p>\n\n<p>Automatically adds <code class=\"language-plaintext highlighter-rouge\">Content-Length</code> if not already present.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hasheaderres-key\"><code class=\"language-plaintext highlighter-rouge\">hasHeader(res, key)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#hasHeader(res, key):bool\n</code></pre>\n\n<p>returns true if the response has a header with the given key.</p>\n\n<p>Key comparison is case-insensitive.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"headersres\"><code class=\"language-plaintext highlighter-rouge\">headers(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#headers(res):map\n</code></pre>\n\n<p>returns the headers map of a response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"htmlmarkup\"><code class=\"language-plaintext highlighter-rouge\">html(markup)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#html(markup:str):Response\n</code></pre>\n\n<p>200 OK response with <code class=\"language-plaintext highlighter-rouge\">Content-Type: text/html; charset=utf-8</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">markup</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hxredirectres-location\"><code class=\"language-plaintext highlighter-rouge\">hxRedirect(res, location)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#hxRedirect(res, location:str):Response\n</code></pre>\n\n<p>sets the <code class=\"language-plaintext highlighter-rouge\">HX-Redirect</code> response header for a client-side redirect.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">location</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hxretargetres-selector\"><code class=\"language-plaintext highlighter-rouge\">hxRetarget(res, selector)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#hxRetarget(res, selector:str):Response\n</code></pre>\n\n<p>sets the <code class=\"language-plaintext highlighter-rouge\">HX-Retarget</code> response header to override the HTMX swap target.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">selector</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hxtriggerres-eventname\"><code class=\"language-plaintext highlighter-rouge\">hxTrigger(res, eventName)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#hxTrigger(res, eventName:str):Response\n</code></pre>\n\n<p>sets the <code class=\"language-plaintext highlighter-rouge\">HX-Trigger</code> response header to trigger a client-side event.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">eventName</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isformattedresponsex\"><code class=\"language-plaintext highlighter-rouge\">isFormattedResponse(x)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#isFormattedResponse(x):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">x</code> is a <code class=\"language-plaintext highlighter-rouge\">FormattedResponse</code> struct instance.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">x</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isresponsex\"><code class=\"language-plaintext highlighter-rouge\">isResponse(x)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#isResponse(x):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">x</code> is a <code class=\"language-plaintext highlighter-rouge\">Response</code> struct instance.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">x</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"jsonokvalue\"><code class=\"language-plaintext highlighter-rouge\">jsonOk(value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#jsonOk(value):Response\n</code></pre>\n\n<p>200 OK response with JSON-encoded <code class=\"language-plaintext highlighter-rouge\">value</code> and <code class=\"language-plaintext highlighter-rouge\">Content-Type: application/json</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"nocacheres\"><code class=\"language-plaintext highlighter-rouge\">noCache(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#noCache(res):Response\n</code></pre>\n\n<p>sets headers to prevent all caching.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"nocontent\"><code class=\"language-plaintext highlighter-rouge\">noContent()</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#noContent():Response\n</code></pre>\n\n<p>204 No Content response.</p>\n\n<hr />\n\n<h4 id=\"notfoundbody\"><code class=\"language-plaintext highlighter-rouge\">notFound(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#notFound(body:str = \"404 Not Found\"):Response\n</code></pre>\n\n<p>404 Not Found response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"404 Not Found\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"okbody\"><code class=\"language-plaintext highlighter-rouge\">ok(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#ok(body:str):Response\n</code></pre>\n\n<p>200 OK response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"payloadtoolargebody\"><code class=\"language-plaintext highlighter-rouge\">payloadTooLarge(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#payloadTooLarge(body:str = \"413 Payload Too Large\"):Response\n</code></pre>\n\n<p>413 Payload Too Large response. Also sets <code class=\"language-plaintext highlighter-rouge\">Connection: close</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"413 Payload Too Large\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"redirectlocation\"><code class=\"language-plaintext highlighter-rouge\">redirect(location)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#redirect(location:str):Response\n</code></pre>\n\n<p>302 Found redirect to <code class=\"language-plaintext highlighter-rouge\">location</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">location</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"redirectpermanentlocation\"><code class=\"language-plaintext highlighter-rouge\">redirectPermanent(location)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#redirectPermanent(location:str):Response\n</code></pre>\n\n<p>301 Moved Permanently redirect to <code class=\"language-plaintext highlighter-rouge\">location</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">location</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"renderresponseres\"><code class=\"language-plaintext highlighter-rouge\">renderResponse(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#renderResponse(res):str\n</code></pre>\n\n<p>renders a response to a complete HTTP/1.1 wire-format string (head + body).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"responsestatus-body\"><code class=\"language-plaintext highlighter-rouge\">response(status, body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#response(status:num, body:str):Response\n</code></pre>\n\n<p>constructs a <code class=\"language-plaintext highlighter-rouge\">Response</code> with the given status and body.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">status</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"servererrorbody\"><code class=\"language-plaintext highlighter-rouge\">serverError(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#serverError(body:str = \"500 Server Error\"):Response\n</code></pre>\n\n<p>500 Internal Server Error response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"500 Server Error\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"setcookieres-name-value-opts\"><code class=\"language-plaintext highlighter-rouge\">setCookie(res, name, value, opts)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#setCookie(res, name:str, value:str, opts:map):Response\n</code></pre>\n\n<p>adds a <code class=\"language-plaintext highlighter-rouge\">Set-Cookie</code> header to <code class=\"language-plaintext highlighter-rouge\">res</code> using <code class=\"language-plaintext highlighter-rouge\">cookie(name, value, opts)</code>.</p>\n\n<p>Multiple cookies can be set by calling <code class=\"language-plaintext highlighter-rouge\">setCookie</code> repeatedly —\n<code class=\"language-plaintext highlighter-rouge\">addHeader</code> semantics ensure values are not clobbered.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">opts</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"statusres\"><code class=\"language-plaintext highlighter-rouge\">status(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#status(res):num\n</code></pre>\n\n<p>returns the status code of a response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"texttxt\"><code class=\"language-plaintext highlighter-rouge\">text(txt)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#text(txt:str):Response\n</code></pre>\n\n<p>200 OK response with <code class=\"language-plaintext highlighter-rouge\">Content-Type: text/plain; charset=utf-8</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">txt</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"unauthorizedbody\"><code class=\"language-plaintext highlighter-rouge\">unauthorized(body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#unauthorized(body:str):Response\n</code></pre>\n\n<p>401 Unauthorized response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withbodyres-body\"><code class=\"language-plaintext highlighter-rouge\">withBody(res, body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withBody(res, body:str):Response\n</code></pre>\n\n<p>returns a new response with <code class=\"language-plaintext highlighter-rouge\">body</code> replaced.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withconncloseres\"><code class=\"language-plaintext highlighter-rouge\">withConnClose(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withConnClose(res):Response\n</code></pre>\n\n<p>sets <code class=\"language-plaintext highlighter-rouge\">Connection: close</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withconnkeepaliveres\"><code class=\"language-plaintext highlighter-rouge\">withConnKeepAlive(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withConnKeepAlive(res):Response\n</code></pre>\n\n<p>sets <code class=\"language-plaintext highlighter-rouge\">Connection: keep-alive</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withcontenttyperes-ct\"><code class=\"language-plaintext highlighter-rouge\">withContentType(res, ct)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withContentType(res, ct:str):Response\n</code></pre>\n\n<p>sets the <code class=\"language-plaintext highlighter-rouge\">content-type</code> header.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">ct</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withheaderres-key-value\"><code class=\"language-plaintext highlighter-rouge\">withHeader(res, key, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withHeader(res, key:str, value:str):Response\n</code></pre>\n\n<p>returns a new response with <code class=\"language-plaintext highlighter-rouge\">key</code> set to <code class=\"language-plaintext highlighter-rouge\">value</code>, replacing any existing value.</p>\n\n<p>Header keys are normalised to lowercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withheadersres-headersmap\"><code class=\"language-plaintext highlighter-rouge\">withHeaders(res, headersMap)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withHeaders(res, headersMap:map):Response\n</code></pre>\n\n<p>returns a new response with all headers from <code class=\"language-plaintext highlighter-rouge\">headersMap</code> applied.</p>\n\n<p>Each key is normalised to lowercase. Existing headers with the same\nkey are replaced.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headersMap</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withstatusres-status\"><code class=\"language-plaintext highlighter-rouge\">withStatus(res, status)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withStatus(res, status:num):Response\n</code></pre>\n\n<p>returns a new response with <code class=\"language-plaintext highlighter-rouge\">status</code> replaced.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">status</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withoutheaderres-key\"><code class=\"language-plaintext highlighter-rouge\">withoutHeader(res, key)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.response#withoutHeader(res, key:str):Response\n</code></pre>\n\n<p>returns a new response with <code class=\"language-plaintext highlighter-rouge\">key</code> removed from headers.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.web.response",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-web-request",
      "url": "https://sluglang.org/libraries/slug-web-request",
      "title": "request (slug.web)",
      "content_html": "<h2 id=\"slugwebrequest\">slug.web.request</h2>\n\n<p>slug.web.request — HTTP request representation and parsing</p>\n\n<p>Defines the <code class=\"language-plaintext highlighter-rouge\">Request</code> struct and provides parsing, construction, and\naccessor functions for working with incoming HTTP requests.</p>\n\n<h2 id=\"request-struct-fields\">Request struct fields</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>HTTP method (<code class=\"language-plaintext highlighter-rouge\">\"GET\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"POST\"</code>, etc.)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>URL path (without query string)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">version</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>HTTP version (<code class=\"language-plaintext highlighter-rouge\">\"HTTP/1.1\"</code>)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Lowercase header names → values</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>any</td>\n      <td>Request body (string for small bodies)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">query</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Parsed query string parameters</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">form</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Parsed <code class=\"language-plaintext highlighter-rouge\">application/x-www-form-urlencoded</code> body</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">files</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>Uploaded files (multipart, when supported)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>URL path parameters (populated by the router)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">requestId</code></td>\n      <td>any</td>\n      <td>Request ID (set by <code class=\"language-plaintext highlighter-rouge\">withRequestId</code> middleware)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">traceId</code></td>\n      <td>any</td>\n      <td>Trace ID (set by <code class=\"language-plaintext highlighter-rouge\">withTraceContext</code> middleware)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">spanId</code></td>\n      <td>any</td>\n      <td>Span ID (set by <code class=\"language-plaintext highlighter-rouge\">withTraceContext</code> middleware)</td>\n    </tr>\n  </tbody>\n</table>\n\n<p>Header names are always normalised to lowercase. Access headers as\n<code class=\"language-plaintext highlighter-rouge\">req.headers[\"content-type\"]</code> not <code class=\"language-plaintext highlighter-rouge\">req.headers[\"Content-Type\"]</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#request\">Request</a></li>\n  <li><a href=\"#isrequestx\"><code class=\"language-plaintext highlighter-rouge\">isRequest(x)</code></a></li>\n  <li><a href=\"#parserequestheadersbuf\"><code class=\"language-plaintext highlighter-rouge\">parseRequestHeaders(buf)</code></a></li>\n  <li><a href=\"#requestmethod-path-version-headers-body\"><code class=\"language-plaintext highlighter-rouge\">request(method, path, version, headers, body)</code></a></li>\n  <li><a href=\"#shouldkeepalivereq\"><code class=\"language-plaintext highlighter-rouge\">shouldKeepAlive(req)</code></a></li>\n  <li><a href=\"#withbodyreq-body\"><code class=\"language-plaintext highlighter-rouge\">withBody(req, body)</code></a></li>\n  <li><a href=\"#withparamsrequest-params\"><code class=\"language-plaintext highlighter-rouge\">withParams(request, params)</code></a></li>\n  <li><a href=\"#withpathreq-path\"><code class=\"language-plaintext highlighter-rouge\">withPath(req, path)</code></a></li>\n  <li><a href=\"#withqueryreq-query\"><code class=\"language-plaintext highlighter-rouge\">withQuery(req, query)</code></a></li>\n  <li><a href=\"#withoutparamrequest-param\"><code class=\"language-plaintext highlighter-rouge\">withoutParam(request, param)</code></a></li>\n</ul>\n\n<h3 id=\"structs\">Structs</h3>\n\n<h4 id=\"request\"><code class=\"language-plaintext highlighter-rouge\">Request</code></h4>\n<pre><code class=\"language-slug\">struct slug.web.request#Request{method:str, path:str, version:str, headers:map, body, query:map, form:map, files:list, params:map, requestId, traceId, spanId}\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">version</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td> </td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">query</code></td>\n      <td>map</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">form</code></td>\n      <td>map</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">files</code></td>\n      <td>list</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td>map</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">requestId</code></td>\n      <td> </td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">traceId</code></td>\n      <td> </td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">spanId</code></td>\n      <td> </td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n  </tbody>\n</table>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"isrequestx\"><code class=\"language-plaintext highlighter-rouge\">isRequest(x)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#isRequest(x):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">x</code> is a <code class=\"language-plaintext highlighter-rouge\">Request</code> struct instance.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">x</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"parserequestheadersbuf\"><code class=\"language-plaintext highlighter-rouge\">parseRequestHeaders(buf)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#parseRequestHeaders(buf):[Request, str]\n</code></pre>\n\n<p>parses the headers section of a raw HTTP request buffer.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">[Request, remainingBuffer]</code> where <code class=\"language-plaintext highlighter-rouge\">remainingBuffer</code> is the\nbytes after the <code class=\"language-plaintext highlighter-rouge\">\\r\\n\\r\\n</code> header/body separator. The body is not\nread — the caller (the server) is responsible for reading it based\non <code class=\"language-plaintext highlighter-rouge\">content-length</code> and then calling <code class=\"language-plaintext highlighter-rouge\">withBody</code>.</p>\n\n<p>Header names are normalised to lowercase. Query string parameters\nare parsed and attached to <code class=\"language-plaintext highlighter-rouge\">req.query</code>.</p>\n\n<p>Throws <code class=\"language-plaintext highlighter-rouge\">RequestError</code> if headers are incomplete or the request line is malformed.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">buf</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:RequestError}</code></p>\n\n<hr />\n\n<h4 id=\"requestmethod-path-version-headers-body\"><code class=\"language-plaintext highlighter-rouge\">request(method, path, version, headers, body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#request(method, path, version = \"HTTP/1.1\", headers = {}, body = \"\"):Request\n</code></pre>\n\n<p>constructs a new <code class=\"language-plaintext highlighter-rouge\">Request</code> with the given method, path, and optional fields.</p>\n\n<p>All other fields default to empty/nil. This is the canonical way to\ncreate a request for testing or manual construction.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">version</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"HTTP/1.1\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"shouldkeepalivereq\"><code class=\"language-plaintext highlighter-rouge\">shouldKeepAlive(req)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#shouldKeepAlive(req):bool\n</code></pre>\n\n<p>returns true if the connection should be kept alive after this request.</p>\n\n<p>For HTTP/1.0, keep-alive requires an explicit <code class=\"language-plaintext highlighter-rouge\">Connection: keep-alive</code> header.\nFor HTTP/1.1, keep-alive is the default unless <code class=\"language-plaintext highlighter-rouge\">Connection: close</code> is set.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">req</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withbodyreq-body\"><code class=\"language-plaintext highlighter-rouge\">withBody(req, body)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#withBody(req, body):Request\n</code></pre>\n\n<p>attaches a body to a request and parses form data if applicable.</p>\n\n<p>If the <code class=\"language-plaintext highlighter-rouge\">content-type</code> is <code class=\"language-plaintext highlighter-rouge\">application/x-www-form-urlencoded</code>, the body\nis parsed and the result is available as <code class=\"language-plaintext highlighter-rouge\">req.form</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">req</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withparamsrequest-params\"><code class=\"language-plaintext highlighter-rouge\">withParams(request, params)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#withParams(request, params:map):Request\n</code></pre>\n\n<p>returns a new request with path params map replaced.</p>\n\n<p>Used by the router to inject matched URL parameters (e.g. <code class=\"language-plaintext highlighter-rouge\">:id</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">request</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withpathreq-path\"><code class=\"language-plaintext highlighter-rouge\">withPath(req, path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#withPath(req, path):Request\n</code></pre>\n\n<p>returns a new request with <code class=\"language-plaintext highlighter-rouge\">path</code> replaced.</p>\n\n<p>Used by the router to strip path prefixes for subrouters.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">req</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withqueryreq-query\"><code class=\"language-plaintext highlighter-rouge\">withQuery(req, query)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#withQuery(req, query):Request\n</code></pre>\n\n<p>returns a new request with <code class=\"language-plaintext highlighter-rouge\">query</code> replaced.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">req</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">query</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"withoutparamrequest-param\"><code class=\"language-plaintext highlighter-rouge\">withoutParam(request, param)</code></h4>\n<pre><code class=\"language-slug\">fn slug.web.request#withoutParam(request, param):Request\n</code></pre>\n\n<p>returns a new request with a single param key removed from <code class=\"language-plaintext highlighter-rouge\">params</code>.</p>\n\n<p>Used by subrouters to remove the <code class=\"language-plaintext highlighter-rouge\">\"*\"</code> wildcard param after consuming it.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">request</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">param</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.web.request",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-time",
      "url": "https://sluglang.org/libraries/slug-time",
      "title": "time (slug)",
      "content_html": "<h2 id=\"slugtime\">slug.time</h2>\n\n<p>slug.time — time and duration utilities</p>\n\n<p>Wall-clock access, sleep, formatting, and duration conversion helpers.\nAll time values are in milliseconds unless the function name specifies\notherwise (e.g. <code class=\"language-plaintext highlighter-rouge\">clockNanos</code>).</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#clock\"><code class=\"language-plaintext highlighter-rouge\">clock()</code></a></li>\n  <li><a href=\"#clocknanos\"><code class=\"language-plaintext highlighter-rouge\">clockNanos()</code></a></li>\n  <li><a href=\"#deltaf\"><code class=\"language-plaintext highlighter-rouge\">delta(f)</code></a></li>\n  <li><a href=\"#fmtclockmillis-fmt\"><code class=\"language-plaintext highlighter-rouge\">fmtClock(millis, fmt)</code></a></li>\n  <li><a href=\"#minstomillismins\"><code class=\"language-plaintext highlighter-rouge\">minsToMillis(mins)</code></a></li>\n  <li><a href=\"#secstomillissecs\"><code class=\"language-plaintext highlighter-rouge\">secsToMillis(secs)</code></a></li>\n  <li><a href=\"#sleepmillis\"><code class=\"language-plaintext highlighter-rouge\">sleep(millis)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"clock\"><code class=\"language-plaintext highlighter-rouge\">clock()</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#clock():num\n</code></pre>\n\n<p>returns the current wall-clock time in milliseconds since the Unix epoch.</p>\n\n<p>@effects(‘time’)</p>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n\n<hr />\n\n<h4 id=\"clocknanos\"><code class=\"language-plaintext highlighter-rouge\">clockNanos()</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#clockNanos():num\n</code></pre>\n\n<p>returns the current time as a nanosecond counter.</p>\n\n<p>Intended for high-resolution timing. The epoch is implementation-defined\n— use differences between two calls rather than absolute values.</p>\n\n<p>@effects(‘time’)</p>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n\n<hr />\n\n<h4 id=\"deltaf\"><code class=\"language-plaintext highlighter-rouge\">delta(f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#delta(f:fn&lt;num&gt;):fn\n</code></pre>\n\n<p>returns a function that measures elapsed time since it was created.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">f</code> should be a time source function (e.g. <code class=\"language-plaintext highlighter-rouge\">clock</code> or <code class=\"language-plaintext highlighter-rouge\">clockNanos</code>).\nEach call to the returned function returns the elapsed time since <code class=\"language-plaintext highlighter-rouge\">delta</code>\nwas first called.</p>\n\n<pre><code class=\"language-slug\">val { delta, clock } = import(\"slug.time\")\n\nval elapsed = delta(clock)\n// ... do some work ...\nprintln(elapsed())  // =&gt; milliseconds elapsed\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn<num></num></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"fmtclockmillis-fmt\"><code class=\"language-plaintext highlighter-rouge\">fmtClock(millis, fmt)</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#fmtClock(millis:num, fmt:str):str\n</code></pre>\n\n<p>formats a millisecond timestamp using a format string.</p>\n\n<p>Format follows standard Go time layout conventions.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">millis</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">fmt</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"minstomillismins\"><code class=\"language-plaintext highlighter-rouge\">minsToMillis(mins)</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#minsToMillis(mins:num):num\n</code></pre>\n\n<p>converts minutes to milliseconds.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">mins</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">minsToMillis(1)  // =&gt; 60000\n</code></pre>\n\n<hr />\n\n<h4 id=\"secstomillissecs\"><code class=\"language-plaintext highlighter-rouge\">secsToMillis(secs)</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#secsToMillis(secs:num):num\n</code></pre>\n\n<p>converts seconds to milliseconds.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">secs</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">secsToMillis(1)  // =&gt; 1000\n</code></pre>\n\n<hr />\n\n<h4 id=\"sleepmillis\"><code class=\"language-plaintext highlighter-rouge\">sleep(millis)</code></h4>\n<pre><code class=\"language-slug\">fn slug.time#sleep(millis:num):nil\n</code></pre>\n\n<p>suspends execution for <code class=\"language-plaintext highlighter-rouge\">millis</code> milliseconds.</p>\n\n<p>@effects(‘time’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">millis</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.time",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-thirdparty-telegram",
      "url": "https://sluglang.org/libraries/slug-thirdparty-telegram",
      "title": "telegram (slug.thirdparty)",
      "content_html": "<h2 id=\"slugthirdpartytelegram\">slug.thirdparty.telegram</h2>\n\n<p>slug.telegram — Telegram Bot API client</p>\n\n<p>Sends messages, typing indicators, and polls for updates via the\nTelegram Bot API. All functions return the decoded JSON response\nfrom Telegram, or <code class=\"language-plaintext highlighter-rouge\">nil</code> on error.</p>\n\n<h2 id=\"configuration\">Configuration</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Key</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">telegram-token</code></td>\n      <td>required</td>\n      <td>Bot token from @BotFather</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">telegram-url</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">https://api.telegram.org/bot</code></td>\n      <td>API base URL</td>\n    </tr>\n  </tbody>\n</table>\n\n<p>The module will print a warning at load time if <code class=\"language-plaintext highlighter-rouge\">telegram_token</code> is\nnot set but will not exit — callers will receive <code class=\"language-plaintext highlighter-rouge\">nil</code> responses until\na valid token is configured.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { sendMessage, getUpdates } = import(\"slug.telegram\")\n\n// send a message\nsendMessage(chatId, \"Hello from Slug!\")\n\n// poll for new messages\nval response = getUpdates(0)\nval updates  = response['result']\n</code></pre>\n\n<h2 id=\"long-polling\">Long polling</h2>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">getUpdates</code> with an <code class=\"language-plaintext highlighter-rouge\">offset</code> equal to the last <code class=\"language-plaintext highlighter-rouge\">update_id + 1</code>\nto avoid receiving the same update twice. The <code class=\"language-plaintext highlighter-rouge\">timeout</code> parameter\ncontrols how long Telegram holds the connection open waiting for new\nupdates (default 30 seconds).</p>\n\n<h2 id=\"markdown-rendering\">Markdown rendering</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">sendMessage</code> defaults to <code class=\"language-plaintext highlighter-rouge\">parseMode: \"Markdown\"</code> which renders bold,\nitalic, inline code, and code blocks from the message text. Pass\n<code class=\"language-plaintext highlighter-rouge\">parseMode: nil</code> to send plain text.</p>\n\n<p>@effects(‘net’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#getupdatesoffset-timeout\"><code class=\"language-plaintext highlighter-rouge\">getUpdates(offset, timeout)</code></a></li>\n  <li><a href=\"#sendmessagechatid-text-parsemode\"><code class=\"language-plaintext highlighter-rouge\">sendMessage(chatId, text, parseMode)</code></a></li>\n  <li><a href=\"#sendtypingchatid\"><code class=\"language-plaintext highlighter-rouge\">sendTyping(chatId)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"getupdatesoffset-timeout\"><code class=\"language-plaintext highlighter-rouge\">getUpdates(offset, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.thirdparty.telegram#getUpdates(offset:num, timeout:num = 30):any\n</code></pre>\n\n<p>polls Telegram for new updates starting from <code class=\"language-plaintext highlighter-rouge\">offset</code>.</p>\n\n<p>Uses long polling — Telegram holds the connection open for up to\n<code class=\"language-plaintext highlighter-rouge\">timeout</code> seconds waiting for new updates before returning an empty\nlist. Set <code class=\"language-plaintext highlighter-rouge\">offset</code> to the last received <code class=\"language-plaintext highlighter-rouge\">update_id + 1</code> to acknowledge\nprocessed updates and avoid receiving them again.</p>\n\n<p>Returns the decoded Telegram response map <code class=\"language-plaintext highlighter-rouge\">{ ok, result: [...] }</code>,\nor <code class=\"language-plaintext highlighter-rouge\">nil</code> on error.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">offset</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">30</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">net</code></p>\n\n<hr />\n\n<h4 id=\"sendmessagechatid-text-parsemode\"><code class=\"language-plaintext highlighter-rouge\">sendMessage(chatId, text, parseMode)</code></h4>\n<pre><code class=\"language-slug\">fn slug.thirdparty.telegram#sendMessage(chatId, text, parseMode = \"Markdown\"):any\n</code></pre>\n\n<p>sends a text message to a Telegram chat.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">parseMode</code> controls text formatting; defaults to <code class=\"language-plaintext highlighter-rouge\">\"Markdown\"</code> which\nrenders bold (<code class=\"language-plaintext highlighter-rouge\">**text**</code>), code (<code class=\"language-plaintext highlighter-rouge\">`text`</code>), and code blocks.\nPass <code class=\"language-plaintext highlighter-rouge\">nil</code> to disable formatting. Returns the Telegram API response\nmap, or <code class=\"language-plaintext highlighter-rouge\">nil</code> on error.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">chatId</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">text</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">parseMode</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"Markdown\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">net</code></p>\n\n<hr />\n\n<h4 id=\"sendtypingchatid\"><code class=\"language-plaintext highlighter-rouge\">sendTyping(chatId)</code></h4>\n<pre><code class=\"language-slug\">fn slug.thirdparty.telegram#sendTyping(chatId):any\n</code></pre>\n\n<p>sends a <code class=\"language-plaintext highlighter-rouge\">typing</code> chat action to show the bot is composing a reply.</p>\n\n<p>The indicator displays for ~5 seconds or until the next message is\nsent. Call just before a slow operation to set user expectations.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">chatId</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">net</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.thirdparty.telegram",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-thirdparty-ollama",
      "url": "https://sluglang.org/libraries/slug-thirdparty-ollama",
      "title": "ollama (slug.thirdparty)",
      "content_html": "<h2 id=\"slugthirdpartyollama\">slug.thirdparty.ollama</h2>\n\n<p>slug.ollama — Ollama LLM client</p>\n\n<p>Sends chat requests to a locally running Ollama instance via the\n<code class=\"language-plaintext highlighter-rouge\">/api/chat</code> endpoint and returns the model’s reply as a string.</p>\n\n<h2 id=\"configuration\">Configuration</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Key</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">ollama-url</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">http://localhost:11434</code></td>\n      <td>Ollama base URL</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">ollama-model</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">llama3</code></td>\n      <td>Model name to use</td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { ollamaChat } = import(\"slug.ollama\")\n\nval history = [\n  { role: \"user\", content: \"What is Slug?\" }\n]\n\nval reply = ollamaChat(history)\nprintln(reply)\n</code></pre>\n\n<h2 id=\"conversation-history\">Conversation history</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">history</code> is a list of <code class=\"language-plaintext highlighter-rouge\">{ role, content }</code> maps in Ollama’s message\nformat. Roles are <code class=\"language-plaintext highlighter-rouge\">\"user\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"assistant\"</code>, and <code class=\"language-plaintext highlighter-rouge\">\"system\"</code>. Build up\nhistory by appending each turn:</p>\n\n<pre><code class=\"language-slug\">val history1 = history :+ { role: \"assistant\", content: reply }\nval history2 = history1 :+ { role: \"user\", content: \"Tell me more\" }\nval reply2   = ollamaChat(history2)\n</code></pre>\n\n<h2 id=\"system-prompt\">System prompt</h2>\n\n<p>Pass <code class=\"language-plaintext highlighter-rouge\">systemPrompt</code> to prepend a system message before every request.\nThe system message is injected fresh on each call and never stored in\n<code class=\"language-plaintext highlighter-rouge\">history</code>, so it doesn’t grow with the conversation.</p>\n\n<pre><code class=\"language-slug\">ollamaChat(history, systemPrompt: \"You are a helpful Slug expert.\")\n</code></pre>\n\n<p>@effects(‘net’)</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"ollamachathistory-systemprompt-model\"><code class=\"language-plaintext highlighter-rouge\">ollamaChat(history, systemPrompt, model)</code></h4>\n<pre><code class=\"language-slug\">fn slug.thirdparty.ollama#ollamaChat(history:list, systemPrompt:str = nil, model:str = cfg(ollama-model, llama3)):any\n</code></pre>\n\n<p>sends a chat request to Ollama and returns the model’s reply text.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">history</code> is a list of <code class=\"language-plaintext highlighter-rouge\">{ role, content }</code> maps representing the\nconversation so far. Roles are <code class=\"language-plaintext highlighter-rouge\">\"user\"</code> and <code class=\"language-plaintext highlighter-rouge\">\"assistant\"</code>. If\n<code class=\"language-plaintext highlighter-rouge\">systemPrompt</code> is provided it is prepended as a <code class=\"language-plaintext highlighter-rouge\">\"system\"</code> message\non every call without being stored in <code class=\"language-plaintext highlighter-rouge\">history</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> on error (details logger).</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">history</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">systemPrompt</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">model</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">cfg(ollama-model, llama3)</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">net</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.thirdparty.ollama",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-test",
      "url": "https://sluglang.org/libraries/slug-test",
      "title": "test (slug)",
      "content_html": "<h2 id=\"slugtest\">slug.test</h2>\n\n<p>slug.test — assertion and test utilities</p>\n\n<p>All assertion functions throw <code class=\"language-plaintext highlighter-rouge\">AssertionError</code> on failure and return\nthe tested value on success, allowing assertions to be chained or\nused inline in expressions.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { assertEqual, assertThrows, runSafe } = import(\"slug.test\")\n\nassertEqual(1 + 1, 2)\nassertEqual(\"hello\" /&gt; toUpper(), \"HELLO\")\nassertThrows(fn() { throw Error{ type: \"Oops\", msg: \"!\" } }, \"Oops\")\n</code></pre>\n\n<h2 id=\"short-aliases\">Short aliases</h2>\n\n<p>All assertion functions have short aliases for concise test code:</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Full name</th>\n      <th>Alias</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertEqual</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">eq</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertLessThan</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">lt</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertLessThanOrEqual</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">lteq</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertGreaterThan</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">gt</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertGreaterThanOrEqual</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">gteq</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertThrows</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">throws</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertTrue</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">ok</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">assertFalse</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">not</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"error-safety\">Error safety</h2>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">runSafe</code> to execute a function without propagating errors —\nuseful for testing error paths or running multiple assertions where\na single failure should not abort the rest.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#asserta-msg\"><code class=\"language-plaintext highlighter-rouge\">assert(a, msg)</code></a></li>\n  <li><a href=\"#assertequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertEqual(value, expected, msg)</code></a></li>\n  <li><a href=\"#asserterrortypef-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertErrorType(f, expected, msg)</code></a></li>\n  <li><a href=\"#assertfalsea-msg\"><code class=\"language-plaintext highlighter-rouge\">assertFalse(a, msg)</code></a></li>\n  <li><a href=\"#assertgreaterthanvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertGreaterThan(value, expected, msg)</code></a></li>\n  <li><a href=\"#assertgreaterthanorequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertGreaterThanOrEqual(value, expected, msg)</code></a></li>\n  <li><a href=\"#assertlessthanvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertLessThan(value, expected, msg)</code></a></li>\n  <li><a href=\"#assertlessthanorequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertLessThanOrEqual(value, expected, msg)</code></a></li>\n  <li><a href=\"#assertnilvalue-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNil(value, msg)</code></a></li>\n  <li><a href=\"#assertnotequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNotEqual(value, expected, msg)</code></a></li>\n  <li><a href=\"#assertnotnilvalue-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNotNil(value, msg)</code></a></li>\n  <li><a href=\"#assertthrowsf-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertThrows(f, expected, msg)</code></a></li>\n  <li><a href=\"#asserttruea-msg\"><code class=\"language-plaintext highlighter-rouge\">assertTrue(a, msg)</code></a></li>\n  <li><a href=\"#eqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">eq(value, expected, msg)</code></a></li>\n  <li><a href=\"#failmsg\"><code class=\"language-plaintext highlighter-rouge\">fail(msg)</code></a></li>\n  <li><a href=\"#gtvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">gt(value, expected, msg)</code></a></li>\n  <li><a href=\"#gteqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">gteq(value, expected, msg)</code></a></li>\n  <li><a href=\"#isasserterrorv\"><code class=\"language-plaintext highlighter-rouge\">isAssertError(v)</code></a></li>\n  <li><a href=\"#ltvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">lt(value, expected, msg)</code></a></li>\n  <li><a href=\"#lteqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">lteq(value, expected, msg)</code></a></li>\n  <li><a href=\"#nota-msg\"><code class=\"language-plaintext highlighter-rouge\">not(a, msg)</code></a></li>\n  <li><a href=\"#oka-msg\"><code class=\"language-plaintext highlighter-rouge\">ok(a, msg)</code></a></li>\n  <li><a href=\"#runsafef\"><code class=\"language-plaintext highlighter-rouge\">runSafe(f)</code></a></li>\n  <li><a href=\"#throwsf-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">throws(f, expected, msg)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"asserta-msg\"><code class=\"language-plaintext highlighter-rouge\">assert(a, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assert(a, msg:str|nil = nil):bool\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">a</code> is <code class=\"language-plaintext highlighter-rouge\">true</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertEqual(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertEqual(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value</code> equals <code class=\"language-plaintext highlighter-rouge\">expected</code> using deep equality.</p>\n\n<p>Uses <code class=\"language-plaintext highlighter-rouge\">equals</code> for lists and maps, <code class=\"language-plaintext highlighter-rouge\">structEquals</code> for structs, and\n<code class=\"language-plaintext highlighter-rouge\">==</code> for all other types. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"asserterrortypef-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertErrorType(f, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertErrorType(f:fn&lt;any&gt;, expected, msg:str|nil = nil):bool\n</code></pre>\n\n<p>asserts that calling <code class=\"language-plaintext highlighter-rouge\">f</code> throws a value of type <code class=\"language-plaintext highlighter-rouge\">expected</code>.</p>\n\n<p>Throws <code class=\"language-plaintext highlighter-rouge\">AssertionError</code> if <code class=\"language-plaintext highlighter-rouge\">f</code> does not throw, or if the thrown\nvalue’s type does not match <code class=\"language-plaintext highlighter-rouge\">expected</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn<any></any></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertfalsea-msg\"><code class=\"language-plaintext highlighter-rouge\">assertFalse(a, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertFalse(a, msg:str|nil = nil):bool\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">a</code> is falsey.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertgreaterthanvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertGreaterThan(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertGreaterThan(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value &gt; expected</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertgreaterthanorequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertGreaterThanOrEqual(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertGreaterThanOrEqual(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value &gt;= expected</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertlessthanvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertLessThan(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertLessThan(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value &lt; expected</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertlessthanorequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertLessThanOrEqual(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertLessThanOrEqual(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value &lt;= expected</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertnilvalue-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNil(value, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertNil(value, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value</code> is <code class=\"language-plaintext highlighter-rouge\">nil</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertnotequalvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNotEqual(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertNotEqual(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value</code> does not equal <code class=\"language-plaintext highlighter-rouge\">expected</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertnotnilvalue-msg\"><code class=\"language-plaintext highlighter-rouge\">assertNotNil(value, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertNotNil(value, msg:str|nil = nil):any\n</code></pre>\n\n<p>asserts that <code class=\"language-plaintext highlighter-rouge\">value</code> is not <code class=\"language-plaintext highlighter-rouge\">nil</code>. Returns <code class=\"language-plaintext highlighter-rouge\">value</code> on success.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"assertthrowsf-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">assertThrows(f, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertThrows(f:fn&lt;any&gt;, expected, msg:str|nil = nil):bool\n</code></pre>\n\n<p>asserts that calling <code class=\"language-plaintext highlighter-rouge\">f</code> throws a value equal to <code class=\"language-plaintext highlighter-rouge\">expected</code>.</p>\n\n<p>Throws <code class=\"language-plaintext highlighter-rouge\">AssertionError</code> if <code class=\"language-plaintext highlighter-rouge\">f</code> does not throw, or if the thrown\nvalue is not equal to <code class=\"language-plaintext highlighter-rouge\">expected</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn<any></any></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"asserttruea-msg\"><code class=\"language-plaintext highlighter-rouge\">assertTrue(a, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#assertTrue(a, msg:str|nil = nil):bool\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"eqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">eq(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#eq(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"failmsg\"><code class=\"language-plaintext highlighter-rouge\">fail(msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#fail(msg:str|nil = nil):any\n</code></pre>\n\n<p>unconditionally throws an <code class=\"language-plaintext highlighter-rouge\">AssertionError</code> with an optional message.</p>\n\n<p>Useful as a catch-all in match arms or branches that should never be reached.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"gtvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">gt(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#gt(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"gteqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">gteq(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#gteq(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"isasserterrorv\"><code class=\"language-plaintext highlighter-rouge\">isAssertError(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#isAssertError(v):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">v</code> is an AssertionError thrown by this module.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"ltvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">lt(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#lt(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"lteqvalue-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">lteq(value, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#lteq(value, expected, msg:str|nil = nil):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"nota-msg\"><code class=\"language-plaintext highlighter-rouge\">not(a, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#not(a, msg:str|nil = nil):bool\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"oka-msg\"><code class=\"language-plaintext highlighter-rouge\">ok(a, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#ok(a, msg:str|nil = nil):bool\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n\n<hr />\n\n<h4 id=\"runsafef\"><code class=\"language-plaintext highlighter-rouge\">runSafe(f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#runSafe(f:fn&lt;any&gt;):map&lt;sym,any&gt;\n</code></pre>\n\n<p>executes <code class=\"language-plaintext highlighter-rouge\">f()</code> and returns a result map without propagating errors.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">{\"ok\": value}</code> on normal return, or\n<code class=\"language-plaintext highlighter-rouge\">{\"error\": thrownValue, \"trace\": stacktrace(thrownValue)}</code> on throw.</p>\n\n<p>Useful for testing that functions throw expected errors, or for running\ntest suites where a single failure should not abort subsequent tests.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn<any></any></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"throwsf-expected-msg\"><code class=\"language-plaintext highlighter-rouge\">throws(f, expected, msg)</code></h4>\n<pre><code class=\"language-slug\">fn slug.test#throws(f:fn&lt;any&gt;, expected, msg:str|nil = nil):bool\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn<any></any></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">expected</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:AssertionError}</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.test",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-term-control",
      "url": "https://sluglang.org/libraries/slug-term-control",
      "title": "control (slug.term)",
      "content_html": "<h2 id=\"slugtermcontrol\">slug.term.control</h2>\n\n<p>slug.term.control — terminal control sequences</p>\n\n<p>Utilities for clearing the terminal display. These functions print\nANSI escape sequences directly to stdout via <code class=\"language-plaintext highlighter-rouge\">print</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#clear\"><code class=\"language-plaintext highlighter-rouge\">clear()</code></a></li>\n  <li><a href=\"#clearall\"><code class=\"language-plaintext highlighter-rouge\">clearAll()</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"clear\"><code class=\"language-plaintext highlighter-rouge\">clear()</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.control#clear():any\n</code></pre>\n\n<p>clears the terminal screen and moves the cursor to the top-left.</p>\n\n<p>Equivalent to the <code class=\"language-plaintext highlighter-rouge\">clear</code> shell command. Does not clear the scrollback buffer.</p>\n\n<hr />\n\n<h4 id=\"clearall\"><code class=\"language-plaintext highlighter-rouge\">clearAll()</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.control#clearAll():any\n</code></pre>\n\n<p>clears the terminal screen, scrollback buffer, and moves the cursor to the top-left.</p>\n\n<p>More thorough than <code class=\"language-plaintext highlighter-rouge\">clear</code> — also wipes the scrollback history visible\nwhen scrolling up in the terminal.</p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.term.control",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-term-colour",
      "url": "https://sluglang.org/libraries/slug-term-colour",
      "title": "colour (slug.term)",
      "content_html": "<h2 id=\"slugtermcolour\">slug.term.colour</h2>\n\n<p>slug.term.colour — terminal colour and text effect library</p>\n\n<p>Wraps strings with ANSI escape codes for coloured terminal output.\nInspired by the Python <a href=\"https://jakob-bagterp.github.io/colorist-for-python/\">colorist</a>\nlibrary. See also the <a href=\"https://en.wikipedia.org/wiki/ANSI_escape_code#Colors\">ANSI escape code reference</a>.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { red, green, effectBold, bgBlue } = import(\"slug.term.colour\")\n\n\"Hello\" /&gt; red /&gt; println\n\"Success\" /&gt; green /&gt; effectBold /&gt; println\n\"Warning\" /&gt; bgBlue /&gt; println\n</code></pre>\n\n<h2 id=\"colour-functions\">Colour functions</h2>\n\n<p>Each named colour is available as a function taking a string and returning\nthe ANSI-wrapped string. Text colours: <code class=\"language-plaintext highlighter-rouge\">black</code>, <code class=\"language-plaintext highlighter-rouge\">red</code>, <code class=\"language-plaintext highlighter-rouge\">green</code>, <code class=\"language-plaintext highlighter-rouge\">yellow</code>,\n<code class=\"language-plaintext highlighter-rouge\">blue</code>, <code class=\"language-plaintext highlighter-rouge\">magenta</code>, <code class=\"language-plaintext highlighter-rouge\">cyan</code>, <code class=\"language-plaintext highlighter-rouge\">white</code> and bright variants (<code class=\"language-plaintext highlighter-rouge\">brightRed</code> etc.).\nBackground variants are prefixed with <code class=\"language-plaintext highlighter-rouge\">bg</code> (<code class=\"language-plaintext highlighter-rouge\">bgRed</code>, <code class=\"language-plaintext highlighter-rouge\">bgBrightBlue</code> etc.).</p>\n\n<h2 id=\"extended-colour-support\">Extended colour support</h2>\n\n<p>For terminals supporting 256 colours or true colour:</p>\n<ul>\n  <li><strong>VGA (0–255):</strong> <code class=\"language-plaintext highlighter-rouge\">vga(str, code)</code>, <code class=\"language-plaintext highlighter-rouge\">bgVga(str, code)</code></li>\n  <li><strong>RGB:</strong> <code class=\"language-plaintext highlighter-rouge\">rgb(str, r, g, b)</code>, <code class=\"language-plaintext highlighter-rouge\">bgRgb(str, r, g, b)</code></li>\n  <li><strong>Hex:</strong> <code class=\"language-plaintext highlighter-rouge\">hex(str, \"#ff5733\")</code>, <code class=\"language-plaintext highlighter-rouge\">bgHex(str, \"#ff5733\")</code></li>\n  <li><strong>xkcd:</strong> <code class=\"language-plaintext highlighter-rouge\">xkcd(str, :electricLime)</code>, <code class=\"language-plaintext highlighter-rouge\">bgXkcd(str, :neonBlue)</code></li>\n</ul>\n\n<h2 id=\"effects\">Effects</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">effectBold</code>, <code class=\"language-plaintext highlighter-rouge\">effectDim</code>, <code class=\"language-plaintext highlighter-rouge\">effectUnderline</code>, <code class=\"language-plaintext highlighter-rouge\">effectBlink</code>,\n<code class=\"language-plaintext highlighter-rouge\">effectReverse</code>, <code class=\"language-plaintext highlighter-rouge\">effectHide</code></p>\n\n<h2 id=\"colour-support-detection\">Colour support detection</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">ColourSupport</code> is set at module load time by running <code class=\"language-plaintext highlighter-rouge\">tput colors</code>.\nUse it to gracefully degrade in environments without colour support.</p>\n\n<h2 id=\"pre-built-maps\">Pre-built maps</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">Colour</code>, <code class=\"language-plaintext highlighter-rouge\">BrightColour</code>, <code class=\"language-plaintext highlighter-rouge\">BgColour</code>, <code class=\"language-plaintext highlighter-rouge\">BgBrightColour</code> are maps of\ncolour name → ANSI code string for programmatic use.\n<code class=\"language-plaintext highlighter-rouge\">Effects</code> is a map of effect name → ANSI code string.\n<code class=\"language-plaintext highlighter-rouge\">Styles</code> is the raw map of style name → ANSI code number list.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#bgbrightcolour\">BgBrightColour</a></li>\n  <li><a href=\"#bgcolour\">BgColour</a></li>\n  <li><a href=\"#brightcolour\">BrightColour</a></li>\n  <li><a href=\"#colour\">Colour</a></li>\n  <li><a href=\"#coloursupport\">ColourSupport</a></li>\n  <li><a href=\"#effects\">Effects</a></li>\n  <li><a href=\"#styles\">Styles</a></li>\n  <li><a href=\"#reset\">reset</a></li>\n  <li><a href=\"#bgblackstr\"><code class=\"language-plaintext highlighter-rouge\">bgBlack(str)</code></a></li>\n  <li><a href=\"#bgbluestr\"><code class=\"language-plaintext highlighter-rouge\">bgBlue(str)</code></a></li>\n  <li><a href=\"#bgbrightblackstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightBlack(str)</code></a></li>\n  <li><a href=\"#bgbrightbluestr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightBlue(str)</code></a></li>\n  <li><a href=\"#bgbrightcyanstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightCyan(str)</code></a></li>\n  <li><a href=\"#bgbrightgreenstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightGreen(str)</code></a></li>\n  <li><a href=\"#bgbrightmagentastr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightMagenta(str)</code></a></li>\n  <li><a href=\"#bgbrightredstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightRed(str)</code></a></li>\n  <li><a href=\"#bgbrightwhitestr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightWhite(str)</code></a></li>\n  <li><a href=\"#bgbrightyellowstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightYellow(str)</code></a></li>\n  <li><a href=\"#bgcyanstr\"><code class=\"language-plaintext highlighter-rouge\">bgCyan(str)</code></a></li>\n  <li><a href=\"#bggreenstr\"><code class=\"language-plaintext highlighter-rouge\">bgGreen(str)</code></a></li>\n  <li><a href=\"#bghexstr-code\"><code class=\"language-plaintext highlighter-rouge\">bgHex(str, code)</code></a></li>\n  <li><a href=\"#bghexcodecode\"><code class=\"language-plaintext highlighter-rouge\">bgHexCode(code)</code></a></li>\n  <li><a href=\"#bgmagentastr\"><code class=\"language-plaintext highlighter-rouge\">bgMagenta(str)</code></a></li>\n  <li><a href=\"#bgredstr\"><code class=\"language-plaintext highlighter-rouge\">bgRed(str)</code></a></li>\n  <li><a href=\"#bgrgbstr-r-g-b\"><code class=\"language-plaintext highlighter-rouge\">bgRgb(str, r, g, b)</code></a></li>\n  <li><a href=\"#bgrgbcoder-g-b\"><code class=\"language-plaintext highlighter-rouge\">bgRgbCode(r, g, b)</code></a></li>\n  <li><a href=\"#bgvgastr-code\"><code class=\"language-plaintext highlighter-rouge\">bgVga(str, code)</code></a></li>\n  <li><a href=\"#bgvgacodecode\"><code class=\"language-plaintext highlighter-rouge\">bgVgaCode(code)</code></a></li>\n  <li><a href=\"#bgwhitestr\"><code class=\"language-plaintext highlighter-rouge\">bgWhite(str)</code></a></li>\n  <li><a href=\"#bgxkcdstr-name\"><code class=\"language-plaintext highlighter-rouge\">bgXkcd(str, name)</code></a></li>\n  <li><a href=\"#bgxkcdcodename\"><code class=\"language-plaintext highlighter-rouge\">bgXkcdCode(name)</code></a></li>\n  <li><a href=\"#bgyellowstr\"><code class=\"language-plaintext highlighter-rouge\">bgYellow(str)</code></a></li>\n  <li><a href=\"#blackstr\"><code class=\"language-plaintext highlighter-rouge\">black(str)</code></a></li>\n  <li><a href=\"#bluestr\"><code class=\"language-plaintext highlighter-rouge\">blue(str)</code></a></li>\n  <li><a href=\"#brightblackstr\"><code class=\"language-plaintext highlighter-rouge\">brightBlack(str)</code></a></li>\n  <li><a href=\"#brightbluestr\"><code class=\"language-plaintext highlighter-rouge\">brightBlue(str)</code></a></li>\n  <li><a href=\"#brightcyanstr\"><code class=\"language-plaintext highlighter-rouge\">brightCyan(str)</code></a></li>\n  <li><a href=\"#brightgreenstr\"><code class=\"language-plaintext highlighter-rouge\">brightGreen(str)</code></a></li>\n  <li><a href=\"#brightmagentastr\"><code class=\"language-plaintext highlighter-rouge\">brightMagenta(str)</code></a></li>\n  <li><a href=\"#brightredstr\"><code class=\"language-plaintext highlighter-rouge\">brightRed(str)</code></a></li>\n  <li><a href=\"#brightwhitestr\"><code class=\"language-plaintext highlighter-rouge\">brightWhite(str)</code></a></li>\n  <li><a href=\"#brightyellowstr\"><code class=\"language-plaintext highlighter-rouge\">brightYellow(str)</code></a></li>\n  <li><a href=\"#cyanstr\"><code class=\"language-plaintext highlighter-rouge\">cyan(str)</code></a></li>\n  <li><a href=\"#effectblinkstr\"><code class=\"language-plaintext highlighter-rouge\">effectBlink(str)</code></a></li>\n  <li><a href=\"#effectboldstr\"><code class=\"language-plaintext highlighter-rouge\">effectBold(str)</code></a></li>\n  <li><a href=\"#effectdimstr\"><code class=\"language-plaintext highlighter-rouge\">effectDim(str)</code></a></li>\n  <li><a href=\"#effecthidestr\"><code class=\"language-plaintext highlighter-rouge\">effectHide(str)</code></a></li>\n  <li><a href=\"#effectreversestr\"><code class=\"language-plaintext highlighter-rouge\">effectReverse(str)</code></a></li>\n  <li><a href=\"#effectunderlinestr\"><code class=\"language-plaintext highlighter-rouge\">effectUnderline(str)</code></a></li>\n  <li><a href=\"#greenstr\"><code class=\"language-plaintext highlighter-rouge\">green(str)</code></a></li>\n  <li><a href=\"#hexstr-code\"><code class=\"language-plaintext highlighter-rouge\">hex(str, code)</code></a></li>\n  <li><a href=\"#hexcodecode\"><code class=\"language-plaintext highlighter-rouge\">hexCode(code)</code></a></li>\n  <li><a href=\"#magentastr\"><code class=\"language-plaintext highlighter-rouge\">magenta(str)</code></a></li>\n  <li><a href=\"#redstr\"><code class=\"language-plaintext highlighter-rouge\">red(str)</code></a></li>\n  <li><a href=\"#rgbstr-r-g-b\"><code class=\"language-plaintext highlighter-rouge\">rgb(str, r, g, b)</code></a></li>\n  <li><a href=\"#rgbcoder-g-b\"><code class=\"language-plaintext highlighter-rouge\">rgbCode(r, g, b)</code></a></li>\n  <li><a href=\"#vgastr-code\"><code class=\"language-plaintext highlighter-rouge\">vga(str, code)</code></a></li>\n  <li><a href=\"#vgacodecode\"><code class=\"language-plaintext highlighter-rouge\">vgaCode(code)</code></a></li>\n  <li><a href=\"#whitestr\"><code class=\"language-plaintext highlighter-rouge\">white(str)</code></a></li>\n  <li><a href=\"#xkcdstr-name\"><code class=\"language-plaintext highlighter-rouge\">xkcd(str, name)</code></a></li>\n  <li><a href=\"#xkcdcodename\"><code class=\"language-plaintext highlighter-rouge\">xkcdCode(name)</code></a></li>\n  <li><a href=\"#yellowstr\"><code class=\"language-plaintext highlighter-rouge\">yellow(str)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"bgbrightcolour\"><code class=\"language-plaintext highlighter-rouge\">BgBrightColour</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#BgBrightColour\n</code></pre>\n\n<p>map of colour name → ANSI escape code string for bright background colours.</p>\n\n<h4 id=\"bgcolour\"><code class=\"language-plaintext highlighter-rouge\">BgColour</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#BgColour\n</code></pre>\n\n<p>map of colour name → ANSI escape code string for background colours.</p>\n\n<h4 id=\"brightcolour\"><code class=\"language-plaintext highlighter-rouge\">BrightColour</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#BrightColour\n</code></pre>\n\n<p>map of colour name → ANSI escape code string for bright colours.</p>\n\n<h4 id=\"colour\"><code class=\"language-plaintext highlighter-rouge\">Colour</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#Colour\n</code></pre>\n\n<p>map of colour name (PascalCase) → ANSI escape code string for standard colours.</p>\n\n<h4 id=\"coloursupport\"><code class=\"language-plaintext highlighter-rouge\">ColourSupport</code></h4>\n\n<pre><code class=\"language-slug\">num slug.term.colour#ColourSupport\n</code></pre>\n\n<p>number of colours supported by the current terminal, as reported by <code class=\"language-plaintext highlighter-rouge\">tput colors</code>.</p>\n\n<p>Common values: 0 (no colour), 8, 16, 256.</p>\n\n<h4 id=\"effects-1\"><code class=\"language-plaintext highlighter-rouge\">Effects</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#Effects\n</code></pre>\n\n<p>map of effect name → ANSI escape code string.</p>\n\n<p>Keys: <code class=\"language-plaintext highlighter-rouge\">Bold</code>, <code class=\"language-plaintext highlighter-rouge\">BoldOff</code>, <code class=\"language-plaintext highlighter-rouge\">Dim</code>, <code class=\"language-plaintext highlighter-rouge\">DimOff</code>, <code class=\"language-plaintext highlighter-rouge\">Underline</code>, <code class=\"language-plaintext highlighter-rouge\">UnderlineOff</code>,\n<code class=\"language-plaintext highlighter-rouge\">Blink</code>, <code class=\"language-plaintext highlighter-rouge\">BlinkOff</code>, <code class=\"language-plaintext highlighter-rouge\">Reverse</code>, <code class=\"language-plaintext highlighter-rouge\">ReverseOff</code>, <code class=\"language-plaintext highlighter-rouge\">Hide</code>, <code class=\"language-plaintext highlighter-rouge\">HideOff</code></p>\n\n<h4 id=\"styles\"><code class=\"language-plaintext highlighter-rouge\">Styles</code></h4>\n\n<pre><code class=\"language-slug\">map slug.term.colour#Styles\n</code></pre>\n\n<p>raw ANSI code number lists per style name.</p>\n\n<p>Keys include colour names, bright/bg variants, <code class=\"language-plaintext highlighter-rouge\">reset</code>, and effects.</p>\n\n<h4 id=\"reset\"><code class=\"language-plaintext highlighter-rouge\">reset</code></h4>\n\n<pre><code class=\"language-slug\">str slug.term.colour#reset\n</code></pre>\n\n<p>ANSI reset escape code — resets all styles to terminal default.</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"bgblackstr\"><code class=\"language-plaintext highlighter-rouge\">bgBlack(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBlack(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbluestr\"><code class=\"language-plaintext highlighter-rouge\">bgBlue(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBlue(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightblackstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightBlack(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightBlack(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightbluestr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightBlue(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightBlue(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightcyanstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightCyan(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightCyan(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightgreenstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightGreen(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightGreen(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightmagentastr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightMagenta(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightMagenta(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightredstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightRed(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightRed(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightwhitestr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightWhite(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightWhite(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgbrightyellowstr\"><code class=\"language-plaintext highlighter-rouge\">bgBrightYellow(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgBrightYellow(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgcyanstr\"><code class=\"language-plaintext highlighter-rouge\">bgCyan(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgCyan(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bggreenstr\"><code class=\"language-plaintext highlighter-rouge\">bgGreen(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgGreen(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bghexstr-code\"><code class=\"language-plaintext highlighter-rouge\">bgHex(str, code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgHex(str:str, code:str):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with hex background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bghexcodecode\"><code class=\"language-plaintext highlighter-rouge\">bgHexCode(code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgHexCode(code:str):any\n</code></pre>\n\n<p>returns the ANSI escape code string for hex background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgmagentastr\"><code class=\"language-plaintext highlighter-rouge\">bgMagenta(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgMagenta(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgredstr\"><code class=\"language-plaintext highlighter-rouge\">bgRed(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgRed(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgrgbstr-r-g-b\"><code class=\"language-plaintext highlighter-rouge\">bgRgb(str, r, g, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgRgb(str:str, r:num, g:num, b:num):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with RGB background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">g</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgrgbcoder-g-b\"><code class=\"language-plaintext highlighter-rouge\">bgRgbCode(r, g, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgRgbCode(r:num, g:num, b:num):any\n</code></pre>\n\n<p>returns the ANSI escape code string for RGB background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">g</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgvgastr-code\"><code class=\"language-plaintext highlighter-rouge\">bgVga(str, code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgVga(str:str, code:num):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with VGA background colour <code class=\"language-plaintext highlighter-rouge\">code</code> (0–255).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgvgacodecode\"><code class=\"language-plaintext highlighter-rouge\">bgVgaCode(code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgVgaCode(code:num):any\n</code></pre>\n\n<p>returns the ANSI escape code string for VGA background colour index <code class=\"language-plaintext highlighter-rouge\">code</code> (0–255).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgwhitestr\"><code class=\"language-plaintext highlighter-rouge\">bgWhite(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgWhite(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgxkcdstr-name\"><code class=\"language-plaintext highlighter-rouge\">bgXkcd(str, name)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgXkcd(str:str, name:sym):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with an xkcd background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>sym</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgxkcdcodename\"><code class=\"language-plaintext highlighter-rouge\">bgXkcdCode(name)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgXkcdCode(name:sym):any\n</code></pre>\n\n<p>returns the ANSI escape code string for an xkcd background colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>sym</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bgyellowstr\"><code class=\"language-plaintext highlighter-rouge\">bgYellow(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#bgYellow(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"blackstr\"><code class=\"language-plaintext highlighter-rouge\">black(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#black(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bluestr\"><code class=\"language-plaintext highlighter-rouge\">blue(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#blue(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightblackstr\"><code class=\"language-plaintext highlighter-rouge\">brightBlack(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightBlack(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightbluestr\"><code class=\"language-plaintext highlighter-rouge\">brightBlue(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightBlue(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightcyanstr\"><code class=\"language-plaintext highlighter-rouge\">brightCyan(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightCyan(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightgreenstr\"><code class=\"language-plaintext highlighter-rouge\">brightGreen(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightGreen(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightmagentastr\"><code class=\"language-plaintext highlighter-rouge\">brightMagenta(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightMagenta(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightredstr\"><code class=\"language-plaintext highlighter-rouge\">brightRed(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightRed(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightwhitestr\"><code class=\"language-plaintext highlighter-rouge\">brightWhite(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightWhite(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"brightyellowstr\"><code class=\"language-plaintext highlighter-rouge\">brightYellow(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#brightYellow(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cyanstr\"><code class=\"language-plaintext highlighter-rouge\">cyan(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#cyan(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effectblinkstr\"><code class=\"language-plaintext highlighter-rouge\">effectBlink(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectBlink(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effectboldstr\"><code class=\"language-plaintext highlighter-rouge\">effectBold(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectBold(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effectdimstr\"><code class=\"language-plaintext highlighter-rouge\">effectDim(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectDim(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effecthidestr\"><code class=\"language-plaintext highlighter-rouge\">effectHide(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectHide(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effectreversestr\"><code class=\"language-plaintext highlighter-rouge\">effectReverse(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectReverse(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"effectunderlinestr\"><code class=\"language-plaintext highlighter-rouge\">effectUnderline(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#effectUnderline(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"greenstr\"><code class=\"language-plaintext highlighter-rouge\">green(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#green(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hexstr-code\"><code class=\"language-plaintext highlighter-rouge\">hex(str, code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#hex(str:str, code:str):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with hex colour (e.g. <code class=\"language-plaintext highlighter-rouge\">hex(\"Hello\", \"#ff5733\")</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hexcodecode\"><code class=\"language-plaintext highlighter-rouge\">hexCode(code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#hexCode(code:str):any\n</code></pre>\n\n<p>returns the ANSI escape code string for hex colour <code class=\"language-plaintext highlighter-rouge\">code</code> (e.g. <code class=\"language-plaintext highlighter-rouge\">\"#ff5733\"</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"magentastr\"><code class=\"language-plaintext highlighter-rouge\">magenta(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#magenta(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"redstr\"><code class=\"language-plaintext highlighter-rouge\">red(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#red(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rgbstr-r-g-b\"><code class=\"language-plaintext highlighter-rouge\">rgb(str, r, g, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#rgb(str:str, r:num, g:num, b:num):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with RGB colour <code class=\"language-plaintext highlighter-rouge\">r</code>, <code class=\"language-plaintext highlighter-rouge\">g</code>, <code class=\"language-plaintext highlighter-rouge\">b</code> (0–255 each).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">g</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rgbcoder-g-b\"><code class=\"language-plaintext highlighter-rouge\">rgbCode(r, g, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#rgbCode(r:num, g:num, b:num):any\n</code></pre>\n\n<p>returns the ANSI escape code string for RGB colour.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">r</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">g</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"vgastr-code\"><code class=\"language-plaintext highlighter-rouge\">vga(str, code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#vga(str:str, code:num):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with VGA colour <code class=\"language-plaintext highlighter-rouge\">code</code> (0–255).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"vgacodecode\"><code class=\"language-plaintext highlighter-rouge\">vgaCode(code)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#vgaCode(code:num):any\n</code></pre>\n\n<p>returns the ANSI escape code string for VGA colour index <code class=\"language-plaintext highlighter-rouge\">code</code> (0–255).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"whitestr\"><code class=\"language-plaintext highlighter-rouge\">white(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#white(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"xkcdstr-name\"><code class=\"language-plaintext highlighter-rouge\">xkcd(str, name)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#xkcd(str:str, name:sym):any\n</code></pre>\n\n<p>wraps <code class=\"language-plaintext highlighter-rouge\">str</code> with an xkcd colour (e.g. <code class=\"language-plaintext highlighter-rouge\">xkcd(\"Hello\", :electricLime)</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>sym</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"xkcdcodename\"><code class=\"language-plaintext highlighter-rouge\">xkcdCode(name)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#xkcdCode(name:sym):any\n</code></pre>\n\n<p>returns the ANSI escape code string for an xkcd colour name (e.g. <code class=\"language-plaintext highlighter-rouge\">:electricLime</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>sym</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"yellowstr\"><code class=\"language-plaintext highlighter-rouge\">yellow(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.term.colour#yellow(str:str):any\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.term.colour",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-sys",
      "url": "https://sluglang.org/libraries/slug-sys",
      "title": "sys (slug)",
      "content_html": "<h2 id=\"slugsys\">slug.sys</h2>\n\n<p>slug.sys — operating system interface</p>\n\n<p>Process management, environment variables, and shell command execution.</p>\n\n<h2 id=\"process-handles\">Process handles</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">spawnProc</code>, <code class=\"language-plaintext highlighter-rouge\">waitProc</code>, and <code class=\"language-plaintext highlighter-rouge\">killProc</code> work with numeric process handles.\nSpawn a process with <code class=\"language-plaintext highlighter-rouge\">spawnProc</code>, wait for it to finish with <code class=\"language-plaintext highlighter-rouge\">waitProc</code>,\nand terminate it early with <code class=\"language-plaintext highlighter-rouge\">killProc</code>.</p>\n\n<p>For simple synchronous command execution, prefer <code class=\"language-plaintext highlighter-rouge\">exec</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#envstr\"><code class=\"language-plaintext highlighter-rouge\">env(str)</code></a></li>\n  <li><a href=\"#execcmd-timeout\"><code class=\"language-plaintext highlighter-rouge\">exec(cmd, timeout)</code></a></li>\n  <li><a href=\"#exitexitcode\"><code class=\"language-plaintext highlighter-rouge\">exit(exitCode)</code></a></li>\n  <li><a href=\"#killprochandle\"><code class=\"language-plaintext highlighter-rouge\">killProc(handle)</code></a></li>\n  <li><a href=\"#setenvkey-value\"><code class=\"language-plaintext highlighter-rouge\">setEnv(key, value)</code></a></li>\n  <li><a href=\"#spawnproccmd\"><code class=\"language-plaintext highlighter-rouge\">spawnProc(cmd)</code></a></li>\n  <li><a href=\"#waitprochandle-timeout\"><code class=\"language-plaintext highlighter-rouge\">waitProc(handle, timeout)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"envstr\"><code class=\"language-plaintext highlighter-rouge\">env(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#env(str:str):str|nil\n</code></pre>\n\n<p>reads an environment variable by name.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> if the variable is not set.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n\n<hr />\n\n<h4 id=\"execcmd-timeout\"><code class=\"language-plaintext highlighter-rouge\">exec(cmd, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#exec(cmd:str, timeout:num = 0):[str, str]\n</code></pre>\n\n<p>runs a shell command synchronously and returns <code class=\"language-plaintext highlighter-rouge\">[stdout, stderr]</code>.</p>\n\n<p>Blocks until the command completes or <code class=\"language-plaintext highlighter-rouge\">timeout</code> elapses. A <code class=\"language-plaintext highlighter-rouge\">timeout</code>\nof <code class=\"language-plaintext highlighter-rouge\">0</code> means wait indefinitely. Both stdout and stderr are returned\nas strings regardless of exit code.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">cmd</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n\n<hr />\n\n<h4 id=\"exitexitcode\"><code class=\"language-plaintext highlighter-rouge\">exit(exitCode)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#exit(exitCode:num):nil\n</code></pre>\n\n<p>terminates the current process with the given exit code.</p>\n\n<p>Deferred functions are not run. Exit code <code class=\"language-plaintext highlighter-rouge\">0</code> indicates success;\nnon-zero indicates failure.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">exitCode</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"killprochandle\"><code class=\"language-plaintext highlighter-rouge\">killProc(handle)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#killProc(handle:num):bool\n</code></pre>\n\n<p>sends a termination signal to a spawned process.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">true</code> if the signal was delivered successfully.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n\n<hr />\n\n<h4 id=\"setenvkey-value\"><code class=\"language-plaintext highlighter-rouge\">setEnv(key, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#setEnv(key:str, value:str):str\n</code></pre>\n\n<p>sets an environment variable.</p>\n\n<p>The format is <code class=\"language-plaintext highlighter-rouge\">\"NAME\", \"value\"</code>. Returns the value that was set.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n\n<hr />\n\n<h4 id=\"spawnproccmd\"><code class=\"language-plaintext highlighter-rouge\">spawnProc(cmd)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#spawnProc(cmd:list):num\n</code></pre>\n\n<p>spawns a process from a command list and returns a process handle.</p>\n\n<p>The command list format is <code class=\"language-plaintext highlighter-rouge\">[\"executable\", \"arg1\", \"arg2\", ...]</code>.\nUse <code class=\"language-plaintext highlighter-rouge\">waitProc</code> to block until the process finishes, or <code class=\"language-plaintext highlighter-rouge\">killProc</code>\nto terminate it.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">cmd</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n\n<hr />\n\n<h4 id=\"waitprochandle-timeout\"><code class=\"language-plaintext highlighter-rouge\">waitProc(handle, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.sys#waitProc(handle:num, timeout:num = 0):num\n</code></pre>\n\n<p>waits for a spawned process to finish and returns its exit code.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">-1</code> if <code class=\"language-plaintext highlighter-rouge\">timeout</code> elapses before the process exits.\nA <code class=\"language-plaintext highlighter-rouge\">timeout</code> of <code class=\"language-plaintext highlighter-rouge\">0</code> means wait indefinitely.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">io</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.sys",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-string",
      "url": "https://sluglang.org/libraries/slug-string",
      "title": "string (slug)",
      "content_html": "<h2 id=\"slugstring\">slug.string</h2>\n\n<p>slug.string — string manipulation utilities</p>\n\n<p>Trimming, splitting, joining, searching, replacing, case conversion,\npadding, case formatting, and random string generation.</p>\n\n<p>All functions treat strings as sequences of Unicode code points where\nrelevant (e.g. <code class=\"language-plaintext highlighter-rouge\">indexOf</code> is Unicode-aware).</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#camelcases-sep\"><code class=\"language-plaintext highlighter-rouge\">camelCase(s, sep)</code></a></li>\n  <li><a href=\"#containsstr-seq\"><code class=\"language-plaintext highlighter-rouge\">contains(str, seq)</code></a></li>\n  <li><a href=\"#containsanystr-seq\"><code class=\"language-plaintext highlighter-rouge\">containsAny(str, seq)</code></a></li>\n  <li><a href=\"#endswithstr-end\"><code class=\"language-plaintext highlighter-rouge\">endsWith(str, end)</code></a></li>\n  <li><a href=\"#fromcodepointcodepoint\"><code class=\"language-plaintext highlighter-rouge\">fromCodePoint(codePoint)</code></a></li>\n  <li><a href=\"#indexofstr-seq-index\"><code class=\"language-plaintext highlighter-rouge\">indexOf(str, seq, index)</code></a></li>\n  <li><a href=\"#islowerstr\"><code class=\"language-plaintext highlighter-rouge\">isLower(str)</code></a></li>\n  <li><a href=\"#isupperstr\"><code class=\"language-plaintext highlighter-rouge\">isUpper(str)</code></a></li>\n  <li><a href=\"#joinstrs-delimiter-str\"><code class=\"language-plaintext highlighter-rouge\">join(strs, delimiter, str)</code></a></li>\n  <li><a href=\"#kebabcases-sep\"><code class=\"language-plaintext highlighter-rouge\">kebabCase(s, sep)</code></a></li>\n  <li><a href=\"#lastindexofstr-seq-index-prev\"><code class=\"language-plaintext highlighter-rouge\">lastIndexOf(str, seq, index, prev)</code></a></li>\n  <li><a href=\"#padleftstr-with-length\"><code class=\"language-plaintext highlighter-rouge\">padLeft(str, with, length)</code></a></li>\n  <li><a href=\"#padrightstr-with-length\"><code class=\"language-plaintext highlighter-rouge\">padRight(str, with, length)</code></a></li>\n  <li><a href=\"#pascalcases-sep\"><code class=\"language-plaintext highlighter-rouge\">pascalCase(s, sep)</code></a></li>\n  <li><a href=\"#randomhexstringlength\"><code class=\"language-plaintext highlighter-rouge\">randomHexString(length)</code></a></li>\n  <li><a href=\"#randomstringlength-chars-acc\"><code class=\"language-plaintext highlighter-rouge\">randomString(length, chars, acc)</code></a></li>\n  <li><a href=\"#replaceallstr-replace-with\"><code class=\"language-plaintext highlighter-rouge\">replaceAll(str, replace, with)</code></a></li>\n  <li><a href=\"#snakecases-sep-screaming\"><code class=\"language-plaintext highlighter-rouge\">snakeCase(s, sep, screaming)</code></a></li>\n  <li><a href=\"#splitstr-delimiter-max-count-strs\"><code class=\"language-plaintext highlighter-rouge\">split(str, delimiter, max, count, strs)</code></a></li>\n  <li><a href=\"#startswithstr-start\"><code class=\"language-plaintext highlighter-rouge\">startsWith(str, start)</code></a></li>\n  <li><a href=\"#tolowerstr\"><code class=\"language-plaintext highlighter-rouge\">toLower(str)</code></a></li>\n  <li><a href=\"#toupperstr\"><code class=\"language-plaintext highlighter-rouge\">toUpper(str)</code></a></li>\n  <li><a href=\"#trimstr\"><code class=\"language-plaintext highlighter-rouge\">trim(str)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"camelcases-sep\"><code class=\"language-plaintext highlighter-rouge\">camelCase(s, sep)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#camelCase(s:str, sep:str = \" \"):str\n</code></pre>\n\n<p>converts a string to <code class=\"language-plaintext highlighter-rouge\">camelCase</code>, capitalising each word except the first.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\" \"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">camelCase(\"LAST NAME\")  // =&gt; \"lastName\"\ncamelCase(\"last name\")  // =&gt; \"lastName\"\ncamelCase(\"l\")  // =&gt; \"l\"\ncamelCase(\"l n\")  // =&gt; \"lN\"\ncamelCase(\"l   n\")  // =&gt; \"lN\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"containsstr-seq\"><code class=\"language-plaintext highlighter-rouge\">contains(str, seq)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#contains(str:str, seq:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">seq</code> appears anywhere in <code class=\"language-plaintext highlighter-rouge\">str</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">seq</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">contains(\"hello slug\", \"slug\")  // =&gt; true\ncontains(\"hello slug\", \"snail\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"containsanystr-seq\"><code class=\"language-plaintext highlighter-rouge\">containsAny(str, seq)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#containsAny(str:str, ...seq):bool\n</code></pre>\n\n<p>returns true if any on the <code class=\"language-plaintext highlighter-rouge\">seq</code> strings appear in <code class=\"language-plaintext highlighter-rouge\">str</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">seq</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">containsAny(\"hello slug\", \"slug\")  // =&gt; true\ncontainsAny(\"hello slug\", \"snail\", \"fish\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"endswithstr-end\"><code class=\"language-plaintext highlighter-rouge\">endsWith(str, end)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#endsWith(str:str, end:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">str</code> ends with <code class=\"language-plaintext highlighter-rouge\">end</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">end</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">endsWith(\"hello slug\", \"slug\")  // =&gt; true\nendsWith(\"hello slug\", \"hello\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"fromcodepointcodepoint\"><code class=\"language-plaintext highlighter-rouge\">fromCodePoint(codePoint)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#fromCodePoint(codePoint:num):str\n</code></pre>\n\n<p>returns the string corresponding to a Unicode code point.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">codePoint</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">fromCodePoint(65)  // =&gt; \"A\"\nfromCodePoint(129315)  // =&gt; \"🤣\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"indexofstr-seq-index\"><code class=\"language-plaintext highlighter-rouge\">indexOf(str, seq, index)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#indexOf(str:str, seq:str, index:num = 0):num\n</code></pre>\n\n<p>returns the byte index of the first occurrence of <code class=\"language-plaintext highlighter-rouge\">seq</code> in <code class=\"language-plaintext highlighter-rouge\">str</code> at or after <code class=\"language-plaintext highlighter-rouge\">index</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">-1</code> if not found. Unicode-aware.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">seq</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-5\">Examples</h4>\n\n<pre><code class=\"language-slug\">indexOf(\"hello slug\", \"zoo\")  // =&gt; -1\nindexOf(\"hello slug\", \"lu\")  // =&gt; 7\nindexOf(\"hello slug\", \"l\")  // =&gt; 2\nindexOf(\"hello slug\", \"l\", 3)  // =&gt; 3\nindexOf(\"hello slug\", \"l\", 4)  // =&gt; 7\nindexOf(\"éé|éé\", \"|\")  // =&gt; 2\n</code></pre>\n\n<hr />\n\n<h4 id=\"islowerstr\"><code class=\"language-plaintext highlighter-rouge\">isLower(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#isLower(str:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">str</code> is non-empty and entirely lowercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-6\">Examples</h4>\n\n<pre><code class=\"language-slug\">isLower(nil)  // =&gt; false\nisLower(\"\")  // =&gt; false\nisLower(\"slug\")  // =&gt; true\nisLower(\"SLUG\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"isupperstr\"><code class=\"language-plaintext highlighter-rouge\">isUpper(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#isUpper(str:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">str</code> is non-empty and entirely uppercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-7\">Examples</h4>\n\n<pre><code class=\"language-slug\">isUpper(nil)  // =&gt; false\nisUpper(\"\")  // =&gt; false\nisUpper(\"slug\")  // =&gt; false\nisUpper(\"SLUG\")  // =&gt; true\n</code></pre>\n\n<hr />\n\n<h4 id=\"joinstrs-delimiter-str\"><code class=\"language-plaintext highlighter-rouge\">join(strs, delimiter, str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#join(strs:list&lt;str&gt;, delimiter:str = \"\", str:str|nil = nil):str\n</code></pre>\n\n<p>joins a list of strings with <code class=\"language-plaintext highlighter-rouge\">delimiter</code> between each element.</p>\n\n<p>Returns an empty string for an empty list.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">strs</code></td>\n      <td>list<str></str></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">delimiter</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-8\">Examples</h4>\n\n<pre><code class=\"language-slug\">join([], \".\")  // =&gt; \"\"\njoin([\"slug\"], \".\")  // =&gt; \"slug\"\njoin([\"slug\", \"test\"], \".\")  // =&gt; \"slug.test\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"kebabcases-sep\"><code class=\"language-plaintext highlighter-rouge\">kebabCase(s, sep)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#kebabCase(s:str, sep:str = \" \"):str\n</code></pre>\n\n<p>converts a string to <code class=\"language-plaintext highlighter-rouge\">kebab-case</code> by replacing <code class=\"language-plaintext highlighter-rouge\">sep</code> with <code class=\"language-plaintext highlighter-rouge\">-</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\" \"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-9\">Examples</h4>\n\n<pre><code class=\"language-slug\">kebabCase(\"LAST NAME\")  // =&gt; \"LAST-NAME\"\nkebabCase(\"last name\")  // =&gt; \"last-name\"\nkebabCase(\"l\")  // =&gt; \"l\"\nkebabCase(\"l n\")  // =&gt; \"l-n\"\nkebabCase(\"l   n\")  // =&gt; \"l---n\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"lastindexofstr-seq-index-prev\"><code class=\"language-plaintext highlighter-rouge\">lastIndexOf(str, seq, index, prev)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#lastIndexOf(str:str, seq:str, index:num = 0, prev:num = (-1)):num\n</code></pre>\n\n<p>returns the index of the last occurrence of <code class=\"language-plaintext highlighter-rouge\">seq</code> in <code class=\"language-plaintext highlighter-rouge\">str</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">-1</code> if not found.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">seq</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">prev</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">(-1)</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-10\">Examples</h4>\n\n<pre><code class=\"language-slug\">lastIndexOf(\"hello slug\", \"zoo\")  // =&gt; -1\nlastIndexOf(\"hello slug\", \"l\")  // =&gt; 7\nlastIndexOf(\"hello slug\", \"h\")  // =&gt; 0\nlastIndexOf(\"hello slug\", \"g\")  // =&gt; 9\n</code></pre>\n\n<hr />\n\n<h4 id=\"padleftstr-with-length\"><code class=\"language-plaintext highlighter-rouge\">padLeft(str, with, length)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#padLeft(str:str, with:str, length:num):str\n</code></pre>\n\n<p>pads <code class=\"language-plaintext highlighter-rouge\">str</code> on the left with <code class=\"language-plaintext highlighter-rouge\">with</code> until it reaches <code class=\"language-plaintext highlighter-rouge\">length</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">str</code> unchanged if already at or above <code class=\"language-plaintext highlighter-rouge\">length</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">with</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">length</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"padrightstr-with-length\"><code class=\"language-plaintext highlighter-rouge\">padRight(str, with, length)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#padRight(str:str, with:str, length:num):str\n</code></pre>\n\n<p>pads <code class=\"language-plaintext highlighter-rouge\">str</code> on the right with <code class=\"language-plaintext highlighter-rouge\">with</code> until it reaches <code class=\"language-plaintext highlighter-rouge\">length</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">str</code> unchanged if already at or above <code class=\"language-plaintext highlighter-rouge\">length</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">with</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">length</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"pascalcases-sep\"><code class=\"language-plaintext highlighter-rouge\">pascalCase(s, sep)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#pascalCase(s:str, sep:str = \" \"):str\n</code></pre>\n\n<p>converts a string to <code class=\"language-plaintext highlighter-rouge\">PascalCase</code>, capitalising the first letter of each word.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\" \"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-11\">Examples</h4>\n\n<pre><code class=\"language-slug\">pascalCase(\"LAST NAME\")  // =&gt; \"LastName\"\npascalCase(\"last name\")  // =&gt; \"LastName\"\npascalCase(\"l\")  // =&gt; \"L\"\npascalCase(\"l n\")  // =&gt; \"LN\"\npascalCase(\"l   n\")  // =&gt; \"LN\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"randomhexstringlength\"><code class=\"language-plaintext highlighter-rouge\">randomHexString(length)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#randomHexString(length:num):str\n</code></pre>\n\n<p>generates a random lowercase hex string of <code class=\"language-plaintext highlighter-rouge\">length</code> characters.</p>\n\n<p>@effects(‘random’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">length</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">random</code></p>\n\n<hr />\n\n<h4 id=\"randomstringlength-chars-acc\"><code class=\"language-plaintext highlighter-rouge\">randomString(length, chars, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#randomString(length:num, chars:str, acc:str = \"\"):str\n</code></pre>\n\n<p>generates a random string of <code class=\"language-plaintext highlighter-rouge\">length</code> characters drawn from <code class=\"language-plaintext highlighter-rouge\">chars</code>.</p>\n\n<p>@effects(‘random’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">length</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">chars</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">random</code></p>\n\n<hr />\n\n<h4 id=\"replaceallstr-replace-with\"><code class=\"language-plaintext highlighter-rouge\">replaceAll(str, replace, with)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#replaceAll(str:str|nil, replace:str, with:str):str|nil\n</code></pre>\n\n<p>replaces all occurrences of <code class=\"language-plaintext highlighter-rouge\">replace</code> in <code class=\"language-plaintext highlighter-rouge\">str</code> with <code class=\"language-plaintext highlighter-rouge\">with</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> for <code class=\"language-plaintext highlighter-rouge\">nil</code> input.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str | nil</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">replace</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">with</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-12\">Examples</h4>\n\n<pre><code class=\"language-slug\">replaceAll(nil, \"/\", \".\")  // =&gt; nil\nreplaceAll(\"slug/test\", \"/\", \".\")  // =&gt; \"slug.test\"\nreplaceAll(\"slug\", \"/\", \".\")  // =&gt; \"slug\"\nreplaceAll(\"E &amp;amp; S\", \"&amp;amp;\", \"&amp;\")  // =&gt; \"E &amp; S\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"snakecases-sep-screaming\"><code class=\"language-plaintext highlighter-rouge\">snakeCase(s, sep, screaming)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#snakeCase(s:str, sep:str = \" \", screaming = false):str\n</code></pre>\n\n<p>converts a string to <code class=\"language-plaintext highlighter-rouge\">snake_case</code> by replacing <code class=\"language-plaintext highlighter-rouge\">sep</code> with <code class=\"language-plaintext highlighter-rouge\">_</code>.</p>\n\n<p>Pass <code class=\"language-plaintext highlighter-rouge\">screaming: true</code> for <code class=\"language-plaintext highlighter-rouge\">SCREAMING_SNAKE_CASE</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\" \"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">screaming</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-13\">Examples</h4>\n\n<pre><code class=\"language-slug\">snakeCase(\"LAST NAME\", \" \", true)  // =&gt; \"LAST_NAME\"\nsnakeCase(\"last name\", \" \", true)  // =&gt; \"LAST_NAME\"\nsnakeCase(\"LAST NAME\")  // =&gt; \"LAST_NAME\"\nsnakeCase(\"last name\")  // =&gt; \"last_name\"\nsnakeCase(\"l\")  // =&gt; \"l\"\nsnakeCase(\"l n\")  // =&gt; \"l_n\"\nsnakeCase(\"l   n\")  // =&gt; \"l___n\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"splitstr-delimiter-max-count-strs\"><code class=\"language-plaintext highlighter-rouge\">split(str, delimiter, max, count, strs)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#split(str:str, delimiter:str, max:num = (-1), count:num = 1, strs:list&lt;str&gt; = []):list&lt;str&gt;\n</code></pre>\n\n<p>splits <code class=\"language-plaintext highlighter-rouge\">str</code> on <code class=\"language-plaintext highlighter-rouge\">delimiter</code>, returning a list of substrings.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">max</code> limits the number of splits performed; <code class=\"language-plaintext highlighter-rouge\">-1</code> means unlimited.\nThe remaining unsplit portion is always included as the last element.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">count</code> and <code class=\"language-plaintext highlighter-rouge\">strs</code> are internal accumulators — do not pass them directly.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">delimiter</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">max</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">(-1)</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">count</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">strs</code></td>\n      <td>list<str></str></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-14\">Examples</h4>\n\n<pre><code class=\"language-slug\">split(\"slug/test\", \"/\")  // =&gt; [\"slug\", \"test\"]\nsplit(\"éé|éé\", \"|\")  // =&gt; [\"éé\", \"éé\"]\nsplit(\"a|b|c\", \"|\", 2)  // =&gt; [\"a\", \"b|c\"]\n</code></pre>\n\n<hr />\n\n<h4 id=\"startswithstr-start\"><code class=\"language-plaintext highlighter-rouge\">startsWith(str, start)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#startsWith(str:str, start:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">str</code> begins with <code class=\"language-plaintext highlighter-rouge\">start</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">start</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-15\">Examples</h4>\n\n<pre><code class=\"language-slug\">startsWith(\"hello slug\", \"slug\")  // =&gt; false\nstartsWith(\"hello slug\", \"hello\")  // =&gt; true\n</code></pre>\n\n<hr />\n\n<h4 id=\"tolowerstr\"><code class=\"language-plaintext highlighter-rouge\">toLower(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#toLower(str:str):str|nil\n</code></pre>\n\n<p>converts a string to lowercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-16\">Examples</h4>\n\n<pre><code class=\"language-slug\">toLower(nil)  // =&gt; nil\ntoLower(\"\")  // =&gt; \"\"\ntoLower(\"SLUG\")  // =&gt; \"slug\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"toupperstr\"><code class=\"language-plaintext highlighter-rouge\">toUpper(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#toUpper(str:str):str|nil\n</code></pre>\n\n<p>converts a string to uppercase.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-17\">Examples</h4>\n\n<pre><code class=\"language-slug\">toUpper(nil)  // =&gt; nil\ntoUpper(\"\")  // =&gt; \"\"\ntoUpper(\"slug\")  // =&gt; \"SLUG\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"trimstr\"><code class=\"language-plaintext highlighter-rouge\">trim(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.string#trim(str:str):str|nil\nfn slug.string#trim(s:str|nil, prefix:str):str|nil\n</code></pre>\n\n<p>removes all leading and trailing occurrences of <code class=\"language-plaintext highlighter-rouge\">prefix</code> from <code class=\"language-plaintext highlighter-rouge\">s</code>.</p>\n\n<p>Repeatedly strips the prefix/suffix until neither end matches.\nNote: <code class=\"language-plaintext highlighter-rouge\">prefix</code> is stripped from both ends, not just the left.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-18\">Examples</h4>\n\n<pre><code class=\"language-slug\">trim(\"  a  \", \" \")  // =&gt; \"a\"\ntrim(\"xxaxxx\", \"x\")  // =&gt; \"a\"\ntrim(\"xxa\", \"x\")  // =&gt; \"a\"\ntrim(\"axxx\", \"x\")  // =&gt; \"a\"\ntrim(\"abxxx\", \"xx\")  // =&gt; \"abx\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.string",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-std",
      "url": "https://sluglang.org/libraries/slug-std",
      "title": "std (slug)",
      "content_html": "<h2 id=\"slugstd\">slug.std</h2>\n\n<p>slug.std — the Slug standard library</p>\n\n<p>Core utilities available to all Slug programs. Provides type constants,\nthe canonical <code class=\"language-plaintext highlighter-rouge\">Error</code> struct, collection transforms, type conversions,\nstring formatting, and common functional helpers.</p>\n\n<h2 id=\"type-constants\">Type constants</h2>\n\n<p>Type symbols returned by <code class=\"language-plaintext highlighter-rouge\">type()</code> are available as named constants:\n<code class=\"language-plaintext highlighter-rouge\">NIL_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">BOOLEAN_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">NUMBER_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">STRING_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">LIST_TYPE</code>,\n<code class=\"language-plaintext highlighter-rouge\">MAP_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">BYTES_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">FUNCTION_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">TASK_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">STRUCT_TYPE</code>,\n<code class=\"language-plaintext highlighter-rouge\">SYMBOL_TYPE</code>, <code class=\"language-plaintext highlighter-rouge\">ERROR_TYPE</code>.</p>\n\n<p>Use these with pinned patterns for readable type dispatch:</p>\n<pre><code class=\"language-slug\">match type(v) {\n  ^STRING_TYPE =&gt; ...\n  ^LIST_TYPE   =&gt; ...\n  _            =&gt; ...\n}\n</code></pre>\n\n<h2 id=\"error-handling\">Error handling</h2>\n\n<p>The canonical error shape is <code class=\"language-plaintext highlighter-rouge\">Error{ type, msg, code, data, cause }</code>.\nConstruct errors with <code class=\"language-plaintext highlighter-rouge\">Error{ type: \"MyError\", msg: \"something went wrong\" }</code>\nand throw them with <code class=\"language-plaintext highlighter-rouge\">throw</code>. There is no try/catch — handle errors via\n<code class=\"language-plaintext highlighter-rouge\">match</code> on return values or <code class=\"language-plaintext highlighter-rouge\">defer onerror</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#boolean_type\">BOOLEAN_TYPE</a></li>\n  <li><a href=\"#bytes_type\">BYTES_TYPE</a></li>\n  <li><a href=\"#error_type\">ERROR_TYPE</a></li>\n  <li><a href=\"#function_type\">FUNCTION_TYPE</a></li>\n  <li><a href=\"#list_type\">LIST_TYPE</a></li>\n  <li><a href=\"#map_type\">MAP_TYPE</a></li>\n  <li><a href=\"#nil_type\">NIL_TYPE</a></li>\n  <li><a href=\"#number_type\">NUMBER_TYPE</a></li>\n  <li><a href=\"#string_type\">STRING_TYPE</a></li>\n  <li><a href=\"#struct_type\">STRUCT_TYPE</a></li>\n  <li><a href=\"#symbol_type\">SYMBOL_TYPE</a></li>\n  <li><a href=\"#task_type\">TASK_TYPE</a></li>\n  <li><a href=\"#error\">Error</a></li>\n  <li><a href=\"#comparea-b\"><code class=\"language-plaintext highlighter-rouge\">compare(a, b)</code></a></li>\n  <li><a href=\"#computemap-key-f\"><code class=\"language-plaintext highlighter-rouge\">compute(map, key, f)</code></a></li>\n  <li><a href=\"#counterstart\"><code class=\"language-plaintext highlighter-rouge\">counter(start)</code></a></li>\n  <li><a href=\"#equalsm1-m2\"><code class=\"language-plaintext highlighter-rouge\">equals(m1, m2)</code></a></li>\n  <li><a href=\"#filtervs-f-acc\"><code class=\"language-plaintext highlighter-rouge\">filter(vs, f, acc)</code></a></li>\n  <li><a href=\"#findtxs-f\"><code class=\"language-plaintext highlighter-rouge\">find&lt;T&gt;(xs, f)</code></a></li>\n  <li><a href=\"#flatmapvs-f\"><code class=\"language-plaintext highlighter-rouge\">flatMap(vs, f)</code></a></li>\n  <li><a href=\"#fmtstr-args\"><code class=\"language-plaintext highlighter-rouge\">fmt(str, args)</code></a></li>\n  <li><a href=\"#getmap-key\"><code class=\"language-plaintext highlighter-rouge\">get(map, key)</code></a></li>\n  <li><a href=\"#ifnilv-f\"><code class=\"language-plaintext highlighter-rouge\">ifNil(v, f)</code></a></li>\n  <li><a href=\"#isdefinedvarname\"><code class=\"language-plaintext highlighter-rouge\">isDefined(varName)</code></a></li>\n  <li><a href=\"#isstructinstancev\"><code class=\"language-plaintext highlighter-rouge\">isStructInstance(v)</code></a></li>\n  <li><a href=\"#keysmap\"><code class=\"language-plaintext highlighter-rouge\">keys(map)</code></a></li>\n  <li><a href=\"#labelsymbol\"><code class=\"language-plaintext highlighter-rouge\">label(symbol)</code></a></li>\n  <li><a href=\"#mapvs-f-acc\"><code class=\"language-plaintext highlighter-rouge\">map(vs, f, acc)</code></a></li>\n  <li><a href=\"#modulename\"><code class=\"language-plaintext highlighter-rouge\">moduleName()</code></a></li>\n  <li><a href=\"#nonnilv-f-default\"><code class=\"language-plaintext highlighter-rouge\">nonNil(v, f, default)</code></a></li>\n  <li><a href=\"#parsenumbervalue\"><code class=\"language-plaintext highlighter-rouge\">parseNumber(value)</code></a></li>\n  <li><a href=\"#putmap-key-value\"><code class=\"language-plaintext highlighter-rouge\">put(map, key, value)</code></a></li>\n  <li><a href=\"#rangestart-end-step-acc\"><code class=\"language-plaintext highlighter-rouge\">range(start, end, step, acc)</code></a></li>\n  <li><a href=\"#reducevs-v-f\"><code class=\"language-plaintext highlighter-rouge\">reduce(vs, v, f)</code></a></li>\n  <li><a href=\"#removemap-key\"><code class=\"language-plaintext highlighter-rouge\">remove(map, key)</code></a></li>\n  <li><a href=\"#structequalsm1-m2\"><code class=\"language-plaintext highlighter-rouge\">structEquals(m1, m2)</code></a></li>\n  <li><a href=\"#swaplist-index1-index2\"><code class=\"language-plaintext highlighter-rouge\">swap(list, index1, index2)</code></a></li>\n  <li><a href=\"#symname\"><code class=\"language-plaintext highlighter-rouge\">sym(name)</code></a></li>\n  <li><a href=\"#thenm-f\"><code class=\"language-plaintext highlighter-rouge\">then(m, f)</code></a></li>\n  <li><a href=\"#tobooleanv\"><code class=\"language-plaintext highlighter-rouge\">toBoolean(v)</code></a></li>\n  <li><a href=\"#tonumberv\"><code class=\"language-plaintext highlighter-rouge\">toNumber(v)</code></a></li>\n  <li><a href=\"#tostringv\"><code class=\"language-plaintext highlighter-rouge\">toString(v)</code></a></li>\n  <li><a href=\"#typeval\"><code class=\"language-plaintext highlighter-rouge\">type(val)</code></a></li>\n  <li><a href=\"#updatelist-index-value\"><code class=\"language-plaintext highlighter-rouge\">update(list, index, value)</code></a></li>\n  <li><a href=\"#zeroifabovea-b\"><code class=\"language-plaintext highlighter-rouge\">zeroIfAbove(a, b)</code></a></li>\n  <li><a href=\"#ziplst1-lst2-acc\"><code class=\"language-plaintext highlighter-rouge\">zip(lst1, lst2, acc)</code></a></li>\n  <li><a href=\"#zipwitha-blst-f\"><code class=\"language-plaintext highlighter-rouge\">zipWith&lt;A, B&gt;(lst, f)</code></a></li>\n  <li><a href=\"#zipwithindextlst\"><code class=\"language-plaintext highlighter-rouge\">zipWithIndex&lt;T&gt;(lst)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"boolean_type\"><code class=\"language-plaintext highlighter-rouge\">BOOLEAN_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#BOOLEAN_TYPE\n</code></pre>\n\n<h4 id=\"bytes_type\"><code class=\"language-plaintext highlighter-rouge\">BYTES_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#BYTES_TYPE\n</code></pre>\n\n<h4 id=\"error_type\"><code class=\"language-plaintext highlighter-rouge\">ERROR_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#ERROR_TYPE\n</code></pre>\n\n<h4 id=\"function_type\"><code class=\"language-plaintext highlighter-rouge\">FUNCTION_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#FUNCTION_TYPE\n</code></pre>\n\n<h4 id=\"list_type\"><code class=\"language-plaintext highlighter-rouge\">LIST_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#LIST_TYPE\n</code></pre>\n\n<h4 id=\"map_type\"><code class=\"language-plaintext highlighter-rouge\">MAP_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#MAP_TYPE\n</code></pre>\n\n<h4 id=\"nil_type\"><code class=\"language-plaintext highlighter-rouge\">NIL_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#NIL_TYPE\n</code></pre>\n\n<p>Constant for NIL_TYPE, returned by <code class=\"language-plaintext highlighter-rouge\">type(nil)</code></p>\n\n<h4 id=\"number_type\"><code class=\"language-plaintext highlighter-rouge\">NUMBER_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#NUMBER_TYPE\n</code></pre>\n\n<h4 id=\"string_type\"><code class=\"language-plaintext highlighter-rouge\">STRING_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#STRING_TYPE\n</code></pre>\n\n<h4 id=\"struct_type\"><code class=\"language-plaintext highlighter-rouge\">STRUCT_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#STRUCT_TYPE\n</code></pre>\n\n<h4 id=\"symbol_type\"><code class=\"language-plaintext highlighter-rouge\">SYMBOL_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#SYMBOL_TYPE\n</code></pre>\n\n<h4 id=\"task_type\"><code class=\"language-plaintext highlighter-rouge\">TASK_TYPE</code></h4>\n\n<pre><code class=\"language-slug\">sym slug.std#TASK_TYPE\n</code></pre>\n\n<h3 id=\"structs\">Structs</h3>\n\n<h4 id=\"error\"><code class=\"language-plaintext highlighter-rouge\">Error</code></h4>\n<pre><code class=\"language-slug\">struct slug.std#Error{type:str = \"Error\", msg:str, code = nil, data = nil, cause = nil}\n</code></pre>\n\n<p>Standard error payload shape for idiomatic error handling.</p>\n\n<p>Always set <code class=\"language-plaintext highlighter-rouge\">type</code> to a stable PascalCase string identifying the error kind\n(e.g. <code class=\"language-plaintext highlighter-rouge\">\"TypeError\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"NotFoundError\"</code>). Use <code class=\"language-plaintext highlighter-rouge\">cause</code> to chain errors.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">type</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"Error\"</code></td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">msg</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">cause</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n      <td> </td>\n    </tr>\n  </tbody>\n</table>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"comparea-b\"><code class=\"language-plaintext highlighter-rouge\">compare(a, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#compare(a, b):num\n</code></pre>\n\n<p>returns -1 if <code class=\"language-plaintext highlighter-rouge\">a &lt; b</code>, 1 if <code class=\"language-plaintext highlighter-rouge\">a &gt; b</code>, 0 if equal.</p>\n\n<p>Compatible with sort comparator contracts.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n\n<hr />\n\n<h4 id=\"computemap-key-f\"><code class=\"language-plaintext highlighter-rouge\">compute(map, key, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#compute(map:map, key, f):map\n</code></pre>\n\n<p>applies <code class=\"language-plaintext highlighter-rouge\">f(key, currentValue)</code> to the value at <code class=\"language-plaintext highlighter-rouge\">key</code> and returns the updated map.</p>\n\n<p>If <code class=\"language-plaintext highlighter-rouge\">key</code> is absent, <code class=\"language-plaintext highlighter-rouge\">currentValue</code> is <code class=\"language-plaintext highlighter-rouge\">nil</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">compute({:k: 1}, :k, function group: [{|| 2 2 false} =&gt; fn(k, v) { &lt;vm bytecode&gt; }])  // =&gt; {:k: 2}\ncompute({}, :k, function group: [{|| 2 2 false} =&gt; fn(k, v) { &lt;vm bytecode&gt; }])  // =&gt; {:k: true}\n</code></pre>\n\n<hr />\n\n<h4 id=\"counterstart\"><code class=\"language-plaintext highlighter-rouge\">counter(start)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#counter(start:num = 0):fn:&lt;num&gt;\n</code></pre>\n\n<p>returns a function that increments and returns a counter on each call.</p>\n\n<p>The counter starts at <code class=\"language-plaintext highlighter-rouge\">start</code>. Each call returns the next value.</p>\n\n<pre><code class=\"language-slug\">val c = counter(0)\nc()  // =&gt; 0\nc()  // =&gt; 1\nc()  // =&gt; 2\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">start</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"equalsm1-m2\"><code class=\"language-plaintext highlighter-rouge\">equals(m1, m2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#equals(m1:map, m2:map):bool\nfn slug.std#equals(v1, v2):bool\nfn slug.std#equals(a:list, b:list, idx:num = 0):bool\n</code></pre>\n\n<p>deep equality for maps, recursively comparing values for all keys.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">m1</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">m2</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">equals(nil, nil)  // =&gt; false\nequals({}, nil)  // =&gt; false\nequals(nil, {})  // =&gt; false\nequals({}, {})  // =&gt; true\nequals({:k1: 1}, {:k1: 1})  // =&gt; true\nequals({:k1: 1}, {})  // =&gt; false\nequals({:k1: 1}, {:k2: 2})  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"filtervs-f-acc\"><code class=\"language-plaintext highlighter-rouge\">filter(vs, f, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#filter(vs:list, f:fn, acc:list = []):list\n</code></pre>\n\n<p>returns a new list containing only elements for which <code class=\"language-plaintext highlighter-rouge\">f</code> returns true.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">vs</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>list</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">filter([1, 2, 3, 4], function group: [{| 1 1 false} =&gt; fn(v) { &lt;vm bytecode&gt; }])  // =&gt; [2, 4]\n</code></pre>\n\n<hr />\n\n<h4 id=\"findtxs-f\"><code class=\"language-plaintext highlighter-rouge\">find&lt;T&gt;(xs, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#find&lt;T&gt;(xs:list&lt;T&gt;, f:fn&lt;bool, T&gt;):T|nil\n</code></pre>\n\n<p>returns the first element of <code class=\"language-plaintext highlighter-rouge\">xs</code> for which <code class=\"language-plaintext highlighter-rouge\">f</code> returns true, or <code class=\"language-plaintext highlighter-rouge\">nil</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">xs</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn&lt;bool, T&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"flatmapvs-f\"><code class=\"language-plaintext highlighter-rouge\">flatMap(vs, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#flatMap(vs:list, f:fn):list\n</code></pre>\n\n<p>applies <code class=\"language-plaintext highlighter-rouge\">f</code> to each element of <code class=\"language-plaintext highlighter-rouge\">vs</code> and concatenates the resulting lists.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">f</code> must return a list or a single value (which is treated as a one-element list).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">vs</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">flatMap([1, 2, 3], function group: [{| 1 1 false} =&gt; fn(n) { &lt;vm bytecode&gt; }])  // =&gt; [1, 1, 2, 2, 3, 3]\nflatMap([1, 2, 3], function group: [{| 1 1 false} =&gt; fn(n) { &lt;vm bytecode&gt; }])  // =&gt; [2]\n</code></pre>\n\n<hr />\n\n<h4 id=\"fmtstr-args\"><code class=\"language-plaintext highlighter-rouge\">fmt(str, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#fmt(str:str, ...args):str\n</code></pre>\n\n<p>formats a string using <code class=\"language-plaintext highlighter-rouge\">{}</code> placeholders and optional format specifiers.</p>\n\n<p>Placeholders:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">{}</code> — next positional argument</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{0}</code>, <code class=\"language-plaintext highlighter-rouge\">{1}</code> — explicit argument index</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:.2f}</code> — float with 2 decimal places</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:d}</code> — integer (truncates decimals)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:,}</code> — number with thousands separators</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:.1%}</code> — percentage with 1 decimal place</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:&gt;8}</code> — right-align in width 8</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:&lt;10s}</code> — left-align string in width 10</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:^10s}</code> — centre string in width 10</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">\\{</code> and <code class=\"language-plaintext highlighter-rouge\">\\}</code> — literal braces</li>\n</ul>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">fmt(\"Hello {}\", \"Slug\")  // =&gt; \"Hello Slug\"\nfmt(\"{1} then {0}\", \"A\", \"B\")  // =&gt; \"B then A\"\nfmt(\"x={:.2f} y={:.2f}\", 1.2, 3.4)  // =&gt; \"x=1.20 y=3.40\"\nfmt(\"{:d}\", 12.5)  // =&gt; \"12\"\nfmt(\"{:,}\", 1234567)  // =&gt; \"1,234,567\"\nfmt(\"{:.1%}\", 0.1234)  // =&gt; \"12.3%\"\nfmt(\"value=\\{x\\}\")  // =&gt; \"value={x}\"\nfmt(\"|{:&gt;8}|\", 12.3)  // =&gt; \"|    12.3|\"\nfmt(\"|{:&lt;10s}|\", \"Slug\")  // =&gt; \"|Slug      |\"\nfmt(\"|{:^10s}|\", \"Slug\")  // =&gt; \"|   Slug   |\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"getmap-key\"><code class=\"language-plaintext highlighter-rouge\">get(map, key)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#get(map:map, key):any\n</code></pre>\n\n<p>returns the value for <code class=\"language-plaintext highlighter-rouge\">key</code> in <code class=\"language-plaintext highlighter-rouge\">map</code>, or <code class=\"language-plaintext highlighter-rouge\">nil</code> if absent.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-5\">Examples</h4>\n\n<pre><code class=\"language-slug\">get({}, :k)  // =&gt; nil\nget({:k: 1}, :k)  // =&gt; 1\n</code></pre>\n\n<hr />\n\n<h4 id=\"ifnilv-f\"><code class=\"language-plaintext highlighter-rouge\">ifNil(v, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#ifNil(v, f:fn):any\nfn slug.std#ifNil(v, default):any\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">default</code> if <code class=\"language-plaintext highlighter-rouge\">v</code> is <code class=\"language-plaintext highlighter-rouge\">nil</code>; returns <code class=\"language-plaintext highlighter-rouge\">v</code> otherwise.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isdefinedvarname\"><code class=\"language-plaintext highlighter-rouge\">isDefined(varName)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#isDefined(varName:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">varName</code> is defined as a binding in the current scope.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">varName</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-6\">Examples</h4>\n\n<pre><code class=\"language-slug\">isDefined(\"type\")  // =&gt; true\nisDefined(\"__not_defined__\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"isstructinstancev\"><code class=\"language-plaintext highlighter-rouge\">isStructInstance(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#isStructInstance(v):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">v</code> is an instance of a struct (not a struct schema).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"keysmap\"><code class=\"language-plaintext highlighter-rouge\">keys(map)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#keys(map):list\n</code></pre>\n\n<p>returns a list of all keys in a map.</p>\n\n<p>Key order is not guaranteed. For sorted keys use <code class=\"language-plaintext highlighter-rouge\">slug.list#sort</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-7\">Examples</h4>\n\n<pre><code class=\"language-slug\">keys({})  // =&gt; []\nkeys({:k: 1})  // =&gt; [:k]\n</code></pre>\n\n<hr />\n\n<h4 id=\"labelsymbol\"><code class=\"language-plaintext highlighter-rouge\">label(symbol)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#label(symbol:sym):str\n</code></pre>\n\n<p>returns the string label of a symbol.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">symbol</code></td>\n      <td>sym</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-8\">Examples</h4>\n\n<pre><code class=\"language-slug\">label(:foo)  // =&gt; \"foo\"\nlabel(:\"a b\")  // =&gt; \"a b\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"mapvs-f-acc\"><code class=\"language-plaintext highlighter-rouge\">map(vs, f, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#map(vs:list, f:fn, acc = []):list\n</code></pre>\n\n<p>applies <code class=\"language-plaintext highlighter-rouge\">f</code> to each element of <code class=\"language-plaintext highlighter-rouge\">vs</code> and returns the resulting list.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">vs</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-9\">Examples</h4>\n\n<pre><code class=\"language-slug\">map([1, 2], function group: [{| 1 1 false} =&gt; fn(n) { &lt;vm bytecode&gt; }])  // =&gt; [2, 4]\n</code></pre>\n\n<hr />\n\n<h4 id=\"modulename\"><code class=\"language-plaintext highlighter-rouge\">moduleName()</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#moduleName():str\n</code></pre>\n\n<p>returns the full name of the current module.</p>\n\n<hr />\n\n<h4 id=\"nonnilv-f-default\"><code class=\"language-plaintext highlighter-rouge\">nonNil(v, f, default)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#nonNil(v, f:fn, default = nil):any\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">default</code> if <code class=\"language-plaintext highlighter-rouge\">v</code> is <code class=\"language-plaintext highlighter-rouge\">nil</code>; calls <code class=\"language-plaintext highlighter-rouge\">f(v)</code> and returns the result otherwise.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">default</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"parsenumbervalue\"><code class=\"language-plaintext highlighter-rouge\">parseNumber(value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#parseNumber(value:str):num\n</code></pre>\n\n<p>parses a numeric string to a number. Throws on invalid input.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-10\">Examples</h4>\n\n<pre><code class=\"language-slug\">parseNumber(\"1\")  // =&gt; 1\nparseNumber(\"1.1\")  // =&gt; 1.1\n</code></pre>\n\n<hr />\n\n<h4 id=\"putmap-key-value\"><code class=\"language-plaintext highlighter-rouge\">put(map, key, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#put(map:map, key, value):map\n</code></pre>\n\n<p>returns a new map with <code class=\"language-plaintext highlighter-rouge\">key</code> set to <code class=\"language-plaintext highlighter-rouge\">value</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-11\">Examples</h4>\n\n<pre><code class=\"language-slug\">put({}, :k, \"v\")  // =&gt; {:k: v}\n</code></pre>\n\n<hr />\n\n<h4 id=\"rangestart-end-step-acc\"><code class=\"language-plaintext highlighter-rouge\">range(start, end, step, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#range(start:num, end:num, step:num = 1, acc:list&lt;num&gt; = []):list&lt;num&gt;\n</code></pre>\n\n<p>generates a list of numbers from <code class=\"language-plaintext highlighter-rouge\">start</code> (inclusive) to <code class=\"language-plaintext highlighter-rouge\">end</code> (exclusive) by <code class=\"language-plaintext highlighter-rouge\">step</code>.</p>\n\n<p>Returns an empty list if the range direction contradicts the step sign.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">start</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">end</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">step</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>list<num></num></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-12\">Examples</h4>\n\n<pre><code class=\"language-slug\">range(0, 0)  // =&gt; []\nrange(0, 2)  // =&gt; [0, 1]\nrange(0, 6, 2)  // =&gt; [0, 2, 4]\nrange(0, 6, -2)  // =&gt; []\nrange(6, 0, -2)  // =&gt; [6, 4, 2]\n</code></pre>\n\n<hr />\n\n<h4 id=\"reducevs-v-f\"><code class=\"language-plaintext highlighter-rouge\">reduce(vs, v, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#reduce(vs:list, v, f:fn):any\n</code></pre>\n\n<p>folds <code class=\"language-plaintext highlighter-rouge\">vs</code> left with <code class=\"language-plaintext highlighter-rouge\">f</code>, starting from initial value <code class=\"language-plaintext highlighter-rouge\">v</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">vs</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-13\">Examples</h4>\n\n<pre><code class=\"language-slug\">reduce([], 0, function group: [{|| 2 2 false} =&gt; fn(a, b) { &lt;vm bytecode&gt; }])  // =&gt; 0\nreduce([1, 2, 3], 0, function group: [{|| 2 2 false} =&gt; fn(a, b) { &lt;vm bytecode&gt; }])  // =&gt; 6\nreduce([1, 2, 3], 9, function group: [{|| 2 2 false} =&gt; fn(a, b) { &lt;vm bytecode&gt; }])  // =&gt; 15\n</code></pre>\n\n<hr />\n\n<h4 id=\"removemap-key\"><code class=\"language-plaintext highlighter-rouge\">remove(map, key)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#remove(map:map, key):map\n</code></pre>\n\n<p>returns a new map with <code class=\"language-plaintext highlighter-rouge\">key</code> removed. No-op if key is absent.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">key</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-14\">Examples</h4>\n\n<pre><code class=\"language-slug\">remove({}, :k)  // =&gt; {}\nremove({:k: 1}, :k)  // =&gt; {}\nremove({:k: 1}, :j)  // =&gt; {:k: 1}\n</code></pre>\n\n<hr />\n\n<h4 id=\"structequalsm1-m2\"><code class=\"language-plaintext highlighter-rouge\">structEquals(m1, m2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#structEquals(m1, m2):bool\n</code></pre>\n\n<p>deep equality for struct types and struct instances.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">false</code> if either value is <code class=\"language-plaintext highlighter-rouge\">nil</code>, if their types differ, or\nif neither is a struct instance or struct schema.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">m1</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">m2</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"swaplist-index1-index2\"><code class=\"language-plaintext highlighter-rouge\">swap(list, index1, index2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#swap(list:list, index1:num, index2:num):list\n</code></pre>\n\n<p>returns a new list with elements at <code class=\"language-plaintext highlighter-rouge\">index1</code> and <code class=\"language-plaintext highlighter-rouge\">index2</code> swapped.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index1</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index2</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-15\">Examples</h4>\n\n<pre><code class=\"language-slug\">swap([1, 2], 0, 1)  // =&gt; [2, 1]\n</code></pre>\n\n<hr />\n\n<h4 id=\"symname\"><code class=\"language-plaintext highlighter-rouge\">sym(name)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#sym(name:str):sym\n</code></pre>\n\n<p>converts a string to a symbol.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-16\">Examples</h4>\n\n<pre><code class=\"language-slug\">sym(\"foo\")  // =&gt; :foo\nsym(\"foo bar\")  // =&gt; :\"foo bar\"\nsym(\"Content-Type\")  // =&gt; :\"Content-Type\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"thenm-f\"><code class=\"language-plaintext highlighter-rouge\">then(m, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#then(m, f:fn):any\n</code></pre>\n\n<p>applies <code class=\"language-plaintext highlighter-rouge\">f</code> to <code class=\"language-plaintext highlighter-rouge\">m</code> and returns the result. Useful for call-chain threading.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">m /&gt; then(fn(v) { ... })</code> is equivalent to <code class=\"language-plaintext highlighter-rouge\">(fn(v) { ... })(m)</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">m</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-17\">Examples</h4>\n\n<pre><code class=\"language-slug\">then(1, function group: [{| 1 1 false} =&gt; fn(v) { &lt;vm bytecode&gt; }])  // =&gt; 2\nthen({:n: Slug}, function group: [{| 1 1 false} =&gt; fn(v) { &lt;vm bytecode&gt; }])  // =&gt; \"Slug\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"tobooleanv\"><code class=\"language-plaintext highlighter-rouge\">toBoolean(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#toBoolean(v):bool\n</code></pre>\n\n<p>converts a value to <code class=\"language-plaintext highlighter-rouge\">bool</code>.</p>\n\n<p>Numeric <code class=\"language-plaintext highlighter-rouge\">1</code> → <code class=\"language-plaintext highlighter-rouge\">true</code>, <code class=\"language-plaintext highlighter-rouge\">0</code> → <code class=\"language-plaintext highlighter-rouge\">false</code>. Strings <code class=\"language-plaintext highlighter-rouge\">\"true\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"yes\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"1\"</code>,\n<code class=\"language-plaintext highlighter-rouge\">\"TRUE\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"YES\"</code> → <code class=\"language-plaintext highlighter-rouge\">true</code>; <code class=\"language-plaintext highlighter-rouge\">\"false\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"no\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"0\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"FALSE\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"NO\"</code>\n→ <code class=\"language-plaintext highlighter-rouge\">false</code>. Other string values throw <code class=\"language-plaintext highlighter-rouge\">TypeError</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:TypeError}</code></p>\n\n<h4 id=\"examples-18\">Examples</h4>\n\n<pre><code class=\"language-slug\">toBoolean(nil)  // =&gt; false\ntoBoolean(0)  // =&gt; false\ntoBoolean(1)  // =&gt; true\ntoBoolean(true)  // =&gt; true\ntoBoolean(false)  // =&gt; false\ntoBoolean(\"true\")  // =&gt; true\ntoBoolean(\"yes\")  // =&gt; true\ntoBoolean(\"1\")  // =&gt; true\ntoBoolean(\"false\")  // =&gt; false\ntoBoolean(\"no\")  // =&gt; false\ntoBoolean(\"0\")  // =&gt; false\n</code></pre>\n\n<hr />\n\n<h4 id=\"tonumberv\"><code class=\"language-plaintext highlighter-rouge\">toNumber(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#toNumber(v):num|nil\n</code></pre>\n\n<p>converts a value to <code class=\"language-plaintext highlighter-rouge\">num</code>.</p>\n\n<p>Passes through numbers, parses numeric strings, returns <code class=\"language-plaintext highlighter-rouge\">nil</code> for <code class=\"language-plaintext highlighter-rouge\">nil</code>.\nThrows <code class=\"language-plaintext highlighter-rouge\">TypeError</code> for other types.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:TypeError}</code></p>\n\n<h4 id=\"examples-19\">Examples</h4>\n\n<pre><code class=\"language-slug\">toNumber(nil)  // =&gt; nil\ntoNumber(1)  // =&gt; 1\ntoNumber(1.1)  // =&gt; 1.1\ntoNumber(\"1\")  // =&gt; 1\ntoNumber(\"1.1\")  // =&gt; 1.1\n</code></pre>\n\n<hr />\n\n<h4 id=\"tostringv\"><code class=\"language-plaintext highlighter-rouge\">toString(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#toString(v):str|nil\n</code></pre>\n\n<p>converts a value to a string representation.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> for <code class=\"language-plaintext highlighter-rouge\">nil</code>, passes through strings, and uses string\nconcatenation (<code class=\"language-plaintext highlighter-rouge\">v + \"\"</code>) for all other types.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-20\">Examples</h4>\n\n<pre><code class=\"language-slug\">toString(nil)  // =&gt; nil\ntoString(\"str\")  // =&gt; \"str\"\ntoString(1.1)  // =&gt; \"1.1\"\ntoString(true)  // =&gt; \"true\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"typeval\"><code class=\"language-plaintext highlighter-rouge\">type(val)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#type(val):sym\n</code></pre>\n\n<p>returns a symbol indicating the runtime type of <code class=\"language-plaintext highlighter-rouge\">val</code>.</p>\n\n<p>Result is one of the <code class=\"language-plaintext highlighter-rouge\">*_TYPE</code> constants exported by this module.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">val</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-21\">Examples</h4>\n\n<pre><code class=\"language-slug\">type(nil)  // =&gt; :nil\ntype(true)  // =&gt; :bool\ntype(1)  // =&gt; :number\ntype(1.1)  // =&gt; :number\ntype(\"Hello Slug!\")  // =&gt; :string\ntype([1, 2])  // =&gt; :list\ntype({:key: value})  // =&gt; :map\ntype(0x\"ff\")  // =&gt; :bytes\ntype(function group: [{| 1 1 false} =&gt; fn(a) { &lt;vm bytecode&gt; }])  // =&gt; :function\n</code></pre>\n\n<hr />\n\n<h4 id=\"updatelist-index-value\"><code class=\"language-plaintext highlighter-rouge\">update(list, index, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#update(list:list, index:num, value):list\n</code></pre>\n\n<p>returns a new list with the element at <code class=\"language-plaintext highlighter-rouge\">index</code> replaced by <code class=\"language-plaintext highlighter-rouge\">value</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-22\">Examples</h4>\n\n<pre><code class=\"language-slug\">update([1, 2, 3], 1, 99)  // =&gt; [1, 99, 3]\n</code></pre>\n\n<hr />\n\n<h4 id=\"zeroifabovea-b\"><code class=\"language-plaintext highlighter-rouge\">zeroIfAbove(a, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#zeroIfAbove(a:num, b:num):num\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">a</code> if <code class=\"language-plaintext highlighter-rouge\">a &lt; b</code>, otherwise returns <code class=\"language-plaintext highlighter-rouge\">0</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-23\">Examples</h4>\n\n<pre><code class=\"language-slug\">zeroIfAbove(1, 1)  // =&gt; 0\nzeroIfAbove(1, 2)  // =&gt; 1\nzeroIfAbove(2, 1)  // =&gt; 0\n</code></pre>\n\n<hr />\n\n<h4 id=\"ziplst1-lst2-acc\"><code class=\"language-plaintext highlighter-rouge\">zip(lst1, lst2, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#zip(lst1:list, lst2:list, acc = []):list&lt;[any,any]&gt;\n</code></pre>\n\n<p>zips two lists into a list of <code class=\"language-plaintext highlighter-rouge\">[a, b]</code> pairs.</p>\n\n<p>Stops at the shorter list. Extra elements from the longer list are discarded.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst1</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst2</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-24\">Examples</h4>\n\n<pre><code class=\"language-slug\">zip([], [])  // =&gt; []\nzip([1], [])  // =&gt; []\nzip([], [1])  // =&gt; []\nzip([1], [2])  // =&gt; [[1, 2]]\n</code></pre>\n\n<hr />\n\n<h4 id=\"zipwitha-blst-f\"><code class=\"language-plaintext highlighter-rouge\">zipWith&lt;A, B&gt;(lst, f)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#zipWith&lt;A, B&gt;(lst:list&lt;A&gt;, f:&lt;B&gt;):list&lt;[A,B]&gt;\n</code></pre>\n\n<p>zips a list with the results of calling <code class=\"language-plaintext highlighter-rouge\">f</code> for each element.</p>\n\n<p>Returns a list of <code class=\"language-plaintext highlighter-rouge\">[element, f()]</code> pairs. <code class=\"language-plaintext highlighter-rouge\">f</code> is called once per element.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst</code></td>\n      <td>list<a></a></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">f</code></td>\n      <td><b></b></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-25\">Examples</h4>\n\n<pre><code class=\"language-slug\">zipWith([\"a\", \"b\"], function group: [{ 0 0 false} =&gt; fn() { &lt;vm bytecode&gt; }])  // =&gt; [[\"a\", 1], [\"b\", 1]]\n</code></pre>\n\n<hr />\n\n<h4 id=\"zipwithindextlst\"><code class=\"language-plaintext highlighter-rouge\">zipWithIndex&lt;T&gt;(lst)</code></h4>\n<pre><code class=\"language-slug\">fn slug.std#zipWithIndex&lt;T&gt;(lst:list&lt;T&gt;):list&lt;[T,num]&gt;\n</code></pre>\n\n<p>zips a list with its zero-based indices.</p>\n\n<p>Returns a list of <code class=\"language-plaintext highlighter-rouge\">[element, index]</code> pairs.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-26\">Examples</h4>\n\n<pre><code class=\"language-slug\">zipWithIndex([])  // =&gt; []\nzipWithIndex([\"a\", \"b\"])  // =&gt; [[\"a\", 0], [\"b\", 1]]\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.std",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-regex",
      "url": "https://sluglang.org/libraries/slug-regex",
      "title": "regex (slug)",
      "content_html": "<h2 id=\"slugregex\">slug.regex</h2>\n\n<p>slug.regex — regular expression matching and extraction</p>\n\n<p>All functions accept standard regex syntax. Patterns are not compiled\nor cached — for performance-sensitive code with repeated matches on\nthe same pattern, consider pre-processing outside hot paths.</p>\n\n<p>Patterns use standard Go/RE2 syntax (no lookaheads or backreferences).</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#findallstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">findAll(str, pattern)</code></a></li>\n  <li><a href=\"#findallgroupsstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">findAllGroups(str, pattern)</code></a></li>\n  <li><a href=\"#indexofstr-pattern-index\"><code class=\"language-plaintext highlighter-rouge\">indexOf(str, pattern, index)</code></a></li>\n  <li><a href=\"#matchesstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">matches(str, pattern)</code></a></li>\n  <li><a href=\"#replaceallstr-pattern-repl\"><code class=\"language-plaintext highlighter-rouge\">replaceAll(str, pattern, repl)</code></a></li>\n  <li><a href=\"#splitstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">split(str, pattern)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"findallstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">findAll(str, pattern)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#findAll(str:str, pattern:str):list&lt;str&gt;\n</code></pre>\n\n<p>returns a list of all non-overlapping matches of <code class=\"language-plaintext highlighter-rouge\">pattern</code> in <code class=\"language-plaintext highlighter-rouge\">str</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">findAll(\"1|2|3\", \"\\d+\")  // =&gt; [\"1\", \"2\", \"3\"]\nfindAll(\"(foo)\", \"[a-z]+\")  // =&gt; [\"foo\"]\n</code></pre>\n\n<hr />\n\n<h4 id=\"findallgroupsstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">findAllGroups(str, pattern)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#findAllGroups(str:str, pattern:str):list&lt;list&lt;str&gt;&gt;\n</code></pre>\n\n<p>returns a list of all matches including capture groups.</p>\n\n<p>Each entry is a list where the first element is the full match and\nsubsequent elements are the capture group values.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">findAllGroups(\"&lt;a href=\"foo\"&gt;bar&lt;/a&gt;\", \"&lt;a href=\"(.*?)\"&gt;(.*?)&lt;/a&gt;\")  // =&gt; [[\"&lt;a href=\"foo\"&gt;bar&lt;/a&gt;\", \"foo\", \"bar\"]]\n</code></pre>\n\n<hr />\n\n<h4 id=\"indexofstr-pattern-index\"><code class=\"language-plaintext highlighter-rouge\">indexOf(str, pattern, index)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#indexOf(str:str, pattern:str, index:num = 0):[num, num]|nil\n</code></pre>\n\n<p>returns the byte index range of the first match of <code class=\"language-plaintext highlighter-rouge\">pattern</code> in <code class=\"language-plaintext highlighter-rouge\">str</code>\nstarting from <code class=\"language-plaintext highlighter-rouge\">index</code>, as <code class=\"language-plaintext highlighter-rouge\">[start, end]</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> if no match is found. The list contains the start\nand end byte indices of the full match.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">index</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"matchesstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">matches(str, pattern)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#matches(str:str, pattern:str):bool\n</code></pre>\n\n<p>returns true if the pattern matches anywhere in the string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">matches(\"test\", \"\\d+\")  // =&gt; false\nmatches(\"aaabbb\", \"b+\")  // =&gt; true\nmatches(\"123\", \"\\d+\")  // =&gt; true\n</code></pre>\n\n<hr />\n\n<h4 id=\"replaceallstr-pattern-repl\"><code class=\"language-plaintext highlighter-rouge\">replaceAll(str, pattern, repl)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#replaceAll(str:str, pattern:str, repl:str):str\n</code></pre>\n\n<p>replaces all matches of <code class=\"language-plaintext highlighter-rouge\">pattern</code> in <code class=\"language-plaintext highlighter-rouge\">str</code> with <code class=\"language-plaintext highlighter-rouge\">repl</code>.</p>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">$1</code>, <code class=\"language-plaintext highlighter-rouge\">$2</code> etc. in <code class=\"language-plaintext highlighter-rouge\">repl</code> to reference capture groups.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">repl</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">replaceAll(\"1|2|3\", \"\\d+\", \"x\")  // =&gt; \"x|x|x\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"splitstr-pattern\"><code class=\"language-plaintext highlighter-rouge\">split(str, pattern)</code></h4>\n<pre><code class=\"language-slug\">fn slug.regex#split(str:str, pattern:str):list&lt;str&gt;\n</code></pre>\n\n<p>splits <code class=\"language-plaintext highlighter-rouge\">str</code> into a list of substrings divided by matches of <code class=\"language-plaintext highlighter-rouge\">pattern</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">pattern</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">split(\"1|2|3\", \"\\|\")  // =&gt; [\"1\", \"2\", \"3\"]\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.regex",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-path",
      "url": "https://sluglang.org/libraries/slug-path",
      "title": "path (slug)",
      "content_html": "<h2 id=\"slugpath\">slug.path</h2>\n\n<p>slug.path - path utilities</p>\n\n<p>Small helpers for path composition and normalization.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#abspath\"><code class=\"language-plaintext highlighter-rouge\">abs(path)</code></a></li>\n  <li><a href=\"#cwd\"><code class=\"language-plaintext highlighter-rouge\">cwd()</code></a></li>\n  <li><a href=\"#joinparts\"><code class=\"language-plaintext highlighter-rouge\">join(parts)</code></a></li>\n  <li><a href=\"#libroot\"><code class=\"language-plaintext highlighter-rouge\">libRoot()</code></a></li>\n  <li><a href=\"#localizepath\"><code class=\"language-plaintext highlighter-rouge\">localize(path)</code></a></li>\n  <li><a href=\"#moduledir\"><code class=\"language-plaintext highlighter-rouge\">moduleDir()</code></a></li>\n  <li><a href=\"#projectroot\"><code class=\"language-plaintext highlighter-rouge\">projectRoot()</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"abspath\"><code class=\"language-plaintext highlighter-rouge\">abs(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#abs(path:str):str\n</code></pre>\n\n<p>Returns a normalized absolute path.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cwd\"><code class=\"language-plaintext highlighter-rouge\">cwd()</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#cwd():str\n</code></pre>\n\n<p>Returns the current process working directory.</p>\n\n<hr />\n\n<h4 id=\"joinparts\"><code class=\"language-plaintext highlighter-rouge\">join(parts)</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#join(...parts):str\n</code></pre>\n\n<p>Joins path elements using the platform-specific separator.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">parts</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"libroot\"><code class=\"language-plaintext highlighter-rouge\">libRoot()</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#libRoot():str\n</code></pre>\n\n<p>Returns the library root of the current module namespace.</p>\n\n<hr />\n\n<h4 id=\"localizepath\"><code class=\"language-plaintext highlighter-rouge\">localize(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#localize(path:str|nil):str|nil\n</code></pre>\n\n<p>If path starts with ‘<strong>project</strong>/’, ‘<strong>library</strong>/’ or ‘<strong>module</strong>/’ returns path new path with substitution,\nuseful for config.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str | nil</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"moduledir\"><code class=\"language-plaintext highlighter-rouge\">moduleDir()</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#moduleDir():str\n</code></pre>\n\n<p>Returns the directory of the current module file.</p>\n\n<hr />\n\n<h4 id=\"projectroot\"><code class=\"language-plaintext highlighter-rouge\">projectRoot()</code></h4>\n<pre><code class=\"language-slug\">fn slug.path#projectRoot():str\n</code></pre>\n\n<p>Returns the entry module directory.</p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.path",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-mustache",
      "url": "https://sluglang.org/libraries/slug-mustache",
      "title": "mustache (slug)",
      "content_html": "<h2 id=\"slugmustache\">slug.mustache</h2>\n\n<p>slug.mustache — Mustache template renderer</p>\n\n<p>A native Slug implementation of the Mustache spec v1.4.3, including\nthe core suites and template inheritance.</p>\n\n<h2 id=\"basic-usage\">Basic usage</h2>\n\n<pre><code class=\"language-slug\">val { render, parse } = import(\"slug.mustache\")\n\nrender(\"Hello, !\", { name: \"World\" })\n// =&gt; \"Hello, World!\"\n\nrender(\" \", { items: [\"a\", \"b\", \"c\"] })\n// =&gt; \"a b c \"\n</code></pre>\n\n<h2 id=\"tag-types\">Tag types</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Tag</th>\n      <th>Meaning</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>``</td>\n      <td>HTML-escaped variable</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">}</code></td>\n      <td>Unescaped variable</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Unescaped variable (alternate syntax)</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Section — renders if truthy/non-empty</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Inverted section — renders if falsey/empty</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Closes a section</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Partial — renders another template by name</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Template inheritance — extend a parent</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Block — defines or overrides a named region</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Comment — ignored</td>\n    </tr>\n    <tr>\n      <td>``</td>\n      <td>Set delimiters</td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"partials\">Partials</h2>\n\n<p>Pass a map of <code class=\"language-plaintext highlighter-rouge\">name -&gt; template_string</code> as the <code class=\"language-plaintext highlighter-rouge\">partials</code> argument.\nPartials inherit the current context and are resolved at render time.</p>\n\n<h2 id=\"template-inheritance\">Template inheritance</h2>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">...</code> to extend a parent template.\nOverride named blocks with <code class=\"language-plaintext highlighter-rouge\">...</code>.</p>\n\n<h2 id=\"performance\">Performance</h2>\n\n<p>For templates rendered multiple times, parse once and pass the AST\nto <code class=\"language-plaintext highlighter-rouge\">render</code> or <code class=\"language-plaintext highlighter-rouge\">renderCached</code> to avoid repeated parsing.\n<code class=\"language-plaintext highlighter-rouge\">renderCached</code> additionally caches parsed partials across calls.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#parsetemplate\"><code class=\"language-plaintext highlighter-rouge\">parse(template)</code></a></li>\n  <li><a href=\"#rendertemplateorast-data-partials\"><code class=\"language-plaintext highlighter-rouge\">render(templateOrAst, data, partials)</code></a></li>\n  <li><a href=\"#rendercachedtemplateorast-data-partials-cache\"><code class=\"language-plaintext highlighter-rouge\">renderCached(templateOrAst, data, partials, cache)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"parsetemplate\"><code class=\"language-plaintext highlighter-rouge\">parse(template)</code></h4>\n<pre><code class=\"language-slug\">fn slug.mustache#parse(template:str):any\n</code></pre>\n\n<p>parses a Mustache template string into an AST.</p>\n\n<p>The returned AST can be passed directly to <code class=\"language-plaintext highlighter-rouge\">render</code> or <code class=\"language-plaintext highlighter-rouge\">renderCached</code>\nto avoid re-parsing on repeated renders. The AST shape is an\nimplementation detail — do not rely on its structure directly.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">template</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rendertemplateorast-data-partials\"><code class=\"language-plaintext highlighter-rouge\">render(templateOrAst, data, partials)</code></h4>\n<pre><code class=\"language-slug\">fn slug.mustache#render(templateOrAst:str|map, data:map&lt;str,any&gt;, partials:map&lt;str,str|fn&lt;str, str&gt;&gt;|nil = nil):str\n</code></pre>\n\n<p>renders a Mustache template and returns the resulting HTML string.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">templateOrAst</code> may be a template string or a pre-parsed AST from <code class=\"language-plaintext highlighter-rouge\">parse</code>.\n<code class=\"language-plaintext highlighter-rouge\">partials</code> may be a map of <code class=\"language-plaintext highlighter-rouge\">name -&gt; template_string</code> or a <code class=\"language-plaintext highlighter-rouge\">fn(name) -&gt; str</code>.\nFor repeated renders of the same template with partials, prefer\n<code class=\"language-plaintext highlighter-rouge\">renderCached</code> to avoid re-parsing partials on each call.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">templateOrAst</code></td>\n      <td>str | map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>map&lt;str,any&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">partials</code></td>\n      <td>map&lt;str,str | fn&lt;str, str» | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:MustacheError}</code></p>\n\n<hr />\n\n<h4 id=\"rendercachedtemplateorast-data-partials-cache\"><code class=\"language-plaintext highlighter-rouge\">renderCached(templateOrAst, data, partials, cache)</code></h4>\n<pre><code class=\"language-slug\">fn slug.mustache#renderCached(templateOrAst:str|map, data:map&lt;str,any&gt;, partials:map&lt;str,str|fn&lt;str, str&gt;&gt;|nil = nil, cache:map = {}):map&lt;sym,str|map&gt;\n</code></pre>\n\n<p>renders a Mustache template with a partial cache for reuse across calls.</p>\n\n<p>Returns a map <code class=\"language-plaintext highlighter-rouge\">{ html: str, cache: map }</code>. Pass the returned <code class=\"language-plaintext highlighter-rouge\">cache</code>\nback on subsequent calls to avoid re-parsing partials.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">templateOrAst</code> may be a template string or a pre-parsed AST from <code class=\"language-plaintext highlighter-rouge\">parse</code>.\n<code class=\"language-plaintext highlighter-rouge\">partials</code> may be a map of <code class=\"language-plaintext highlighter-rouge\">name -&gt; template_string</code> or a <code class=\"language-plaintext highlighter-rouge\">fn(name) -&gt; str</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">templateOrAst</code></td>\n      <td>str | map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>map&lt;str,any&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">partials</code></td>\n      <td>map&lt;str,str | fn&lt;str, str» | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">cache</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:MustacheError}</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.mustache",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-meta",
      "url": "https://sluglang.org/libraries/slug-meta",
      "title": "meta (slug)",
      "content_html": "<h2 id=\"slugmeta\">slug.meta</h2>\n\n<p>slug.meta — runtime reflection and metadata</p>\n\n<p>Provides access to runtime metadata about values, tags, bindings, and\nmodules. Used by tooling such as <code class=\"language-plaintext highlighter-rouge\">slug.doc.manifest</code> and <code class=\"language-plaintext highlighter-rouge\">slug.doc.markdown</code>\nto generate documentation from live module state.</p>\n\n<h2 id=\"describe-shape\">describe shape</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">describe(value)</code> returns a map whose shape depends on the value type:</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>// function\n{ type: :fn, docs: str, tags: map, details: { params: list } }\n\n// overloaded function group\n{ type: :grp, details: { groups: list } }\n\n// struct schema\n{ type: :struct, docs: str, tags: map, details: { fields: list } }\n\n// other (str, num, sym, map, ...)\n{ type: :str | :num | :sym | :map | ... }\n</code></pre></div></div>\n\n<p>Each param/field in <code class=\"language-plaintext highlighter-rouge\">details.params</code> or <code class=\"language-plaintext highlighter-rouge\">details.fields</code> is a map:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>{ name: str, tags: map, vargs: bool, default: any }\n</code></pre></div></div>\n\n<h2 id=\"tag-format\">Tag format</h2>\n\n<p>Tags are stored as a map of tag name → list of values.\nUse <code class=\"language-plaintext highlighter-rouge\">getTag(value, \"@returns\")</code> to retrieve a tag’s values.\nA tag with no arguments is stored as <code class=\"language-plaintext highlighter-rouge\">[\"\"]</code>.</p>\n\n<h2 id=\"binding-constants\">Binding constants</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">BINDING_NAME</code>, <code class=\"language-plaintext highlighter-rouge\">BINDING_VALUE</code>, and <code class=\"language-plaintext highlighter-rouge\">BINDING_PARAMS</code> are index\nconstants for working with raw binding tuples returned by\n<code class=\"language-plaintext highlighter-rouge\">searchScopeTags</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#binding_name\">BINDING_NAME</a></li>\n  <li><a href=\"#binding_params\">BINDING_PARAMS</a></li>\n  <li><a href=\"#binding_value\">BINDING_VALUE</a></li>\n  <li><a href=\"#describevalue\"><code class=\"language-plaintext highlighter-rouge\">describe(value)</code></a></li>\n  <li><a href=\"#describesymbolmodule-symbol\"><code class=\"language-plaintext highlighter-rouge\">describeSymbol(module, symbol)</code></a></li>\n  <li><a href=\"#gettagvalue-tag\"><code class=\"language-plaintext highlighter-rouge\">getTag(value, tag)</code></a></li>\n  <li><a href=\"#hastagvalue-tag\"><code class=\"language-plaintext highlighter-rouge\">hasTag(value, tag)</code></a></li>\n  <li><a href=\"#moduledocsmodule\"><code class=\"language-plaintext highlighter-rouge\">moduleDocs(module)</code></a></li>\n  <li><a href=\"#searchmoduletagsmodule-tag-includeprivate\"><code class=\"language-plaintext highlighter-rouge\">searchModuleTags(module, tag, includePrivate)</code></a></li>\n  <li><a href=\"#searchscopetagstag\"><code class=\"language-plaintext highlighter-rouge\">searchScopeTags(tag)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"binding_name\"><code class=\"language-plaintext highlighter-rouge\">BINDING_NAME</code></h4>\n\n<pre><code class=\"language-slug\">num slug.meta#BINDING_NAME\n</code></pre>\n\n<h4 id=\"binding_params\"><code class=\"language-plaintext highlighter-rouge\">BINDING_PARAMS</code></h4>\n\n<pre><code class=\"language-slug\">num slug.meta#BINDING_PARAMS\n</code></pre>\n\n<h4 id=\"binding_value\"><code class=\"language-plaintext highlighter-rouge\">BINDING_VALUE</code></h4>\n\n<pre><code class=\"language-slug\">num slug.meta#BINDING_VALUE\n</code></pre>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"describevalue\"><code class=\"language-plaintext highlighter-rouge\">describe(value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#describe(value):map&lt;sym,any&gt;\n</code></pre>\n\n<p>returns a metadata map describing the given value.</p>\n\n<p>See module doc for the full shape. The <code class=\"language-plaintext highlighter-rouge\">type</code> field indicates the\nkind of value. Functions expose their parameter list and doc comment.\nStruct schemas expose their field list. Overloaded functions are\nrepresented as a <code class=\"language-plaintext highlighter-rouge\">:grp</code> with a <code class=\"language-plaintext highlighter-rouge\">groups</code> list of individual function\ndescriptors.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"describesymbolmodule-symbol\"><code class=\"language-plaintext highlighter-rouge\">describeSymbol(module, symbol)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#describeSymbol(module:str, symbol:str):map&lt;sym,any&gt;\n</code></pre>\n\n<p>returns metadata for a specific symbol in a module by binding name.</p>\n\n<p>unlike <code class=\"language-plaintext highlighter-rouge\">describe(import(module)[symbol])</code>, this resolves docs directly\nfrom module binding metadata so top-level <code class=\"language-plaintext highlighter-rouge\">/** ... */</code> comments are\npreserved when symbols are imported via maps.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">module</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">symbol</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"gettagvalue-tag\"><code class=\"language-plaintext highlighter-rouge\">getTag(value, tag)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#getTag(value, tag:str):list&lt;any&gt;\n</code></pre>\n\n<p>returns the list of arguments for a tag on <code class=\"language-plaintext highlighter-rouge\">value</code>.</p>\n\n<p>Returns an empty list if the tag is not present.\nReturns <code class=\"language-plaintext highlighter-rouge\">[\"\"]</code> for tags with no arguments (e.g. <code class=\"language-plaintext highlighter-rouge\">@export</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tag</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"hastagvalue-tag\"><code class=\"language-plaintext highlighter-rouge\">hasTag(value, tag)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#hasTag(value, tag:str):bool\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">true</code> if <code class=\"language-plaintext highlighter-rouge\">value</code> has the given tag annotation.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tag</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"moduledocsmodule\"><code class=\"language-plaintext highlighter-rouge\">moduleDocs(module)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#moduleDocs(module:str):str\n</code></pre>\n\n<p>returns the module-level doc comment for the given module name.</p>\n\n<p>Returns the raw comment text with markers stripped, or <code class=\"language-plaintext highlighter-rouge\">nil</code> if the\nmodule has no doc comment. The first paragraph is suitable for use\nas a short description; subsequent paragraphs provide extended docs.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">module</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"searchmoduletagsmodule-tag-includeprivate\"><code class=\"language-plaintext highlighter-rouge\">searchModuleTags(module, tag, includePrivate)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#searchModuleTags(module:str, tag:str, includePrivate:bool = false):map&lt;str,any&gt;\n</code></pre>\n\n<p>searches all exported bindings in a module for a given tag.</p>\n\n<p>Returns a map of binding name → binding value for all exported\nsymbols that have the specified tag. Pass <code class=\"language-plaintext highlighter-rouge\">includePrivate: true</code>\nto include non-exported bindings.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">module</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tag</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">includePrivate</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"searchscopetagstag\"><code class=\"language-plaintext highlighter-rouge\">searchScopeTags(tag)</code></h4>\n<pre><code class=\"language-slug\">fn slug.meta#searchScopeTags(tag:str):list&lt;[str,any,list&lt;any&gt;]&gt;\n</code></pre>\n\n<p>searches all bindings in the current scope for a given tag.</p>\n\n<p>Returns a list of binding tuples. Use <code class=\"language-plaintext highlighter-rouge\">BINDING_NAME</code>, <code class=\"language-plaintext highlighter-rouge\">BINDING_VALUE</code>,\nand <code class=\"language-plaintext highlighter-rouge\">BINDING_PARAMS</code> as indices to access tuple elements.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tag</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.meta",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-math",
      "url": "https://sluglang.org/libraries/slug-math",
      "title": "math (slug)",
      "content_html": "<h2 id=\"slugmath\">slug.math</h2>\n\n<p>slug.math — numeric utilities</p>\n\n<p>Mathematical functions for common numeric operations including\nrounding, extrema, statistics, and random number generation.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#ceiln\"><code class=\"language-plaintext highlighter-rouge\">ceil(n)</code></a></li>\n  <li><a href=\"#clampzeron\"><code class=\"language-plaintext highlighter-rouge\">clampZero(n)</code></a></li>\n  <li><a href=\"#floorn\"><code class=\"language-plaintext highlighter-rouge\">floor(n)</code></a></li>\n  <li><a href=\"#maxa-b\"><code class=\"language-plaintext highlighter-rouge\">max(a, b)</code></a></li>\n  <li><a href=\"#meanxs\"><code class=\"language-plaintext highlighter-rouge\">mean(xs)</code></a></li>\n  <li><a href=\"#mina-b\"><code class=\"language-plaintext highlighter-rouge\">min(a, b)</code></a></li>\n  <li><a href=\"#percentilesortedxs-p\"><code class=\"language-plaintext highlighter-rouge\">percentileSorted(xs, p)</code></a></li>\n  <li><a href=\"#rndrangemin-max\"><code class=\"language-plaintext highlighter-rouge\">rndRange(min, max)</code></a></li>\n  <li><a href=\"#sqrtn\"><code class=\"language-plaintext highlighter-rouge\">sqrt(n)</code></a></li>\n  <li><a href=\"#stdevxs-mean\"><code class=\"language-plaintext highlighter-rouge\">stdev(xs, mean)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"ceiln\"><code class=\"language-plaintext highlighter-rouge\">ceil(n)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#ceil(n:num):num\n</code></pre>\n\n<p>returns the least integer greater than or equal to <code class=\"language-plaintext highlighter-rouge\">n</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">n</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">ceil(1)  // =&gt; 1\nceil(1.2)  // =&gt; 2\nceil(-1.2)  // =&gt; -1\n</code></pre>\n\n<hr />\n\n<h4 id=\"clampzeron\"><code class=\"language-plaintext highlighter-rouge\">clampZero(n)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#clampZero(n:num):num\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">n</code> if it is &gt;= 0, otherwise returns 0.</p>\n\n<p>Useful for ensuring subtracted values never go negative.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">n</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"floorn\"><code class=\"language-plaintext highlighter-rouge\">floor(n)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#floor(n:num):num\n</code></pre>\n\n<p>returns the greatest integer less than or equal to <code class=\"language-plaintext highlighter-rouge\">n</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">n</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">floor(1)  // =&gt; 1\nfloor(1.2)  // =&gt; 1\nfloor(-1.2)  // =&gt; -2\n</code></pre>\n\n<hr />\n\n<h4 id=\"maxa-b\"><code class=\"language-plaintext highlighter-rouge\">max(a, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#max(a:num, ...b):num\nfn slug.math#max(a:num, b:num):num\n</code></pre>\n\n<p>returns the largest of two or more numbers.</p>\n\n<p>Accepts a variadic list of additional values beyond the required first two.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">max(1, 2, 3)  // =&gt; 3\nmax(7, 9, 8)  // =&gt; 9\nmax(4, 5, 3)  // =&gt; 5\n</code></pre>\n\n<hr />\n\n<h4 id=\"meanxs\"><code class=\"language-plaintext highlighter-rouge\">mean(xs)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#mean(xs:list&lt;num&gt;):num\n</code></pre>\n\n<p>returns the arithmetic mean of a list of numbers.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">0</code> for an empty list.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">xs</code></td>\n      <td>list<num></num></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"mina-b\"><code class=\"language-plaintext highlighter-rouge\">min(a, b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#min(a:num, ...b):num\n</code></pre>\n\n<p>returns the smallest of two or more numbers.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">a</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">min(1, 2, 3)  // =&gt; 1\nmin(4, 3, 5)  // =&gt; 3\nmin(6, 5, 4)  // =&gt; 4\n</code></pre>\n\n<hr />\n\n<h4 id=\"percentilesortedxs-p\"><code class=\"language-plaintext highlighter-rouge\">percentileSorted(xs, p)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#percentileSorted(xs:list&lt;num&gt;, p:num):num\n</code></pre>\n\n<p>returns the <code class=\"language-plaintext highlighter-rouge\">p</code>th percentile of a pre-sorted ascending list.</p>\n\n<p>Uses linear interpolation between adjacent values. The list must be\nsorted in ascending order before calling — use <code class=\"language-plaintext highlighter-rouge\">slug.list#sort</code> or\n<code class=\"language-plaintext highlighter-rouge\">slug.benchmark</code>’s internal <code class=\"language-plaintext highlighter-rouge\">sortAsc</code> if needed.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">0</code> for an empty list and the single element for a one-element list.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">xs</code></td>\n      <td>list<num></num></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">p</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rndrangemin-max\"><code class=\"language-plaintext highlighter-rouge\">rndRange(min, max)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#rndRange(min:num, max:num):num\n</code></pre>\n\n<p>returns a random integer in the range <code class=\"language-plaintext highlighter-rouge\">[min, max)</code> (exclusive upper bound).</p>\n\n<p>@effects(‘random’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">min</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">max</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">random</code></p>\n\n<hr />\n\n<h4 id=\"sqrtn\"><code class=\"language-plaintext highlighter-rouge\">sqrt(n)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#sqrt(n:num):num\n</code></pre>\n\n<p>returns the square root of <code class=\"language-plaintext highlighter-rouge\">n</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">NaN</code> for negative values.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">n</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">sqrt(0)  // =&gt; 0\nsqrt(4)  // =&gt; 2\nsqrt(9)  // =&gt; 3\n</code></pre>\n\n<hr />\n\n<h4 id=\"stdevxs-mean\"><code class=\"language-plaintext highlighter-rouge\">stdev(xs, mean)</code></h4>\n<pre><code class=\"language-slug\">fn slug.math#stdev(xs:list&lt;num&gt;, mean:num):num\n</code></pre>\n\n<p>returns the sample standard deviation of a list of numbers.</p>\n\n<p>Uses Bessel’s correction (divides by <code class=\"language-plaintext highlighter-rouge\">n - 1</code>). Returns <code class=\"language-plaintext highlighter-rouge\">0</code> for lists\nwith fewer than two elements. Requires the precomputed <code class=\"language-plaintext highlighter-rouge\">mean</code> as a\nsecond argument to avoid recomputing it internally.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">xs</code></td>\n      <td>list<num></num></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">mean</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.math",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-map",
      "url": "https://sluglang.org/libraries/slug-map",
      "title": "map (slug)",
      "content_html": "<h2 id=\"slugmap\">slug.map</h2>\n\n<p>slug.map — persistent map utilities</p>\n\n<p>Higher-level map operations built on the core <code class=\"language-plaintext highlighter-rouge\">put</code> and <code class=\"language-plaintext highlighter-rouge\">remove</code>\nprimitives from <code class=\"language-plaintext highlighter-rouge\">slug.std</code>. All functions are pure and return new\nmaps without modifying their inputs.</p>\n\n<p>For basic key operations (<code class=\"language-plaintext highlighter-rouge\">put</code>, <code class=\"language-plaintext highlighter-rouge\">remove</code>, <code class=\"language-plaintext highlighter-rouge\">update</code>, <code class=\"language-plaintext highlighter-rouge\">get</code>, <code class=\"language-plaintext highlighter-rouge\">keys</code>)\nsee <code class=\"language-plaintext highlighter-rouge\">slug.std</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#differenceks1-s2\"><code class=\"language-plaintext highlighter-rouge\">difference&lt;K&gt;(s1, s2)</code></a></li>\n  <li><a href=\"#intersectks1-s2\"><code class=\"language-plaintext highlighter-rouge\">intersect&lt;K&gt;(s1, s2)</code></a></li>\n  <li><a href=\"#mergebase-patch\"><code class=\"language-plaintext highlighter-rouge\">merge(base, patch)</code></a></li>\n  <li><a href=\"#patchbase-patchdata\"><code class=\"language-plaintext highlighter-rouge\">patch(base, patchData)</code></a></li>\n  <li><a href=\"#putnestedmap-keys-value\"><code class=\"language-plaintext highlighter-rouge\">putNested(map, keys, value)</code></a></li>\n  <li><a href=\"#unionks1-s2\"><code class=\"language-plaintext highlighter-rouge\">union&lt;K&gt;(s1, s2)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"differenceks1-s2\"><code class=\"language-plaintext highlighter-rouge\">difference&lt;K&gt;(s1, s2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#difference&lt;K&gt;(s1:map&lt;K,any&gt;, s2:map&lt;K,any&gt;):map&lt;K,any&gt;\n</code></pre>\n\n<p>returns <code class=\"language-plaintext highlighter-rouge\">s1</code> with all keys that appear in <code class=\"language-plaintext highlighter-rouge\">s2</code> removed.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s1</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s2</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">difference({:k1: 1}, {:k1: 2})  // =&gt; {}\ndifference({:k1: 1, :k2: 1}, {:k2: 2})  // =&gt; {:k1: 1}\n</code></pre>\n\n<hr />\n\n<h4 id=\"intersectks1-s2\"><code class=\"language-plaintext highlighter-rouge\">intersect&lt;K&gt;(s1, s2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#intersect&lt;K&gt;(s1:map&lt;K,any&gt;, s2:map&lt;K,any&gt;):map&lt;K,any&gt;\n</code></pre>\n\n<p>returns a map containing only keys present in both maps.</p>\n\n<p>Values are taken from <code class=\"language-plaintext highlighter-rouge\">s1</code>. Keys that exist only in <code class=\"language-plaintext highlighter-rouge\">s1</code> or only\nin <code class=\"language-plaintext highlighter-rouge\">s2</code> are excluded from the result.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s1</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s2</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">intersect({:k1: 1}, {:k1: 2})  // =&gt; {:k1: 1}\nintersect({:k1: 1}, {:k2: 2})  // =&gt; {}\nintersect({}, {:k2: 2})  // =&gt; {}\nintersect({:k1: 1}, {})  // =&gt; {}\n</code></pre>\n\n<hr />\n\n<h4 id=\"mergebase-patch\"><code class=\"language-plaintext highlighter-rouge\">merge(base, patch)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#merge(base:map, patch:map):map\n</code></pre>\n\n<p>merges two maps, with <code class=\"language-plaintext highlighter-rouge\">patch</code> values overwriting <code class=\"language-plaintext highlighter-rouge\">base</code> values on key conflicts.</p>\n\n<p>Shallow — nested maps are replaced entirely, not recursively merged.\nFor deep merging of nested maps, use <code class=\"language-plaintext highlighter-rouge\">patch</code> instead.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">patch</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">merge({:a: 1, :b: 2}, {:b: 3, :c: 4})  // =&gt; {:a: 1, :b: 3, :c: 4}\nmerge({:a: 1}, {})  // =&gt; {:a: 1}\nmerge({}, {:a: 1})  // =&gt; {:a: 1}\n</code></pre>\n\n<hr />\n\n<h4 id=\"patchbase-patchdata\"><code class=\"language-plaintext highlighter-rouge\">patch(base, patchData)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#patch(base:map, patchData:map):map\n</code></pre>\n\n<p>recursively merges two maps, deeply merging nested map values.</p>\n\n<p>When both <code class=\"language-plaintext highlighter-rouge\">base</code> and <code class=\"language-plaintext highlighter-rouge\">patchData</code> have a map value at the same key,\nthose maps are merged recursively. Otherwise the <code class=\"language-plaintext highlighter-rouge\">patchData</code> value\noverwrites the <code class=\"language-plaintext highlighter-rouge\">base</code> value. For a shallow merge, use <code class=\"language-plaintext highlighter-rouge\">merge</code> instead.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">patchData</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">patch({:a: {:x: 1}}, {:a: {:y: 2}})  // =&gt; {:a: {:x: 1, :y: 2}}\npatch({:a: 1}, {:a: {:b: 2}})  // =&gt; {:a: {:b: 2}}\npatch({:a: {:b: 2}}, {:a: 1})  // =&gt; {:a: 1}\n</code></pre>\n\n<hr />\n\n<h4 id=\"putnestedmap-keys-value\"><code class=\"language-plaintext highlighter-rouge\">putNested(map, keys, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#putNested(map:map, keys:list, value):map\n</code></pre>\n\n<p>sets a deeply nested key in a map, creating intermediate maps as needed.</p>\n\n<p>Keys are converted to symbols. If an intermediate key already exists\nand maps to a map, that map is updated. If it maps to a non-map value,\nit is replaced with a new map containing the nested key.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>map</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">keys</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">putNested({}, [\"k\"], \"v\")  // =&gt; {:k: v}\nputNested({}, [\"k\", \"k\"], \"v\")  // =&gt; {:k: {:k: v}}\nputNested({:k: {:j: 1}}, [\"k\", \"k\"], \"v\")  // =&gt; {:k: {:k: v, :j: 1}}\n</code></pre>\n\n<hr />\n\n<h4 id=\"unionks1-s2\"><code class=\"language-plaintext highlighter-rouge\">union&lt;K&gt;(s1, s2)</code></h4>\n<pre><code class=\"language-slug\">fn slug.map#union&lt;K&gt;(s1:map&lt;K,any&gt;, s2:map&lt;K,any&gt;):map&lt;K,any&gt;\n</code></pre>\n\n<p>returns a map containing all keys from both maps.</p>\n\n<p>On key conflicts, <code class=\"language-plaintext highlighter-rouge\">s1</code> values take precedence over <code class=\"language-plaintext highlighter-rouge\">s2</code> values.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s1</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s2</code></td>\n      <td>map&lt;K,any&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-5\">Examples</h4>\n\n<pre><code class=\"language-slug\">union({:k1: 1}, {:k2: 2})  // =&gt; {:k1: 1, :k2: 2}\nunion({:k1: 1}, {})  // =&gt; {:k1: 1}\nunion({}, {:k2: 2})  // =&gt; {:k2: 2}\nunion({:k1: 1}, {:k1: 9})  // =&gt; {:k1: 1}\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.map",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-log",
      "url": "https://sluglang.org/libraries/slug-log",
      "title": "log (slug)",
      "content_html": "<h2 id=\"sluglog\">slug.log</h2>\n\n<p>slug.log — structured logging</p>\n\n<p>Provides levelled, coloured, optionally file-backed logging for Slug\nprograms. Supports both module-level convenience functions and named\nper-source loggers for multi-module applications.</p>\n\n<h2 id=\"log-levels\">Log levels</h2>\n\n<p>Levels are ordered: <code class=\"language-plaintext highlighter-rouge\">trace</code> &lt; <code class=\"language-plaintext highlighter-rouge\">debug</code> &lt; <code class=\"language-plaintext highlighter-rouge\">info</code> &lt; <code class=\"language-plaintext highlighter-rouge\">warn</code> &lt; <code class=\"language-plaintext highlighter-rouge\">error</code> &lt; <code class=\"language-plaintext highlighter-rouge\">none</code>.\nA message is emitted only when its level is &gt;= the configured log level.\nSetting the level to <code class=\"language-plaintext highlighter-rouge\">none</code> suppresses all output.</p>\n\n<h2 id=\"configuration\">Configuration</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>cfg key</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">level</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"info\"</code></td>\n      <td>Global minimum log level</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">level__&lt;src&gt;</code></td>\n      <td> </td>\n      <td>Per-source override (dots replaced with <code class=\"language-plaintext highlighter-rouge\">_</code>)</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">log-file</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n      <td>Write to this file path instead of stderr</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">colour</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">true</code></td>\n      <td>Write to stderr with ANSI color codes</td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val log = import(\"slug.log\")\n\nlog.info(\"server started on port {}\", 8080)\nlog.warn(\"retrying after {} ms\", 500)\n</code></pre>\n\n<h2 id=\"named-loggers\">Named loggers</h2>\n\n<pre><code class=\"language-slug\">val log = import(\"slug.log\").logger(\"slug.io.http\")\n\nlog.debug(\"GET {} {}\", path, status)\n\n// chainable — passes the value through unchanged\nval result = fetchData()\n  /&gt; log.cInfo(\"fetched {} records\")\n  /&gt; process\n</code></pre>\n\n<h2 id=\"chainable-variants\">Chainable variants</h2>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">c*</code> functions (<code class=\"language-plaintext highlighter-rouge\">cTrace</code>, <code class=\"language-plaintext highlighter-rouge\">cDebug</code>, <code class=\"language-plaintext highlighter-rouge\">cInfo</code>, <code class=\"language-plaintext highlighter-rouge\">cWarn</code>, <code class=\"language-plaintext highlighter-rouge\">cError</code>) log a\nmessage and return their first argument unchanged. This lets you insert\nlogging into a pipeline without breaking the data flow:</p>\n\n<pre><code class=\"language-slug\">items\n  /&gt; filter(fn(x) { x.active })\n  /&gt; log.cDebug(\"active items: {}\")\n  /&gt; map(transform)\n</code></pre>\n\n<h2 id=\"file-output\">File output</h2>\n\n<p>When <code class=\"language-plaintext highlighter-rouge\">log-file</code> is set, log entries are appended to that file with no\ncolour codes. When writing to stderr, ANSI colour codes are applied per\nlevel.</p>\n\n<p>@effects(‘io’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#debug\">Debug</a></li>\n  <li><a href=\"#error\">Error</a></li>\n  <li><a href=\"#info\">Info</a></li>\n  <li><a href=\"#none\">None</a></li>\n  <li><a href=\"#trace\">Trace</a></li>\n  <li><a href=\"#warn\">Warn</a></li>\n  <li><a href=\"#cdebugarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cDebug(arg, message, args)</code></a></li>\n  <li><a href=\"#cerrorarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cError(arg, message, args)</code></a></li>\n  <li><a href=\"#cinfoarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cInfo(arg, message, args)</code></a></li>\n  <li><a href=\"#ctracearg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cTrace(arg, message, args)</code></a></li>\n  <li><a href=\"#cwarnarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cWarn(arg, message, args)</code></a></li>\n  <li><a href=\"#debugmessage-args\"><code class=\"language-plaintext highlighter-rouge\">debug(message, args)</code></a></li>\n  <li><a href=\"#errormessage-args\"><code class=\"language-plaintext highlighter-rouge\">error(message, args)</code></a></li>\n  <li><a href=\"#infopath\"><code class=\"language-plaintext highlighter-rouge\">info(path)</code></a></li>\n  <li><a href=\"#loggersrc\"><code class=\"language-plaintext highlighter-rouge\">logger(src)</code></a></li>\n  <li><a href=\"#nonemessage-args\"><code class=\"language-plaintext highlighter-rouge\">none(message, args)</code></a></li>\n  <li><a href=\"#tracemessage-args\"><code class=\"language-plaintext highlighter-rouge\">trace(message, args)</code></a></li>\n  <li><a href=\"#warnmessage-args\"><code class=\"language-plaintext highlighter-rouge\">warn(message, args)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"debug\"><code class=\"language-plaintext highlighter-rouge\">Debug</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#Debug\n</code></pre>\n\n<p>debug-level messages; verbose operational detail</p>\n\n<h4 id=\"error\"><code class=\"language-plaintext highlighter-rouge\">Error</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#Error\n</code></pre>\n\n<p>errors; failures that require attention</p>\n\n<h4 id=\"info\"><code class=\"language-plaintext highlighter-rouge\">Info</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#Info\n</code></pre>\n\n<p>informational messages; normal operational events</p>\n\n<h4 id=\"none\"><code class=\"language-plaintext highlighter-rouge\">None</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#None\n</code></pre>\n\n<p>suppress all output</p>\n\n<h4 id=\"trace\"><code class=\"language-plaintext highlighter-rouge\">Trace</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#Trace\n</code></pre>\n\n<p>minimum log level — emits everything</p>\n\n<h4 id=\"warn\"><code class=\"language-plaintext highlighter-rouge\">Warn</code></h4>\n\n<pre><code class=\"language-slug\">num slug.log#Warn\n</code></pre>\n\n<p>warnings; unexpected but recoverable situations</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"cdebugarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cDebug(arg, message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#cDebug(arg, message:str, ...args):any\n</code></pre>\n\n<p>logs a debug-level message and returns the first argument unchanged.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">arg</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cerrorarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cError(arg, message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#cError(arg, message:str, ...args):any\n</code></pre>\n\n<p>logs an error-level message and returns the first argument unchanged.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">arg</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cinfoarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cInfo(arg, message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#cInfo(arg, message:str, ...args):any\n</code></pre>\n\n<p>logs an info-level message and returns the first argument unchanged.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">arg</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"ctracearg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cTrace(arg, message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#cTrace(arg, message:str, ...args):any\n</code></pre>\n\n<p>logs a trace-level message and returns the first argument unchanged.</p>\n\n<p>Designed for use in call chains — the value flows through unmodified:</p>\n\n<pre><code class=\"language-slug\">val result = fetchItems()\n  /&gt; cTrace(\"fetched: {}\")\n  /&gt; process\n</code></pre>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">arg</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"cwarnarg-message-args\"><code class=\"language-plaintext highlighter-rouge\">cWarn(arg, message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#cWarn(arg, message:str, ...args):any\n</code></pre>\n\n<p>logs a warn-level message and returns the first argument unchanged.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">arg</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"debugmessage-args\"><code class=\"language-plaintext highlighter-rouge\">debug(message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#debug(message:str, ...args):str|nil\n</code></pre>\n\n<p>logs a debug-level message using the global log level.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"errormessage-args\"><code class=\"language-plaintext highlighter-rouge\">error(message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#error(message:str, ...args):str|nil\n</code></pre>\n\n<p>logs an error-level message using the global log level.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"infopath\"><code class=\"language-plaintext highlighter-rouge\">info(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#info(path:str):map\nfn slug.log#info(message:str, ...args):str|nil\n</code></pre>\n\n<p>logs an info-level message using the global log level.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"loggersrc\"><code class=\"language-plaintext highlighter-rouge\">logger(src)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#logger(src:str):map\n</code></pre>\n\n<p>creates a named logger for a specific source module.</p>\n\n<p>The source name is prepended to every log message, making it easy\nto filter output by module in multi-component applications.</p>\n\n<p>The log level can be overridden per-source via cfg:\ndots in the source name are replaced with underscores.\ne.g. <code class=\"language-plaintext highlighter-rouge\">logger(\"slug.io.http\")</code> reads <code class=\"language-plaintext highlighter-rouge\">cfg(\"level__slug_io_http\")</code>.</p>\n\n<p>Returns a map of logging functions: <code class=\"language-plaintext highlighter-rouge\">trace</code>, <code class=\"language-plaintext highlighter-rouge\">debug</code>, <code class=\"language-plaintext highlighter-rouge\">info</code>, <code class=\"language-plaintext highlighter-rouge\">warn</code>,\n<code class=\"language-plaintext highlighter-rouge\">error</code> and their chainable counterparts <code class=\"language-plaintext highlighter-rouge\">cTrace</code>…<code class=\"language-plaintext highlighter-rouge\">cError</code>.</p>\n\n<pre><code class=\"language-slug\">val log = import(\"slug.log\").logger(\"myapp.worker\")\nlog.info(\"started {} workers\", count)\nval result = compute() /&gt; log.cWarn(\"slow result: {}\")\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">src</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"nonemessage-args\"><code class=\"language-plaintext highlighter-rouge\">none(message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#none(message:str, ...args):nil\n</code></pre>\n\n<p>logs at the <code class=\"language-plaintext highlighter-rouge\">none</code> level.</p>\n\n<p>Since <code class=\"language-plaintext highlighter-rouge\">none</code> is above all other levels, this message is only emitted\nwhen the configured level is also <code class=\"language-plaintext highlighter-rouge\">none</code> — effectively never. Useful\nas a placeholder or for temporarily silencing a log call.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"tracemessage-args\"><code class=\"language-plaintext highlighter-rouge\">trace(message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#trace(message:str, ...args):str|nil\n</code></pre>\n\n<p>logs a trace-level message using the global log level.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">message</code> is a <code class=\"language-plaintext highlighter-rouge\">fmt</code>-style format string; <code class=\"language-plaintext highlighter-rouge\">args</code> are its arguments.\nEmits nothing if the configured level is above <code class=\"language-plaintext highlighter-rouge\">trace</code>.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"warnmessage-args\"><code class=\"language-plaintext highlighter-rouge\">warn(message, args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.log#warn(message:str, ...args):str|nil\n</code></pre>\n\n<p>logs a warn-level message using the global log level.</p>\n\n<p>@effects(‘io’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.log",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-list",
      "url": "https://sluglang.org/libraries/slug-list",
      "title": "list (slug)",
      "content_html": "<h2 id=\"sluglist\">slug.list</h2>\n\n<p>slug.list — list utilities</p>\n\n<p>Sorting, searching, flattening, shuffling, and character conversion\nhelpers for <code class=\"language-plaintext highlighter-rouge\">list</code> values. Complements the core list operations in\n<code class=\"language-plaintext highlighter-rouge\">slug.std</code> (<code class=\"language-plaintext highlighter-rouge\">map</code>, <code class=\"language-plaintext highlighter-rouge\">filter</code>, <code class=\"language-plaintext highlighter-rouge\">reduce</code>, <code class=\"language-plaintext highlighter-rouge\">find</code>, <code class=\"language-plaintext highlighter-rouge\">flatMap</code>, etc.).</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#aslistchars-i-acc\"><code class=\"language-plaintext highlighter-rouge\">asList(chars, i, acc)</code></a></li>\n  <li><a href=\"#flattentlsts\"><code class=\"language-plaintext highlighter-rouge\">flatten&lt;T&gt;(lsts)</code></a></li>\n  <li><a href=\"#indexoftlist-value-idx\"><code class=\"language-plaintext highlighter-rouge\">indexOf&lt;T&gt;(list, value, idx)</code></a></li>\n  <li><a href=\"#removevaluetlist-value\"><code class=\"language-plaintext highlighter-rouge\">removeValue&lt;T&gt;(list, value)</code></a></li>\n  <li><a href=\"#shuffletlist\"><code class=\"language-plaintext highlighter-rouge\">shuffle&lt;T&gt;(list)</code></a></li>\n  <li><a href=\"#sorttlst\"><code class=\"language-plaintext highlighter-rouge\">sort&lt;T&gt;(lst)</code></a></li>\n  <li><a href=\"#sortwithcomparatorlst-comparator\"><code class=\"language-plaintext highlighter-rouge\">sortWithComparator(lst, comparator)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"aslistchars-i-acc\"><code class=\"language-plaintext highlighter-rouge\">asList(chars, i, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#asList(chars:str, i:num = 0, acc:list&lt;str&gt; = []):list&lt;str&gt;\n</code></pre>\n\n<p>converts a string into a list of single-character strings.</p>\n\n<p>Returns an empty list for <code class=\"language-plaintext highlighter-rouge\">nil</code> or an empty string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">chars</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">i</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>list<str></str></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">asList(nil)  // =&gt; []\nasList(\"\")  // =&gt; []\nasList(\"123\")  // =&gt; [\"1\", \"2\", \"3\"]\n</code></pre>\n\n<hr />\n\n<h4 id=\"flattentlsts\"><code class=\"language-plaintext highlighter-rouge\">flatten&lt;T&gt;(lsts)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#flatten&lt;T&gt;(lsts:list&lt;list&lt;T&gt;|T&gt;):list&lt;T&gt;\n</code></pre>\n\n<p>flattens a list of lists into a single list.</p>\n\n<p>Only one level deep — nested lists within the inner lists are not\nrecursively flattened.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lsts</code></td>\n      <td>list&lt;list<T> | T&gt;</T></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">flatten([])  // =&gt; []\nflatten([1])  // =&gt; [1]\nflatten([[1, 2], [3]])  // =&gt; [1, 2, 3]\nflatten([[1, 2], [3], [4, 5]])  // =&gt; [1, 2, 3, 4, 5]\n</code></pre>\n\n<hr />\n\n<h4 id=\"indexoftlist-value-idx\"><code class=\"language-plaintext highlighter-rouge\">indexOf&lt;T&gt;(list, value, idx)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#indexOf&lt;T&gt;(list:list&lt;T&gt;, value:T, idx:num = 0):num\n</code></pre>\n\n<p>returns the index of the first occurrence of <code class=\"language-plaintext highlighter-rouge\">value</code> in <code class=\"language-plaintext highlighter-rouge\">list</code>.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">-1</code> if the value is not found. Uses value equality (<code class=\"language-plaintext highlighter-rouge\">==</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>T</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">idx</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">indexOf([1, 2], 2)  // =&gt; 1\nindexOf([1, 2], 1)  // =&gt; 0\nindexOf([1, 2], 9)  // =&gt; -1\n</code></pre>\n\n<hr />\n\n<h4 id=\"removevaluetlist-value\"><code class=\"language-plaintext highlighter-rouge\">removeValue&lt;T&gt;(list, value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#removeValue&lt;T&gt;(list:list&lt;T&gt;, value:T):list&lt;T&gt;\n</code></pre>\n\n<p>returns a new list with the first occurrence of <code class=\"language-plaintext highlighter-rouge\">value</code> removed.</p>\n\n<p>Returns the original list unchanged if the value is not present.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td>T</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">removeValue([1, 2, 3], 2)  // =&gt; [1, 3]\nremoveValue([1, 2, 3], 5)  // =&gt; [1, 2, 3]\n</code></pre>\n\n<hr />\n\n<h4 id=\"shuffletlist\"><code class=\"language-plaintext highlighter-rouge\">shuffle&lt;T&gt;(list)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#shuffle&lt;T&gt;(list:list&lt;T&gt;):list&lt;T&gt;\n</code></pre>\n\n<p>returns a new list with elements shuffled in random order.</p>\n\n<p>Uses the Fisher-Yates algorithm. The original list is not modified.</p>\n\n<p>@effects(‘random’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">random</code></p>\n\n<hr />\n\n<h4 id=\"sorttlst\"><code class=\"language-plaintext highlighter-rouge\">sort&lt;T&gt;(lst)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#sort&lt;T&gt;(lst:list&lt;T&gt;):list&lt;T&gt;\n</code></pre>\n\n<p>sorts a list in natural ascending order.</p>\n\n<p>Uses <code class=\"language-plaintext highlighter-rouge\">slug.std#compare</code> for ordering. Works correctly for lists of\nnumbers or lists of strings. For mixed or custom types, use\n<code class=\"language-plaintext highlighter-rouge\">sortWithComparator</code> instead.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"sortwithcomparatorlst-comparator\"><code class=\"language-plaintext highlighter-rouge\">sortWithComparator(lst, comparator)</code></h4>\n<pre><code class=\"language-slug\">fn slug.list#sortWithComparator(lst:list&lt;T&gt;, comparator:fn&lt;num, T&gt;):list&lt;T&gt;\n</code></pre>\n\n<p>sorts a list using a custom comparator function.</p>\n\n<p>The comparator receives two elements and must return a negative number\nif the first should come before the second, zero if equal, or a positive\nnumber if the first should come after.</p>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">slug.std#compare</code> as the comparator for natural ordering of\nnumbers and strings.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lst</code></td>\n      <td>list<T></T></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">comparator</code></td>\n      <td>fn&lt;num, T&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">sortWithComparator([3, 1, 2], function group: [{|| 2 2 false} =&gt; fn(a, b) { &lt;vm bytecode&gt; }])  // =&gt; [1, 2, 3]\nsortWithComparator([\"c\", \"a\", \"b\"], function group: [{|| 2 2 false} =&gt; fn(a, b) { &lt;vm bytecode&gt; }])  // =&gt; [\"a\", \"b\", \"c\"]\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.list",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-jsonrpc",
      "url": "https://sluglang.org/libraries/slug-jsonrpc",
      "title": "jsonrpc (slug)",
      "content_html": "<h2 id=\"slugjsonrpc\">slug.jsonrpc</h2>\n\n<p>slug.jsonrpc — JSON-RPC 2.0 helpers</p>\n\n<p>Builders, validators, and parser/encoder utilities for JSON-RPC 2.0\nmessages as defined by the specification:\nhttps://www.jsonrpc.org/specification</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#internal_error\">INTERNAL_ERROR</a></li>\n  <li><a href=\"#invalid_params\">INVALID_PARAMS</a></li>\n  <li><a href=\"#invalid_request\">INVALID_REQUEST</a></li>\n  <li><a href=\"#method_not_found\">METHOD_NOT_FOUND</a></li>\n  <li><a href=\"#parse_error\">PARSE_ERROR</a></li>\n  <li><a href=\"#version\">VERSION</a></li>\n  <li><a href=\"#encodemessage\"><code class=\"language-plaintext highlighter-rouge\">encode(message)</code></a></li>\n  <li><a href=\"#errorobjectcode-message-data\"><code class=\"language-plaintext highlighter-rouge\">errorObject(code, message, data)</code></a></li>\n  <li><a href=\"#failureid-code-message-data\"><code class=\"language-plaintext highlighter-rouge\">failure(id, code, message, data)</code></a></li>\n  <li><a href=\"#isbatchv\"><code class=\"language-plaintext highlighter-rouge\">isBatch(v)</code></a></li>\n  <li><a href=\"#iserrorresponsev\"><code class=\"language-plaintext highlighter-rouge\">isErrorResponse(v)</code></a></li>\n  <li><a href=\"#ismessagev\"><code class=\"language-plaintext highlighter-rouge\">isMessage(v)</code></a></li>\n  <li><a href=\"#isnotificationv\"><code class=\"language-plaintext highlighter-rouge\">isNotification(v)</code></a></li>\n  <li><a href=\"#isrequestv\"><code class=\"language-plaintext highlighter-rouge\">isRequest(v)</code></a></li>\n  <li><a href=\"#isresponsev\"><code class=\"language-plaintext highlighter-rouge\">isResponse(v)</code></a></li>\n  <li><a href=\"#issuccessresponsev\"><code class=\"language-plaintext highlighter-rouge\">isSuccessResponse(v)</code></a></li>\n  <li><a href=\"#notificationmethod-params\"><code class=\"language-plaintext highlighter-rouge\">notification(method, params)</code></a></li>\n  <li><a href=\"#parsepayload\"><code class=\"language-plaintext highlighter-rouge\">parse(payload)</code></a></li>\n  <li><a href=\"#requestid-method-params\"><code class=\"language-plaintext highlighter-rouge\">request(id, method, params)</code></a></li>\n  <li><a href=\"#successid-result\"><code class=\"language-plaintext highlighter-rouge\">success(id, result)</code></a></li>\n  <li><a href=\"#validatemessage\"><code class=\"language-plaintext highlighter-rouge\">validate(message)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"internal_error\"><code class=\"language-plaintext highlighter-rouge\">INTERNAL_ERROR</code></h4>\n\n<pre><code class=\"language-slug\">num slug.jsonrpc#INTERNAL_ERROR\n</code></pre>\n\n<h4 id=\"invalid_params\"><code class=\"language-plaintext highlighter-rouge\">INVALID_PARAMS</code></h4>\n\n<pre><code class=\"language-slug\">num slug.jsonrpc#INVALID_PARAMS\n</code></pre>\n\n<h4 id=\"invalid_request\"><code class=\"language-plaintext highlighter-rouge\">INVALID_REQUEST</code></h4>\n\n<pre><code class=\"language-slug\">num slug.jsonrpc#INVALID_REQUEST\n</code></pre>\n\n<h4 id=\"method_not_found\"><code class=\"language-plaintext highlighter-rouge\">METHOD_NOT_FOUND</code></h4>\n\n<pre><code class=\"language-slug\">num slug.jsonrpc#METHOD_NOT_FOUND\n</code></pre>\n\n<h4 id=\"parse_error\"><code class=\"language-plaintext highlighter-rouge\">PARSE_ERROR</code></h4>\n\n<pre><code class=\"language-slug\">num slug.jsonrpc#PARSE_ERROR\n</code></pre>\n\n<h4 id=\"version\"><code class=\"language-plaintext highlighter-rouge\">VERSION</code></h4>\n\n<pre><code class=\"language-slug\">str slug.jsonrpc#VERSION\n</code></pre>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"encodemessage\"><code class=\"language-plaintext highlighter-rouge\">encode(message)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#encode(message:list|map):str\n</code></pre>\n\n<p>encodes a JSON-RPC message or batch to JSON.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>list | map</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"errorobjectcode-message-data\"><code class=\"language-plaintext highlighter-rouge\">errorObject(code, message, data)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#errorObject(code:num, message:str, data:any = nil):map&lt;str,any&gt;\n</code></pre>\n\n<p>builds a JSON-RPC error object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>any</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"failureid-code-message-data\"><code class=\"language-plaintext highlighter-rouge\">failure(id, code, message, data)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#failure(id:str|num|nil, code:num, message:str, data:any = nil):map&lt;str,any&gt;\n</code></pre>\n\n<p>builds a JSON-RPC error response object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">id</code></td>\n      <td>str | num | nil</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">code</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>any</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isbatchv\"><code class=\"language-plaintext highlighter-rouge\">isBatch(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isBatch(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a JSON-RPC batch payload.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"iserrorresponsev\"><code class=\"language-plaintext highlighter-rouge\">isErrorResponse(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isErrorResponse(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is an error response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"ismessagev\"><code class=\"language-plaintext highlighter-rouge\">isMessage(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isMessage(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a valid single JSON-RPC message object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isnotificationv\"><code class=\"language-plaintext highlighter-rouge\">isNotification(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isNotification(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a notification object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isrequestv\"><code class=\"language-plaintext highlighter-rouge\">isRequest(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isRequest(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a request object (includes notifications).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isresponsev\"><code class=\"language-plaintext highlighter-rouge\">isResponse(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isResponse(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a response object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"issuccessresponsev\"><code class=\"language-plaintext highlighter-rouge\">isSuccessResponse(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#isSuccessResponse(v):bool\n</code></pre>\n\n<p>returns true when <code class=\"language-plaintext highlighter-rouge\">v</code> is a success response.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"notificationmethod-params\"><code class=\"language-plaintext highlighter-rouge\">notification(method, params)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#notification(method:str, params:list|map|nil = nil):map&lt;str,any&gt;\n</code></pre>\n\n<p>builds a JSON-RPC notification object (request without <code class=\"language-plaintext highlighter-rouge\">id</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td>list | map | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"parsepayload\"><code class=\"language-plaintext highlighter-rouge\">parse(payload)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#parse(payload:str):any\n</code></pre>\n\n<p>decodes JSON and validates it as JSON-RPC 2.0.</p>\n\n<p>Throws <code class=\"language-plaintext highlighter-rouge\">JsonRpcError</code> with code:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">-32700</code> for JSON parse errors</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">-32600</code> for structurally invalid JSON-RPC payloads</li>\n</ul>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">payload</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:JsonRpcError}</code></p>\n\n<hr />\n\n<h4 id=\"requestid-method-params\"><code class=\"language-plaintext highlighter-rouge\">request(id, method, params)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#request(id:str|num|nil, method:str, params:list|map|nil = nil):map&lt;str,any&gt;\n</code></pre>\n\n<p>builds a JSON-RPC request object.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">id</code></td>\n      <td>str | num | nil</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td>list | map | nil</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"successid-result\"><code class=\"language-plaintext highlighter-rouge\">success(id, result)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#success(id:str|num|nil, result:any = nil):map&lt;str,any&gt;\n</code></pre>\n\n<p>builds a JSON-RPC success response object.</p>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">result</code> member is always present (it may be <code class=\"language-plaintext highlighter-rouge\">nil</code>).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">id</code></td>\n      <td>str | num | nil</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">result</code></td>\n      <td>any</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"validatemessage\"><code class=\"language-plaintext highlighter-rouge\">validate(message)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonrpc#validate(message:any):map|list\n</code></pre>\n\n<p>validates a JSON-RPC message or batch.</p>\n\n<p>Returns the input when valid, otherwise throws <code class=\"language-plaintext highlighter-rouge\">JsonRpcError</code>\nwith <code class=\"language-plaintext highlighter-rouge\">code = -32600</code> (Invalid Request).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>any</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:JsonRpcError}</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.jsonrpc",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-jsonl",
      "url": "https://sluglang.org/libraries/slug-jsonl",
      "title": "jsonl (slug)",
      "content_html": "<h2 id=\"slugjsonl\">slug.jsonl</h2>\n\n<p>slug.jsonl — JSON Lines encoding and decoding</p>\n\n<p>Encodes lists of values into JSONL (<code class=\"language-plaintext highlighter-rouge\">.jsonl</code>) and decodes JSONL strings\ninto lists of values. Uses <code class=\"language-plaintext highlighter-rouge\">slug.json</code> for per-line JSON handling.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#decodejsonl-skipempty\"><code class=\"language-plaintext highlighter-rouge\">decode(jsonl, skipEmpty)</code></a></li>\n  <li><a href=\"#encodevalues-eol-trailingeol\"><code class=\"language-plaintext highlighter-rouge\">encode(values, eol, trailingEol)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"decodejsonl-skipempty\"><code class=\"language-plaintext highlighter-rouge\">decode(jsonl, skipEmpty)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonl#decode(jsonl:str, skipEmpty:bool = true):list&lt;any&gt;\n</code></pre>\n\n<p>decodes JSON Lines text into a list of values.</p>\n\n<p>By default blank lines are ignored. Set <code class=\"language-plaintext highlighter-rouge\">skipEmpty</code> to <code class=\"language-plaintext highlighter-rouge\">false</code> to enforce\nstrict parsing and treat empty lines as errors.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">jsonl</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">skipEmpty</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">true</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">decode(\"{\"a\":1}\n{\"b\":2}\")  // =&gt; [{a: 1}, {b: 2}]\ndecode(\"{\"a\":1}\n{\"b\":2}\")  // =&gt; [{a: 1}, {b: 2}]\ndecode(\"{\"a\":1}\n\n{\"b\":2}\")  // =&gt; [{a: 1}, {b: 2}]\n</code></pre>\n\n<hr />\n\n<h4 id=\"encodevalues-eol-trailingeol\"><code class=\"language-plaintext highlighter-rouge\">encode(values, eol, trailingEol)</code></h4>\n<pre><code class=\"language-slug\">fn slug.jsonl#encode(values:list&lt;any&gt;, eol:str = \"\\n\", trailingEol:bool = false):str\n</code></pre>\n\n<p>encodes a list of values as JSON Lines text.</p>\n\n<p>Each value is encoded as one JSON value per line.</p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">eol</code> controls the line separator (default <code class=\"language-plaintext highlighter-rouge\">\"\\n\"</code>).</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">trailingEol</code> appends one final <code class=\"language-plaintext highlighter-rouge\">eol</code> when <code class=\"language-plaintext highlighter-rouge\">true</code>.</li>\n</ul>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">values</code></td>\n      <td>list<any></any></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">eol</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\\n\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">trailingEol</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">encode([{name: a}, {name: b}])  // =&gt; \"{\"name\":\"a\"}\n{\"name\":\"b\"}\"\nencode([1, true, nil], \"\n\", true)  // =&gt; \"1\ntrue\nnull\n\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.jsonl",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-json",
      "url": "https://sluglang.org/libraries/slug-json",
      "title": "json (slug)",
      "content_html": "<h2 id=\"slugjson\">slug.json</h2>\n\n<p>slug.json — JSON encoding and decoding</p>\n\n<p>A pure Slug implementation of JSON serialisation and deserialisation\nconforming to RFC 8259.</p>\n\n<h2 id=\"type-mapping\">Type mapping</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Slug type</th>\n      <th>JSON type</th>\n      <th>Notes</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>string</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">num</code></td>\n      <td>number</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">bool</code></td>\n      <td>boolean</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">nil</code></td>\n      <td>null</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>array</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>object</td>\n      <td>keys serialised as strings; sorted</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sym</code></td>\n      <td>string</td>\n      <td>symbol label used as string value</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">bytes</code></td>\n      <td>string</td>\n      <td>encoded as <code class=\"language-plaintext highlighter-rouge\">\"b64:&lt;base64&gt;\"</code> prefix string</td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"key-handling\">Key handling</h2>\n\n<p>Object keys are always serialised as strings. Both symbol keys (<code class=\"language-plaintext highlighter-rouge\">:name</code>)\nand string keys (<code class=\"language-plaintext highlighter-rouge\">\"name\"</code>) are supported on encode. On decode, all\nobject keys are returned as string keys — use dot access (<code class=\"language-plaintext highlighter-rouge\">m.name</code>) or\nstring bracket access (<code class=\"language-plaintext highlighter-rouge\">m[\"name\"]</code>) to read decoded values.</p>\n\n<h2 id=\"bytes-encoding\">Bytes encoding</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">bytes</code> values are encoded as <code class=\"language-plaintext highlighter-rouge\">\"b64:&lt;base64&gt;\"</code> strings. On decode,\nany string with this prefix is automatically decoded back to <code class=\"language-plaintext highlighter-rouge\">bytes</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#decodejsonstr\"><code class=\"language-plaintext highlighter-rouge\">decode(jsonStr)</code></a></li>\n  <li><a href=\"#encodev\"><code class=\"language-plaintext highlighter-rouge\">encode(v)</code></a></li>\n  <li><a href=\"#prettyv-indent\"><code class=\"language-plaintext highlighter-rouge\">pretty(v, indent)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"decodejsonstr\"><code class=\"language-plaintext highlighter-rouge\">decode(jsonStr)</code></h4>\n<pre><code class=\"language-slug\">fn slug.json#decode(jsonStr:str):any\n</code></pre>\n\n<p>decodes a JSON string into a Slug value.</p>\n\n<p>Object keys are always decoded as string keys. Use dot access (<code class=\"language-plaintext highlighter-rouge\">m.name</code>)\nor string bracket access (<code class=\"language-plaintext highlighter-rouge\">m[\"name\"]</code>) to read fields — never symbol\nbracket access (<code class=\"language-plaintext highlighter-rouge\">m[:name]</code>).</p>\n\n<p>Strings with the <code class=\"language-plaintext highlighter-rouge\">b64:</code> prefix are decoded to <code class=\"language-plaintext highlighter-rouge\">bytes</code> values.\nThrows <code class=\"language-plaintext highlighter-rouge\">JsonError</code> on malformed input.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">jsonStr</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:JsonError}</code></p>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">decode(\"\"hello\"\")  // =&gt; \"hello\"\ndecode(\"42\")  // =&gt; 42\ndecode(\"true\")  // =&gt; true\ndecode(\"false\")  // =&gt; false\ndecode(\"null\")  // =&gt; nil\ndecode(\"[1,2,3]\")  // =&gt; [1, 2, 3]\ndecode(\"\"b64:Zm9v\"\")  // =&gt; 0x\"666f6f\"\ndecode(\"{\"name\":\"Alice\",\"age\":30}\")  // =&gt; {name: Alice, age: 30}\n</code></pre>\n\n<hr />\n\n<h4 id=\"encodev\"><code class=\"language-plaintext highlighter-rouge\">encode(v)</code></h4>\n<pre><code class=\"language-slug\">fn slug.json#encode(v:any):str\n</code></pre>\n\n<p>encodes a Slug value as a compact JSON string.</p>\n\n<p>Object keys are sorted alphabetically. Symbols are encoded as their label\nstring. Bytes are encoded as <code class=\"language-plaintext highlighter-rouge\">\"b64:&lt;base64&gt;\"</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td>any</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:JsonError}</code></p>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">encode(\"hello\")  // =&gt; \"\"hello\"\"\nencode(42)  // =&gt; \"42\"\nencode(true)  // =&gt; \"true\"\nencode(false)  // =&gt; \"false\"\nencode(nil)  // =&gt; \"null\"\nencode(0x\"ff\")  // =&gt; \"\"b64:/w==\"\"\nencode([1, 2, 3])  // =&gt; \"[1,2,3]\"\nencode({:type: :fn, :age: 30})  // =&gt; \"{\"age\":30,\"type\":\"fn\"}\"\nencode({:name: Alice, :age: 30})  // =&gt; \"{\"age\":30,\"name\":\"Alice\"}\"\nencode({name: Alice, age: 30})  // =&gt; \"{\"age\":30,\"name\":\"Alice\"}\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"prettyv-indent\"><code class=\"language-plaintext highlighter-rouge\">pretty(v, indent)</code></h4>\n<pre><code class=\"language-slug\">fn slug.json#pretty(v:any, indent:num = 2):str\n</code></pre>\n\n<p>encodes a Slug value as a pretty-printed JSON string.</p>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">indent</code> parameter controls the number of spaces per indentation\nlevel. Follows the same type mapping as <code class=\"language-plaintext highlighter-rouge\">encode</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">v</code></td>\n      <td>any</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">indent</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">2</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:JsonError}</code></p>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">pretty(\"hello\", 2)  // =&gt; \"\"hello\"\"\npretty([1, 2, 3], 4)  // =&gt; \"[\n    1,\n    2,\n    3\n]\"\npretty(0x\"ff\", 2)  // =&gt; \"\"b64:/w==\"\"\npretty({:type: :fn, :age: 30}, 2)  // =&gt; \"{\n  \"age\": 30,\n  \"type\": \"fn\"\n}\"\npretty({:name: Alice, :age: 30}, 2)  // =&gt; \"{\n  \"age\": 30,\n  \"name\": \"Alice\"\n}\"\npretty({name: Alice, age: 30}, 2)  // =&gt; \"{\n  \"age\": 30,\n  \"name\": \"Alice\"\n}\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.json",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-tcp",
      "url": "https://sluglang.org/libraries/slug-io-tcp",
      "title": "tcp (slug.io)",
      "content_html": "<h2 id=\"slugiotcp\">slug.io.tcp</h2>\n\n<p>slug.io.tcp — low-level TCP networking</p>\n\n<p>Raw TCP socket operations for building servers and clients. Connection\nand listener handles are numeric values — always close them when done.</p>\n\n<h2 id=\"tcp-server-example\">TCP server example</h2>\n\n<pre><code class=\"language-slug\">val { bind, accept, read, write, close } = import(\"slug.io.tcp\")\n\nval listener = bind(\"0.0.0.0\", 8080)\ndefer close(listener)\n\nnursery {\n  spawn {\n    val conn = accept(listener)\n    defer close(conn)\n    val data = read(conn, 4096)\n    write(conn, \"HTTP/1.1 200 OK\\r\\n\\r\\nHello!\")\n  }\n}\n</code></pre>\n\n<h2 id=\"tcp-client-example\">TCP client example</h2>\n\n<pre><code class=\"language-slug\">val conn = connect(\"example.com\", 80)\ndefer close(conn)\nwrite(conn, \"GET / HTTP/1.0\\r\\n\\r\\n\")\nval response = read(conn, 4096)\n</code></pre>\n\n<p>For HTTP use cases, prefer <code class=\"language-plaintext highlighter-rouge\">slug.io.http</code>. For web servers, prefer\n<code class=\"language-plaintext highlighter-rouge\">slug.web.server</code>.</p>\n\n<p>@effects(‘io net’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#acceptlistener\"><code class=\"language-plaintext highlighter-rouge\">accept(listener)</code></a></li>\n  <li><a href=\"#bindaddr-port\"><code class=\"language-plaintext highlighter-rouge\">bind(addr, port)</code></a></li>\n  <li><a href=\"#closehandle\"><code class=\"language-plaintext highlighter-rouge\">close(handle)</code></a></li>\n  <li><a href=\"#connectaddr-port\"><code class=\"language-plaintext highlighter-rouge\">connect(addr, port)</code></a></li>\n  <li><a href=\"#readstream-maxbytes\"><code class=\"language-plaintext highlighter-rouge\">read(stream, maxBytes)</code></a></li>\n  <li><a href=\"#writestream-data\"><code class=\"language-plaintext highlighter-rouge\">write(stream, data)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"acceptlistener\"><code class=\"language-plaintext highlighter-rouge\">accept(listener)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#accept(listener:num):num\n</code></pre>\n\n<p>waits for an incoming connection on <code class=\"language-plaintext highlighter-rouge\">listener</code> and returns a connection handle.</p>\n\n<p>Blocks until a client connects. Use in a <code class=\"language-plaintext highlighter-rouge\">spawn</code> or <code class=\"language-plaintext highlighter-rouge\">nursery</code> block\nfor concurrent connection handling.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">listener</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"bindaddr-port\"><code class=\"language-plaintext highlighter-rouge\">bind(addr, port)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#bind(addr:str, port:num):num\n</code></pre>\n\n<p>binds a TCP listener to <code class=\"language-plaintext highlighter-rouge\">addr:port</code> and returns a listener handle.</p>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">accept</code> to wait for incoming connections.\nUse <code class=\"language-plaintext highlighter-rouge\">defer close(listener)</code> to release the port when done.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">addr</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">port</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"closehandle\"><code class=\"language-plaintext highlighter-rouge\">close(handle)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#close(handle:num):num\n</code></pre>\n\n<p>closes a TCP listener or connection handle.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"connectaddr-port\"><code class=\"language-plaintext highlighter-rouge\">connect(addr, port)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#connect(addr:str, port:num):num\n</code></pre>\n\n<p>connects to a TCP server at <code class=\"language-plaintext highlighter-rouge\">addr:port</code> and returns a connection handle.</p>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">defer close(conn)</code> to release the connection.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">addr</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">port</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"readstream-maxbytes\"><code class=\"language-plaintext highlighter-rouge\">read(stream, maxBytes)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#read(stream:num, maxBytes:num):str\n</code></pre>\n\n<p>reads up to <code class=\"language-plaintext highlighter-rouge\">maxBytes</code> from a TCP stream.</p>\n\n<p>Returns the data read as a string, or <code class=\"language-plaintext highlighter-rouge\">nil</code> on EOF.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">stream</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">maxBytes</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"writestream-data\"><code class=\"language-plaintext highlighter-rouge\">write(stream, data)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.tcp#write(stream:num, data:str):num\n</code></pre>\n\n<p>sends <code class=\"language-plaintext highlighter-rouge\">data</code> over a TCP stream.</p>\n\n<p>Returns the number of bytes written.</p>\n\n<p>@effects(‘io net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">stream</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.tcp",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-stdin",
      "url": "https://sluglang.org/libraries/slug-io-stdin",
      "title": "stdin (slug.io)",
      "content_html": "<h2 id=\"slugiostdin\">slug.io.stdin</h2>\n\n<p>slug.io.stdin — process standard input as a line stream</p>\n\n<p>Exposes process stdin as a shared channel stream for use with\nchannels and <code class=\"language-plaintext highlighter-rouge\">select</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#confirmmessage-default\"><code class=\"language-plaintext highlighter-rouge\">confirm(message, default)</code></a></li>\n  <li><a href=\"#promptprompt\"><code class=\"language-plaintext highlighter-rouge\">prompt(prompt)</code></a></li>\n  <li><a href=\"#readline\"><code class=\"language-plaintext highlighter-rouge\">readLine()</code></a></li>\n  <li><a href=\"#readlines\"><code class=\"language-plaintext highlighter-rouge\">readLines()</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"confirmmessage-default\"><code class=\"language-plaintext highlighter-rouge\">confirm(message, default)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stdin#confirm(message:str, default:bool = false):bool\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">default</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"promptprompt\"><code class=\"language-plaintext highlighter-rouge\">prompt(prompt)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stdin#prompt(prompt:str):str\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">prompt</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"readline\"><code class=\"language-plaintext highlighter-rouge\">readLine()</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stdin#readLine():any\n</code></pre>\n\n<hr />\n\n<h4 id=\"readlines\"><code class=\"language-plaintext highlighter-rouge\">readLines()</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stdin#readLines():chan&lt;str|nil&gt;\n</code></pre>\n\n<p>Returns a shared singleton channel of stdin line events.</p>\n\n<p>Event stream:</p>\n<ul>\n  <li>each line is emitted as <code class=\"language-plaintext highlighter-rouge\">str</code> (without trailing newline)</li>\n  <li>empty lines are preserved as <code class=\"language-plaintext highlighter-rouge\">\"\"</code></li>\n  <li>a final partial line (without trailing newline) is emitted</li>\n  <li>when input ends, the channel closes</li>\n</ul>\n\n<p>With <code class=\"language-plaintext highlighter-rouge\">slug.channel#recv</code>, closure is observed as <code class=\"language-plaintext highlighter-rouge\">nil</code>.</p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.stdin",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-stderr",
      "url": "https://sluglang.org/libraries/slug-io-stderr",
      "title": "stderr (slug.io)",
      "content_html": "<h2 id=\"slugiostderr\">slug.io.stderr</h2>\n\n<p>slug.io.stderr — write to standard error</p>\n\n<p>Provides <code class=\"language-plaintext highlighter-rouge\">print</code> and <code class=\"language-plaintext highlighter-rouge\">println</code> equivalents that write to stderr\ninstead of stdout. Useful for diagnostic output, error messages,\nand logging that should not mix with a program’s regular output.</p>\n\n<h2 id=\"important-import-style\">Important: import style</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">print</code> and <code class=\"language-plaintext highlighter-rouge\">println</code> are builtins that take precedence over imported\nnames, so <code class=\"language-plaintext highlighter-rouge\">val {*} = import('slug.io.stderr')</code> will not shadow them.\nAlways import this module under a name:</p>\n\n<pre><code class=\"language-slug\">val err = import('slug.io.stderr')\n\nerr.print(\"warning: \")\nerr.println(\"retrying after timeout\")\n</code></pre>\n\n<p>@effects(‘io’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#printargs\"><code class=\"language-plaintext highlighter-rouge\">print(args)</code></a></li>\n  <li><a href=\"#printlnargs\"><code class=\"language-plaintext highlighter-rouge\">println(args)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"printargs\"><code class=\"language-plaintext highlighter-rouge\">print(args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stderr#print(...args):any\n</code></pre>\n\n<p>writes args to stderr without a trailing newline.</p>\n\n<p>Behaves identically to the builtin <code class=\"language-plaintext highlighter-rouge\">print</code> but writes to stderr.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"printlnargs\"><code class=\"language-plaintext highlighter-rouge\">println(args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.stderr#println(...args):any\n</code></pre>\n\n<p>writes args to stderr followed by a newline.</p>\n\n<p>Behaves identically to the builtin <code class=\"language-plaintext highlighter-rouge\">println</code> but writes to stderr.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.stderr",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-http",
      "url": "https://sluglang.org/libraries/slug-io-http",
      "title": "http (slug.io)",
      "content_html": "<h2 id=\"slugiohttp\">slug.io.http</h2>\n\n<p>slug.io.http — HTTP client</p>\n\n<p>Makes outbound HTTP requests and returns <code class=\"language-plaintext highlighter-rouge\">[status:num, body:str]</code>.\nAll methods are convenience wrappers around <code class=\"language-plaintext highlighter-rouge\">request</code>.</p>\n\n<h2 id=\"example\">Example</h2>\n\n<pre><code class=\"language-slug\">val { get, post } = import(\"slug.io.http\")\nval { decode }    = import(\"slug.json\")\n\nval [status, body] = get(\"https://api.example.com/users\")\nmatch status {\n  200 =&gt; decode(body) /&gt; println\n  _   =&gt; println(\"error: \" + status)\n}\n\nval [status, body] = post(\n  encode({ name: \"Alice\" }),\n  \"https://api.example.com/users\",\n  { \"Content-Type\": \"application/json\" }\n)\n</code></pre>\n\n<p>Note: <code class=\"language-plaintext highlighter-rouge\">post</code>, <code class=\"language-plaintext highlighter-rouge\">put</code>, and <code class=\"language-plaintext highlighter-rouge\">patch</code> take the body as the <strong>first</strong> argument,\nbefore the URL. This is designed for call-chain usage:</p>\n<pre><code class=\"language-slug\">encode(payload) /&gt; post(\"https://api.example.com/data\")\n</code></pre>\n\n<p>@effects(‘net’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#deleteurl-headers\"><code class=\"language-plaintext highlighter-rouge\">delete(url, headers)</code></a></li>\n  <li><a href=\"#geturl-headers\"><code class=\"language-plaintext highlighter-rouge\">get(url, headers)</code></a></li>\n  <li><a href=\"#patchbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">patch(body, url, headers)</code></a></li>\n  <li><a href=\"#postbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">post(body, url, headers)</code></a></li>\n  <li><a href=\"#putbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">put(body, url, headers)</code></a></li>\n  <li><a href=\"#requestmethod-url-body-headers-timeout\"><code class=\"language-plaintext highlighter-rouge\">request(method, url, body, headers, timeout)</code></a></li>\n  <li><a href=\"#urldecodestr\"><code class=\"language-plaintext highlighter-rouge\">urlDecode(str)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"deleteurl-headers\"><code class=\"language-plaintext highlighter-rouge\">delete(url, headers)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#delete(url:str, headers:map = {}):[num, str]\n</code></pre>\n\n<p>makes a DELETE request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"geturl-headers\"><code class=\"language-plaintext highlighter-rouge\">get(url, headers)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#get(url:str, headers:map = {}):[num, str]\n</code></pre>\n\n<p>makes a GET request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"patchbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">patch(body, url, headers)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#patch(body:str, url:str, headers:map = {}):[num, str]\n</code></pre>\n\n<p>makes a PATCH request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>Note: <code class=\"language-plaintext highlighter-rouge\">body</code> is the first argument to support call-chain style.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"postbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">post(body, url, headers)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#post(body:str, url:str, headers:map = {}):[num, str]\n</code></pre>\n\n<p>makes a POST request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>Note: <code class=\"language-plaintext highlighter-rouge\">body</code> is the first argument to support call-chain style:\n<code class=\"language-plaintext highlighter-rouge\">encode(payload) /&gt; post(\"https://...\")</code></p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"putbody-url-headers\"><code class=\"language-plaintext highlighter-rouge\">put(body, url, headers)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#put(body:str, url:str, headers:map = {}):[num, str]\n</code></pre>\n\n<p>makes a PUT request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>Note: <code class=\"language-plaintext highlighter-rouge\">body</code> is the first argument to support call-chain style.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"requestmethod-url-body-headers-timeout\"><code class=\"language-plaintext highlighter-rouge\">request(method, url, body, headers, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#request(method:str, url:str, body:str = \"\", headers:map = {}, timeout:num = 30000):[num, str]\n</code></pre>\n\n<p>makes an HTTP request and returns <code class=\"language-plaintext highlighter-rouge\">[status, body]</code>.</p>\n\n<p>The low-level entry point — prefer the method-specific helpers for\ncommon cases.</p>\n\n<p>@effects(‘net’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">method</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">url</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">body</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">headers</code></td>\n      <td>map</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{}</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">30000</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"urldecodestr\"><code class=\"language-plaintext highlighter-rouge\">urlDecode(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.http#urlDecode(str:str):any\n</code></pre>\n\n<p>decodes a URL-encoded string.</p>\n\n<p>Note: not yet implemented — returns the input string unchanged.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.http",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-fs",
      "url": "https://sluglang.org/libraries/slug-io-fs",
      "title": "fs (slug.io)",
      "content_html": "<h2 id=\"slugiofs\">slug.io.fs</h2>\n\n<p>slug.io.fs — filesystem I/O</p>\n\n<p>Read, write, and navigate the filesystem. File handles from <code class=\"language-plaintext highlighter-rouge\">openFile</code>\nmust be closed with <code class=\"language-plaintext highlighter-rouge\">closeFile</code> — use <code class=\"language-plaintext highlighter-rouge\">defer closeFile(handle)</code> for safety.</p>\n\n<h2 id=\"simple-file-operations\">Simple file operations</h2>\n\n<pre><code class=\"language-slug\">val { readFile, writeFile, exists } = import(\"slug.io.fs\")\n\nval content = readFile(\"config.toml\")\nwriteFile(\"output.txt\", \"hello\\n\")\n</code></pre>\n\n<h2 id=\"streaming-reads\">Streaming reads</h2>\n\n<pre><code class=\"language-slug\">val { openFile, readLines, closeFile, READ_MODE } = import(\"slug.io.fs\")\n\nval handle = openFile(\"data.csv\", READ_MODE)\ndefer closeFile(handle)\nval lines = readLines(handle)\n</code></pre>\n\n<h2 id=\"file-modes\">File modes</h2>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">READ_MODE</code>   — open for reading (<code class=\"language-plaintext highlighter-rouge\">\"r\"</code>)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">WRITE_MODE</code>  — open for writing, truncates existing content (<code class=\"language-plaintext highlighter-rouge\">\"w\"</code>)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">APPEND_MODE</code> — open for appending (<code class=\"language-plaintext highlighter-rouge\">\"a\"</code>)</li>\n</ul>\n\n<p>@effects(‘fs’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#append_mode\">APPEND_MODE</a></li>\n  <li><a href=\"#read_mode\">READ_MODE</a></li>\n  <li><a href=\"#write_mode\">WRITE_MODE</a></li>\n  <li><a href=\"#appendfilecontents-path\"><code class=\"language-plaintext highlighter-rouge\">appendFile(contents, path)</code></a></li>\n  <li><a href=\"#closefilehandle\"><code class=\"language-plaintext highlighter-rouge\">closeFile(handle)</code></a></li>\n  <li><a href=\"#existspath\"><code class=\"language-plaintext highlighter-rouge\">exists(path)</code></a></li>\n  <li><a href=\"#infopath\"><code class=\"language-plaintext highlighter-rouge\">info(path)</code></a></li>\n  <li><a href=\"#isdirpath\"><code class=\"language-plaintext highlighter-rouge\">isDir(path)</code></a></li>\n  <li><a href=\"#listfilesrecursivepath-filter-acc\"><code class=\"language-plaintext highlighter-rouge\">listFilesRecursive(path, filter, acc)</code></a></li>\n  <li><a href=\"#lspath\"><code class=\"language-plaintext highlighter-rouge\">ls(path)</code></a></li>\n  <li><a href=\"#mkdirspath\"><code class=\"language-plaintext highlighter-rouge\">mkDirs(path)</code></a></li>\n  <li><a href=\"#openfilepath-mode\"><code class=\"language-plaintext highlighter-rouge\">openFile(path, mode)</code></a></li>\n  <li><a href=\"#readfilepath\"><code class=\"language-plaintext highlighter-rouge\">readFile(path)</code></a></li>\n  <li><a href=\"#readlinehandle\"><code class=\"language-plaintext highlighter-rouge\">readLine(handle)</code></a></li>\n  <li><a href=\"#readlinesfile-lines\"><code class=\"language-plaintext highlighter-rouge\">readLines(file, lines)</code></a></li>\n  <li><a href=\"#rmpath\"><code class=\"language-plaintext highlighter-rouge\">rm(path)</code></a></li>\n  <li><a href=\"#writehandle-content\"><code class=\"language-plaintext highlighter-rouge\">write(handle, content)</code></a></li>\n  <li><a href=\"#writefilecontents-path\"><code class=\"language-plaintext highlighter-rouge\">writeFile(contents, path)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"append_mode\"><code class=\"language-plaintext highlighter-rouge\">APPEND_MODE</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.fs#APPEND_MODE\n</code></pre>\n\n<h4 id=\"read_mode\"><code class=\"language-plaintext highlighter-rouge\">READ_MODE</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.fs#READ_MODE\n</code></pre>\n\n<h4 id=\"write_mode\"><code class=\"language-plaintext highlighter-rouge\">WRITE_MODE</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.fs#WRITE_MODE\n</code></pre>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"appendfilecontents-path\"><code class=\"language-plaintext highlighter-rouge\">appendFile(contents, path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#appendFile(contents:str, path:str):num\n</code></pre>\n\n<p>appends <code class=\"language-plaintext highlighter-rouge\">contents</code> to the end of a file, creating it if absent.</p>\n\n<p>Returns the number of bytes written.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">contents</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"closefilehandle\"><code class=\"language-plaintext highlighter-rouge\">closeFile(handle)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#closeFile(handle:num):nil\n</code></pre>\n\n<p>closes an open file handle.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"existspath\"><code class=\"language-plaintext highlighter-rouge\">exists(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#exists(path:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">path</code> exists and is accessible.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"infopath\"><code class=\"language-plaintext highlighter-rouge\">info(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#info(path:str):map\n</code></pre>\n\n<p>returns metadata about a file or directory as a map.</p>\n\n<p>The map contains at minimum <code class=\"language-plaintext highlighter-rouge\">name</code>, <code class=\"language-plaintext highlighter-rouge\">size</code>, <code class=\"language-plaintext highlighter-rouge\">isDir</code>, and <code class=\"language-plaintext highlighter-rouge\">modTime</code> fields.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"isdirpath\"><code class=\"language-plaintext highlighter-rouge\">isDir(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#isDir(path:str):bool\n</code></pre>\n\n<p>returns true if <code class=\"language-plaintext highlighter-rouge\">path</code> is a directory.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"listfilesrecursivepath-filter-acc\"><code class=\"language-plaintext highlighter-rouge\">listFilesRecursive(path, filter, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#listFilesRecursive(path:list, filter:fn = fn((s)) : bool {true}, acc = []):list\n</code></pre>\n\n<p>recursively collects all files under the given path(s) matching <code class=\"language-plaintext highlighter-rouge\">filter</code>.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">path</code> is a list of starting paths. Directories are expanded recursively.\n<code class=\"language-plaintext highlighter-rouge\">filter</code> receives each file path and returns true to include it.</p>\n\n<pre><code class=\"language-slug\">listFilesRecursive([\"src\"], fn(s) { endsWith(s, \".slug\") })\n// =&gt; [\"src/main.slug\", \"src/lib/util.slug\", ...]\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">filter</code></td>\n      <td>fn</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">fn((s)) : bool {true}</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"lspath\"><code class=\"language-plaintext highlighter-rouge\">ls(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#ls(path:str):list\n</code></pre>\n\n<p>returns a list of filenames in a directory (non-recursive).</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"mkdirspath\"><code class=\"language-plaintext highlighter-rouge\">mkDirs(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#mkDirs(...path):bool\n</code></pre>\n\n<p>creates all directories in the given path(s), including intermediates.</p>\n\n<p>Returns true on success.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"openfilepath-mode\"><code class=\"language-plaintext highlighter-rouge\">openFile(path, mode)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#openFile(path:str, mode:str):num\n</code></pre>\n\n<p>opens a file in the specified mode and returns a file handle.</p>\n\n<p>Always close the handle with <code class=\"language-plaintext highlighter-rouge\">closeFile</code>. Use <code class=\"language-plaintext highlighter-rouge\">defer closeFile(handle)</code>\nto ensure it is closed even if an error occurs.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">mode</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"readfilepath\"><code class=\"language-plaintext highlighter-rouge\">readFile(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#readFile(path:str):str\n</code></pre>\n\n<p>reads the entire contents of a file and returns it as a string.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"readlinehandle\"><code class=\"language-plaintext highlighter-rouge\">readLine(handle)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#readLine(handle:num):str\n</code></pre>\n\n<p>reads the next line from an open file handle.</p>\n\n<p>Returns <code class=\"language-plaintext highlighter-rouge\">nil</code> at end of file. The returned string includes the trailing\nnewline — use <code class=\"language-plaintext highlighter-rouge\">str[0:-1]</code> to strip it.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"readlinesfile-lines\"><code class=\"language-plaintext highlighter-rouge\">readLines(file, lines)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#readLines(file:num, lines = []):list\n</code></pre>\n\n<p>reads all remaining lines from an open file handle into a list.</p>\n\n<p>Trailing newlines are stripped from each line. Returns an empty list\nif the file is already at EOF.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">file</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">lines</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rmpath\"><code class=\"language-plaintext highlighter-rouge\">rm(path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#rm(path:str):nil\n</code></pre>\n\n<p>removes a file or empty directory at <code class=\"language-plaintext highlighter-rouge\">path</code>.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"writehandle-content\"><code class=\"language-plaintext highlighter-rouge\">write(handle, content)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#write(handle:num, content:str):num\n</code></pre>\n\n<p>writes <code class=\"language-plaintext highlighter-rouge\">content</code> to an open file handle.</p>\n\n<p>Returns the number of bytes written.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">content</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"writefilecontents-path\"><code class=\"language-plaintext highlighter-rouge\">writeFile(contents, path)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.fs#writeFile(contents:str, path:str):nil\n</code></pre>\n\n<p>writes <code class=\"language-plaintext highlighter-rouge\">contents</code> to a file, creating or truncating it.</p>\n\n<p>@effects(‘fs’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">contents</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">path</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.fs",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-io-db",
      "url": "https://sluglang.org/libraries/slug-io-db",
      "title": "db (slug.io)",
      "content_html": "<h2 id=\"slugiodb\">slug.io.db</h2>\n\n<p>slug.io.db — relational database access</p>\n\n<p>Connect to SQLite, MySQL, or PostgreSQL databases and execute queries\nand statements. Connection handles are numeric values returned by <code class=\"language-plaintext highlighter-rouge\">connect</code>\nand passed to all subsequent operations.</p>\n\n<p>Always close connections with <code class=\"language-plaintext highlighter-rouge\">defer close(conn)</code> or explicit <code class=\"language-plaintext highlighter-rouge\">close(conn)</code>.</p>\n\n<h2 id=\"sqlite-examples\">SQLite examples</h2>\n\n<pre><code class=\"language-slug\">val { connect, query, exec, close, SQLITE_DRIVER } = import(\"slug.io.db\")\n\n// in-memory database\nval conn = connect(\":memory:\", SQLITE_DRIVER)\ndefer close(conn)\n\n// file database with options\nval conn = connect(\"file:app.db?cache=shared&amp;mode=rwc\", SQLITE_DRIVER)\ndefer close(conn)\n</code></pre>\n\n<h2 id=\"mysql-example\">MySQL example</h2>\n\n<pre><code class=\"language-slug\">val conn = connect(\"user:pass@tcp(localhost:3306)/dbname?charset=utf8mb4&amp;parseTime=True\", MYSQL_DRIVER)\ndefer close(conn)\n</code></pre>\n\n<h2 id=\"postgresql-example\">PostgreSQL example</h2>\n\n<pre><code class=\"language-slug\">val conn = connect(\"postgres://user:password@localhost/dbname?sslmode=disable\", PGSQL_DRIVER)\ndefer close(conn)\n</code></pre>\n\n<h2 id=\"transactions\">Transactions</h2>\n\n<pre><code class=\"language-slug\">val tx = begin(conn)\nexec(tx, \"INSERT INTO ...\")\ncommit(tx)\n</code></pre>\n\n<p>@effects(‘db’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#mysql_driver\">MYSQL_DRIVER</a></li>\n  <li><a href=\"#pgsql_driver\">PGSQL_DRIVER</a></li>\n  <li><a href=\"#sqlite_driver\">SQLITE_DRIVER</a></li>\n  <li><a href=\"#beginconnection\"><code class=\"language-plaintext highlighter-rouge\">begin(connection)</code></a></li>\n  <li><a href=\"#closeconnection\"><code class=\"language-plaintext highlighter-rouge\">close(connection)</code></a></li>\n  <li><a href=\"#commitconnection\"><code class=\"language-plaintext highlighter-rouge\">commit(connection)</code></a></li>\n  <li><a href=\"#connectconnectionstring-driver\"><code class=\"language-plaintext highlighter-rouge\">connect(connectionString, driver)</code></a></li>\n  <li><a href=\"#execconnection-sql-params\"><code class=\"language-plaintext highlighter-rouge\">exec(connection, sql, params)</code></a></li>\n  <li><a href=\"#queryconnection-sql-params\"><code class=\"language-plaintext highlighter-rouge\">query(connection, sql, params)</code></a></li>\n  <li><a href=\"#rollbackconnection\"><code class=\"language-plaintext highlighter-rouge\">rollback(connection)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"mysql_driver\"><code class=\"language-plaintext highlighter-rouge\">MYSQL_DRIVER</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.db#MYSQL_DRIVER\n</code></pre>\n\n<p>driver string for MySQL connections.</p>\n\n<h4 id=\"pgsql_driver\"><code class=\"language-plaintext highlighter-rouge\">PGSQL_DRIVER</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.db#PGSQL_DRIVER\n</code></pre>\n\n<p>driver string for PostgreSQL connections.</p>\n\n<h4 id=\"sqlite_driver\"><code class=\"language-plaintext highlighter-rouge\">SQLITE_DRIVER</code></h4>\n\n<pre><code class=\"language-slug\">str slug.io.db#SQLITE_DRIVER\n</code></pre>\n\n<p>driver string for SQLite3 connections.</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"beginconnection\"><code class=\"language-plaintext highlighter-rouge\">begin(connection)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#begin(connection:num):num\n</code></pre>\n\n<p>begins a transaction and returns a transaction handle.</p>\n\n<p>Pass the transaction handle to <code class=\"language-plaintext highlighter-rouge\">query</code>, <code class=\"language-plaintext highlighter-rouge\">exec</code>, <code class=\"language-plaintext highlighter-rouge\">commit</code>, or <code class=\"language-plaintext highlighter-rouge\">rollback</code>\nin place of a connection handle.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"closeconnection\"><code class=\"language-plaintext highlighter-rouge\">close(connection)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#close(connection:num):nil\n</code></pre>\n\n<p>closes a database connection or transaction handle.</p>\n\n<p>Always close connections when done. Use <code class=\"language-plaintext highlighter-rouge\">defer close(conn)</code> for safety.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"commitconnection\"><code class=\"language-plaintext highlighter-rouge\">commit(connection)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#commit(connection:num):num\n</code></pre>\n\n<p>commits a transaction.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"connectconnectionstring-driver\"><code class=\"language-plaintext highlighter-rouge\">connect(connectionString, driver)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#connect(connectionString:str, driver:str):num\n</code></pre>\n\n<p>opens a database connection and returns a connection handle.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">connectionString</code> format depends on the driver — see module doc for examples.\nUse <code class=\"language-plaintext highlighter-rouge\">defer close(conn)</code> to ensure the connection is released.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connectionString</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">driver</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"execconnection-sql-params\"><code class=\"language-plaintext highlighter-rouge\">exec(connection, sql, params)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#exec(connection:num, sql:str, ...params):map\n</code></pre>\n\n<p>executes a SQL statement and returns a result map.</p>\n\n<p>The result map contains <code class=\"language-plaintext highlighter-rouge\">rowsAffected</code> and <code class=\"language-plaintext highlighter-rouge\">lastInsertId</code> where supported\nby the driver. Use <code class=\"language-plaintext highlighter-rouge\">...params</code> to pass positional <code class=\"language-plaintext highlighter-rouge\">?</code> parameter values.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sql</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"queryconnection-sql-params\"><code class=\"language-plaintext highlighter-rouge\">query(connection, sql, params)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#query(connection:num, sql:str, ...params):list\n</code></pre>\n\n<p>executes a SQL query and returns the result rows as a list of string-keyed maps.</p>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">...params</code> to pass positional <code class=\"language-plaintext highlighter-rouge\">?</code> parameter values.\nFor named parameters, use <code class=\"language-plaintext highlighter-rouge\">slug.db.repo</code>.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sql</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">params</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"rollbackconnection\"><code class=\"language-plaintext highlighter-rouge\">rollback(connection)</code></h4>\n<pre><code class=\"language-slug\">fn slug.io.db#rollback(connection:num):num\n</code></pre>\n\n<p>rolls back a transaction.</p>\n\n<p>@effects(‘db’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">connection</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.io.db",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-html",
      "url": "https://sluglang.org/libraries/slug-html",
      "title": "html (slug)",
      "content_html": "<h2 id=\"slughtml\">slug.html</h2>\n\n<p>slug.html — basic HTML utilities</p>\n\n<p>Lightweight helpers for working with HTML fragments. Not a full HTML\nparser — intended for simple extraction and unescaping tasks on\nwell-formed markup.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#extractinnertexthtml-tag-start\"><code class=\"language-plaintext highlighter-rouge\">extractInnerText(html, tag, start)</code></a></li>\n  <li><a href=\"#htmlunescapestr\"><code class=\"language-plaintext highlighter-rouge\">htmlUnescape(str)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"extractinnertexthtml-tag-start\"><code class=\"language-plaintext highlighter-rouge\">extractInnerText(html, tag, start)</code></h4>\n<pre><code class=\"language-slug\">fn slug.html#extractInnerText(html:str, tag:str, start:num = 0):str\n</code></pre>\n\n<p>extracts the inner content of the first matching tag in an HTML string.</p>\n\n<p>Handles nested tags of the same type correctly — the inner content is\neverything between the outermost opening and closing tag. Returns an\nempty string if the tag is not found or <code class=\"language-plaintext highlighter-rouge\">start</code> is negative.</p>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">start</code> parameter can be used to search from a specific character\noffset, enabling successive extractions from the same document.</p>\n\n<pre><code class=\"language-slug\">extractInnerText(\"&lt;div&gt;&lt;p&gt;hello&lt;/p&gt;&lt;/div&gt;\", \"p\")\n// =&gt; \"hello\"\n\nextractInnerText(\"&lt;a href='h'&gt;&lt;a&gt;hi&lt;/a&gt;&lt;/a&gt;\", \"a\")\n// =&gt; \"&lt;a&gt;hi&lt;/a&gt;\"\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">html</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tag</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">start</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">extractInnerText(\"&lt;a&gt;hi&lt;/a&gt;\", \"a\", -1)  // =&gt; \"\"\nextractInnerText(\"&lt;a&gt;hi&lt;/a&gt;\", \"div\")  // =&gt; \"\"\nextractInnerText(\"&lt;a&gt;hi&lt;/a&gt;\", \"a\")  // =&gt; \"hi\"\nextractInnerText(\"&lt;a href='h'&gt;&lt;a&gt;hi&lt;/a&gt;&lt;/a&gt;\", \"a\")  // =&gt; \"&lt;a&gt;hi&lt;/a&gt;\"\nextractInnerText(\"&lt;a&gt;&lt;a href='h'&gt;hi&lt;/a&gt;&lt;/a&gt;\", \"a\")  // =&gt; \"&lt;a href='h'&gt;hi&lt;/a&gt;\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"htmlunescapestr\"><code class=\"language-plaintext highlighter-rouge\">htmlUnescape(str)</code></h4>\n<pre><code class=\"language-slug\">fn slug.html#htmlUnescape(str):str\n</code></pre>\n\n<p>decodes common HTML entities in a string.</p>\n\n<p>Handles <code class=\"language-plaintext highlighter-rouge\">&amp;amp;</code>, <code class=\"language-plaintext highlighter-rouge\">&amp;lt;</code>, <code class=\"language-plaintext highlighter-rouge\">&amp;gt;</code>, <code class=\"language-plaintext highlighter-rouge\">&amp;quot;</code>, and <code class=\"language-plaintext highlighter-rouge\">&amp;#39;</code>.\nDoes not handle numeric entities beyond <code class=\"language-plaintext highlighter-rouge\">&amp;#39;</code> or named entities\nbeyond the five listed above.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">htmlUnescape(\"E &amp;amp; S\")  // =&gt; \"E &amp; S\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.html",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-doc-markdown",
      "url": "https://sluglang.org/libraries/slug-doc-markdown",
      "title": "markdown (slug.doc)",
      "content_html": "<h2 id=\"slugdocmarkdown\">slug.doc.markdown</h2>\n\n<p>slug.doc.markdown — Markdown API documentation generator</p>\n\n<p>Reflects over live Slug modules using slug.meta#describe and renders\na single-page markdown file with standard API documentation style.</p>\n\n<p>Each module gets a level-2 section with its doc comment as a lead paragraph,\nfollowed by subsections for Constants, Structs, and Functions. Overloaded\nfunctions are grouped under a single heading with multiple signature blocks.</p>\n\n<p>Output is designed for rendering on GitHub, static site generators, or\nany standard markdown renderer.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#pagepermodulemodulenames-moduletoc\"><code class=\"language-plaintext highlighter-rouge\">pagePerModule(moduleNames, moduleToc)</code></a></li>\n  <li><a href=\"#singlepagemodulenames-title-moduletoc\"><code class=\"language-plaintext highlighter-rouge\">singlePage(moduleNames, title, moduleToc)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"pagepermodulemodulenames-moduletoc\"><code class=\"language-plaintext highlighter-rouge\">pagePerModule(moduleNames, moduleToc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.doc.markdown#pagePerModule(moduleNames:list, moduleToc:bool = false):list\n</code></pre>\n\n<p>generates a multi-page markdown API reference for the given list of module names, returns [name, text].</p>\n\n<p>each module gets a level-2 section with subsections for Constants, Structs, and\nFunctions. overloaded functions are grouped under a single heading. all doc\ncomments are rendered in full.</p>\n\n<p>pass the full dotted module names as they would appear in an import statement.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">moduleNames</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">moduleToc</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"singlepagemodulenames-title-moduletoc\"><code class=\"language-plaintext highlighter-rouge\">singlePage(moduleNames, title, moduleToc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.doc.markdown#singlePage(moduleNames:list, title:str = \"Slug API Reference\", moduleToc:bool = false):str\n</code></pre>\n\n<p>generates a single-page markdown API reference for the given list of module names.</p>\n\n<p>modules are sorted alphabetically. each module gets a level-2 section with\nsubsections for Constants, Structs, and Functions. overloaded functions are\ngrouped under a single heading. all doc comments are rendered in full.</p>\n\n<p>pass the full dotted module names as they would appear in an import statement.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">moduleNames</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">title</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"Slug API Reference\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">moduleToc</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">false</code></td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.doc.markdown",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-doc-manifest",
      "url": "https://sluglang.org/libraries/slug-doc-manifest",
      "title": "manifest (slug.doc)",
      "content_html": "<h2 id=\"slugdocmanifest\">slug.doc.manifest</h2>\n\n<p>slug.doc.manifest — MANIFEST.ai generator</p>\n\n<p>Reflects over live Slug modules using slug.meta#describe and renders\na structured MANIFEST.ai file in the Option 3 block format.</p>\n\n<p>Each exported symbol produces a signature line followed by an indented\nblock of metadata sub-lines. Only sub-lines with content are emitted —\nabsent tags produce no output.</p>\n\n<p>Supported tags</p>\n\n<p>On functions:\n  @returns(‘type’)       return type annotation; rendered on the signature line\n  @effects(‘fs io …’)   space-separated effect labels; rendered as “effects: …”\n  @throws(‘Error{type}’)  thrown error type; rendered under “errors:” block\n  @throwsDesc(‘…’)      cause description paired with @throws; appended to thrown line</p>\n\n<p>On struct fields:\n  @type(‘type’)           field type annotation; rendered on the field line\n  @desc(‘…’)            field description; rendered as “: …” on the field line\n                          field lines are omitted entirely when both tags are absent</p>\n\n<p>Doc comments:\n  The first paragraph of a /** doc comment is extracted and rendered as\n  the desc: sub-line. Paragraphs are separated by blank lines. The first\n  paragraph lines are joined with spaces into a single desc string.\n  Subsequent paragraphs are ignored in MANIFEST output.</p>\n\n<p>Output format example:\n  fn slug.repo#loadQueries(base:str = DefaultBase):map&lt;any, any&gt;\n    desc: “scans base dir for .sql files; returns nested map of query functions”\n    effects: fs\n    errors:\n      thrown: struct(Error) “unexpected filesystem failure”</p>\n\n<p>struct slug.repo#SqlQuery{sql:str, args:list<any>, type:sym}\n    desc: \"result of extractArgs; carries rewritten SQL and inferred statement type\"\n    field cause str: \"the original error that triggered this one\"</any></p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"manifestmodulenames\"><code class=\"language-plaintext highlighter-rouge\">manifest(moduleNames)</code></h4>\n<pre><code class=\"language-slug\">fn slug.doc.manifest#manifest(moduleNames:list):str\n</code></pre>\n\n<p>generates a MANIFEST.ai file for the given list of module names.</p>\n\n<p>modules are sorted alphabetically. within each module, symbols are\nsorted alphabetically. the output contains two sections: modules:section\nlists all module names, symbols:section lists all exported symbols in\nthe Option 3 block format with indented metadata sub-lines.</p>\n\n<p>pass the full dotted module names as they would appear in an import statement.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">moduleNames</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.doc.manifest",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-doc-discover",
      "url": "https://sluglang.org/libraries/slug-doc-discover",
      "title": "discover (slug.doc)",
      "content_html": "<h2 id=\"slugdocdiscover\">slug.doc.discover</h2>\n\n<p>slug.doc.discover — Slug module discovery helper</p>\n\n<p>Scans a source directory recursively for <code class=\"language-plaintext highlighter-rouge\">.slug</code> files and converts each\nfile path into a dotted module name suitable for <code class=\"language-plaintext highlighter-rouge\">import(...)</code>.</p>\n\n<p>The scan is performed relative to the provided directory. Returned module\nnames are normalized by:</p>\n<ul>\n  <li>stripping the base directory prefix</li>\n  <li>converting <code class=\"language-plaintext highlighter-rouge\">/</code> and <code class=\"language-plaintext highlighter-rouge\">\\</code> path separators to <code class=\"language-plaintext highlighter-rouge\">.</code></li>\n  <li>removing any leading dot</li>\n  <li>dropping the <code class=\"language-plaintext highlighter-rouge\">.slug</code> suffix</li>\n</ul>\n\n<p>Example:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>discoverModules(\"lib\")\n// =&gt; [\"slug.doc.discover\", \"slug.doc.manifest\", \"slug.doc.markdown\", ...]\n</code></pre></div></div>\n\n<p>If <code class=\"language-plaintext highlighter-rouge\">dir</code> is <code class=\"language-plaintext highlighter-rouge\">nil</code>, an empty list is returned.</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"discovermodulesdir\"><code class=\"language-plaintext highlighter-rouge\">discoverModules(dir)</code></h4>\n<pre><code class=\"language-slug\">fn slug.doc.discover#discoverModules(dir):list\n</code></pre>\n\n<p>Scans a directory recursively for .slug files and derives dotted module\nnames from their paths relative to the base directory.</p>\n\n<p>e.g. base=”lib”, path=”lib/slug/io/fs.slug” =&gt; “slug.io.fs”</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">dir</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.doc.discover",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-debug",
      "url": "https://sluglang.org/libraries/slug-debug",
      "title": "debug (slug)",
      "content_html": "<h2 id=\"slugdebug\">slug.debug</h2>\n\n<p>slug.debug — runtime debugging utilities</p>\n\n<p>Low-level inspection tools for development and troubleshooting.\nNot intended for production use.</p>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"identvalue\"><code class=\"language-plaintext highlighter-rouge\">ident(value)</code></h4>\n<pre><code class=\"language-slug\">fn slug.debug#ident(value):str\n</code></pre>\n\n<p>returns a stable string identity key for any runtime value.</p>\n\n<p>Useful for distinguishing two values that print identically but are\ndistinct runtime objects, or for using values as map keys in contexts\nwhere their string representation would collide.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">value</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.debug",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-db-repo",
      "url": "https://sluglang.org/libraries/slug-db-repo",
      "title": "repo (slug.db)",
      "content_html": "<h2 id=\"slugdbrepo\">slug.db.repo</h2>\n\n<p>slug.db.repo — file-based SQL query loader with named parameter extraction and schema mapping</p>\n\n<p>Scans a directory of <code class=\"language-plaintext highlighter-rouge\">.sql</code> files and builds a nested map of ready-to-call\nquery functions that mirrors the folder structure. Named parameters in SQL\n(<code class=\"language-plaintext highlighter-rouge\">:param</code>) are extracted and rewritten to <code class=\"language-plaintext highlighter-rouge\">?</code> placeholders automatically.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { loadQueries, into } = import(\"slug.db.repo\")\nval { connect, SQLITE_DRIVER } = import(\"slug.io.db\")\n\nval conn  = connect(\"file:app.db\", SQLITE_DRIVER)\nval repos = loadQueries()\n\n// db/queries/users/byAge.sql: SELECT * FROM users WHERE age &gt; :age\nval users = conn /&gt; repos.users.byAge({ age: 25 }) /&gt; into(User)\n</code></pre>\n\n<h2 id=\"sql-file-layout\">SQL file layout</h2>\n\n<p>Files are discovered recursively under the base directory. The path\nrelative to the base becomes the nested map key:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>db/queries/users/byAge.sql  =&gt;  repos.users.byAge(conn, args)\ndb/queries/posts/recent.sql =&gt;  repos.posts.recent(conn, args)\n</code></pre></div></div>\n\n<h2 id=\"named-parameters\">Named parameters</h2>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">:paramName</code> in SQL to define named parameters. They are rewritten\nto <code class=\"language-plaintext highlighter-rouge\">?</code> placeholders and extracted in order. Parameters inside string\nliterals and comments are safely ignored.</p>\n\n<p>Pass args as a <code class=\"language-plaintext highlighter-rouge\">map</code> (<code class=\"language-plaintext highlighter-rouge\">{ age: 25 }</code>), a <code class=\"language-plaintext highlighter-rouge\">list</code> (<code class=\"language-plaintext highlighter-rouge\">[25]</code>), or a struct.</p>\n\n<h2 id=\"query-type-detection\">Query type detection</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">SELECT</code>/<code class=\"language-plaintext highlighter-rouge\">WITH</code> statements call <code class=\"language-plaintext highlighter-rouge\">query()</code> (returns <code class=\"language-plaintext highlighter-rouge\">list</code>).\nAll other statements call <code class=\"language-plaintext highlighter-rouge\">exec()</code> (returns <code class=\"language-plaintext highlighter-rouge\">map</code>).</p>\n\n<p>@effects(‘fs db’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#intodata-totype-columntofieldname\"><code class=\"language-plaintext highlighter-rouge\">into(data, toType, columnToFieldName)</code></a></li>\n  <li><a href=\"#loadqueriesbase\"><code class=\"language-plaintext highlighter-rouge\">loadQueries(base)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"intodata-totype-columntofieldname\"><code class=\"language-plaintext highlighter-rouge\">into(data, toType, columnToFieldName)</code></h4>\n<pre><code class=\"language-slug\">fn slug.db.repo#into(data:list, toType, columnToFieldName:fn = fn((s)) {camelCase(s, _)}):list\nfn slug.db.repo#into(data:map, target, columnToFieldName:fn = fn((s)) {camelCase(s, _)}):any\n</code></pre>\n\n<p>maps a list of db result rows onto a struct or map target.</p>\n\n<p>Delegates each row to the <code class=\"language-plaintext highlighter-rouge\">map</code> variant. Column names are normalised\nfrom <code class=\"language-plaintext highlighter-rouge\">snake_case</code> to <code class=\"language-plaintext highlighter-rouge\">camelCase</code> by default.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">data</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">toType</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">columnToFieldName</code></td>\n      <td>fn</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">fn((s)) {camelCase(s, _)}</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"loadqueriesbase\"><code class=\"language-plaintext highlighter-rouge\">loadQueries(base)</code></h4>\n<pre><code class=\"language-slug\">fn slug.db.repo#loadQueries(base:str = DefaultBase):map\n</code></pre>\n\n<p>scans <code class=\"language-plaintext highlighter-rouge\">base</code> recursively for <code class=\"language-plaintext highlighter-rouge\">.sql</code> files and returns a nested map of query functions.</p>\n\n<p>Each leaf is a <code class=\"language-plaintext highlighter-rouge\">fn(conn, args)</code> that executes the query against <code class=\"language-plaintext highlighter-rouge\">conn</code>.\nThe map structure mirrors the directory structure under <code class=\"language-plaintext highlighter-rouge\">base</code>.\nThe default base directory is <code class=\"language-plaintext highlighter-rouge\">db/queries</code> or the <code class=\"language-plaintext highlighter-rouge\">base-directory</code> config key.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultBase</code></td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.db.repo",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-db-migration",
      "url": "https://sluglang.org/libraries/slug-db-migration",
      "title": "migration (slug.db)",
      "content_html": "<h2 id=\"slugdbmigration\">slug.db.migration</h2>\n\n<p>slug.db.migration — SQL schema migration runner</p>\n\n<p>Applies, rolls back, and reports on versioned SQL migration scripts\nstored as <code class=\"language-plaintext highlighter-rouge\">.sql</code> files on the filesystem.</p>\n\n<h2 id=\"file-naming-convention\">File naming convention</h2>\n\n<p>Migration files must follow the pattern:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>&lt;version&gt;__&lt;description&gt;.sql\n&lt;version&gt;__&lt;environment&gt;__&lt;description&gt;.sql\n</code></pre></div></div>\n\n<p>Examples:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>db/migrations/001__create_users.sql\ndb/migrations/002__production__add_index.sql\n</code></pre></div></div>\n\n<p>Files are sorted and applied in ascending version order.</p>\n\n<h2 id=\"script-sections\">Script sections</h2>\n\n<p>Each <code class=\"language-plaintext highlighter-rouge\">.sql</code> file may contain <code class=\"language-plaintext highlighter-rouge\">-- @up</code> and <code class=\"language-plaintext highlighter-rouge\">-- @down</code> section markers.\nThe <code class=\"language-plaintext highlighter-rouge\">up</code> section is applied on <code class=\"language-plaintext highlighter-rouge\">up</code>, the <code class=\"language-plaintext highlighter-rouge\">down</code> section on <code class=\"language-plaintext highlighter-rouge\">down</code>.\nIf no markers are present, the entire file is treated as the <code class=\"language-plaintext highlighter-rouge\">up</code> script.</p>\n\n<div class=\"language-sql highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c1\">-- @up</span>\n<span class=\"k\">CREATE</span> <span class=\"k\">TABLE</span> <span class=\"n\">users</span> <span class=\"p\">(</span><span class=\"n\">id</span> <span class=\"nb\">INTEGER</span> <span class=\"k\">PRIMARY</span> <span class=\"k\">KEY</span><span class=\"p\">,</span> <span class=\"n\">name</span> <span class=\"nb\">TEXT</span><span class=\"p\">);</span>\n\n<span class=\"c1\">-- @down</span>\n<span class=\"k\">DROP</span> <span class=\"k\">TABLE</span> <span class=\"n\">users</span><span class=\"p\">;</span>\n</code></pre></div></div>\n\n<h2 id=\"tracking-table\">Tracking table</h2>\n\n<p>Applied migrations are recorded in a <code class=\"language-plaintext highlighter-rouge\">slug_schema_migrations</code> table\nwhich is created automatically on first run. Each entry stores the\nversion, environment, filename, SHA-256 checksum, and success status.</p>\n\n<h2 id=\"configuration\">Configuration</h2>\n\n<p>Default base directory and environment can be set via <code class=\"language-plaintext highlighter-rouge\">cfg</code>:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>base-directory = db/migrations\nenvironment    = production\n</code></pre></div></div>\n\n<p>@effects(‘fs db’)</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#migration\">Migration</a></li>\n  <li><a href=\"#downconn-step-base\"><code class=\"language-plaintext highlighter-rouge\">down(conn, step, base)</code></a></li>\n  <li><a href=\"#statusconn-env-base\"><code class=\"language-plaintext highlighter-rouge\">status(conn, env, base)</code></a></li>\n  <li><a href=\"#upconn-env-base\"><code class=\"language-plaintext highlighter-rouge\">up(conn, env, base)</code></a></li>\n</ul>\n\n<h3 id=\"structs\">Structs</h3>\n\n<h4 id=\"migration\"><code class=\"language-plaintext highlighter-rouge\">Migration</code></h4>\n<pre><code class=\"language-slug\">struct slug.db.migration#Migration{id:num, version:str, environment:str, filename:str, checksum:str, success:bool, appliedAt:str}\n</code></pre>\n\n<p>represents a migration record as stored in the tracking table.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Default</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">id</code></td>\n      <td>num</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">version</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">environment</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">filename</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">checksum</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">success</code></td>\n      <td>bool</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">appliedAt</code></td>\n      <td>str</td>\n      <td>—</td>\n      <td> </td>\n    </tr>\n  </tbody>\n</table>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"downconn-step-base\"><code class=\"language-plaintext highlighter-rouge\">down(conn, step, base)</code></h4>\n<pre><code class=\"language-slug\">fn slug.db.migration#down(conn:num, step:num = 1, base:str = DefaultBase):num\n</code></pre>\n\n<p>rolls back the most recently applied migrations.</p>\n\n<p>Applies the <code class=\"language-plaintext highlighter-rouge\">-- @down</code> section of each rolled-back migration script\nand removes its entry from the tracking table. <code class=\"language-plaintext highlighter-rouge\">step</code> controls how\nmany migrations to roll back (default 1).</p>\n\n<p>Returns the connection handle for chaining.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">conn</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">step</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultBase</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"statusconn-env-base\"><code class=\"language-plaintext highlighter-rouge\">status(conn, env, base)</code></h4>\n<pre><code class=\"language-slug\">fn slug.db.migration#status(conn:num, env:list = DefaultEnv, base:str = DefaultBase):num\n</code></pre>\n\n<p>prints the status of all migration files against the database.</p>\n\n<p>Each migration is reported as APPLIED, MISSING, or INELIGIBLE (for\nenvironments not in <code class=\"language-plaintext highlighter-rouge\">env</code>). Applied migrations whose checksum no longer\nmatches the file will throw <code class=\"language-plaintext highlighter-rouge\">MigrationError</code>.</p>\n\n<p>Returns the connection handle for chaining.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">conn</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">env</code></td>\n      <td>list</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultEnv</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultBase</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:MigrationError}</code></p>\n\n<hr />\n\n<h4 id=\"upconn-env-base\"><code class=\"language-plaintext highlighter-rouge\">up(conn, env, base)</code></h4>\n<pre><code class=\"language-slug\">fn slug.db.migration#up(conn:num, env:list = DefaultEnv, base:str = DefaultBase):num\n</code></pre>\n\n<p>applies all pending eligible migrations in ascending version order.</p>\n\n<p>Skips already-applied migrations and migrations for ineligible environments.\nOn failure, records the migration as failed and rethrows the error.</p>\n\n<p>Returns the connection handle for chaining.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">conn</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">env</code></td>\n      <td>list</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultEnv</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">base</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">DefaultBase</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:MigrationError}</code></p>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.db.migration",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-csv",
      "url": "https://sluglang.org/libraries/slug-csv",
      "title": "csv (slug)",
      "content_html": "<h2 id=\"slugcsv\">slug.csv</h2>\n\n<p>slug.csv — CSV parsing and serialisation</p>\n\n<p>Parses CSV strings into lists of rows and serialises lists of rows back\nto CSV strings. Handles quoted fields, embedded newlines, escaped quotes,\nand configurable separators.</p>\n\n<p>Rows are represented as <code class=\"language-plaintext highlighter-rouge\">list</code> values. Columns are accessed by index:\n<code class=\"language-plaintext highlighter-rouge\">row[0]</code> for the first column, <code class=\"language-plaintext highlighter-rouge\">row[1]</code> for the second, and so on.</p>\n\n<h2 id=\"example\">Example</h2>\n\n<pre><code class=\"language-slug\">val { fromCsvString, toCsv } = import(\"slug.csv\")\n\nval rows = fromCsvString(\"name,age\\r\\nAlice,30\\r\\nBob,25\")\nrows[0]  // =&gt; [\"name\", \"age\"]\nrows[1]  // =&gt; [\"Alice\", \"30\"]\n\ntoCsv([[\"name\", \"age\"], [\"Alice\", \"30\"]])\n// =&gt; \"name,age\\r\\nAlice,30\\r\\n\"\n</code></pre>\n\n<h2 id=\"quoting-rules\">Quoting rules</h2>\n\n<p>Fields are automatically quoted during serialisation if they contain\nthe separator, the quote character, a newline, or a carriage return.\nQuote characters within a field are escaped by doubling: <code class=\"language-plaintext highlighter-rouge\">\"</code> → <code class=\"language-plaintext highlighter-rouge\">\"\"</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#fromcsvstringcsvstr-sep-quote\"><code class=\"language-plaintext highlighter-rouge\">fromCsvString(csvStr, sep, quote)</code></a></li>\n  <li><a href=\"#tocsvrows-sep-quote-eol-acc\"><code class=\"language-plaintext highlighter-rouge\">toCsv(rows, sep, quote, eol, acc)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"fromcsvstringcsvstr-sep-quote\"><code class=\"language-plaintext highlighter-rouge\">fromCsvString(csvStr, sep, quote)</code></h4>\n<pre><code class=\"language-slug\">fn slug.csv#fromCsvString(csvStr:str, sep:str = \",\", quote:str = \"\\\"\"):list&lt;list&lt;str&gt;&gt;\n</code></pre>\n\n<p>parses a CSV string into a list of rows, where each row is a list of strings.</p>\n\n<p>Handles quoted fields (including embedded newlines and escaped quotes),\nCRLF and LF line endings, and configurable separator and quote characters.\nAccess columns by index: <code class=\"language-plaintext highlighter-rouge\">row[0]</code>, <code class=\"language-plaintext highlighter-rouge\">row[1]</code>, etc.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">csvStr</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\",\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">quote</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\\\"\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">fromCsvString(\"a,b,c\")  // =&gt; [[\"a\", \"b\", \"c\"]]\nfromCsvString(\"a,b,c\nd,\"e\n f\",g\")  // =&gt; [[\"a\", \"b\", \"c\"], [\"d\", \"e\n f\", \"g\"]]\n</code></pre>\n\n<hr />\n\n<h4 id=\"tocsvrows-sep-quote-eol-acc\"><code class=\"language-plaintext highlighter-rouge\">toCsv(rows, sep, quote, eol, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.csv#toCsv(rows:list&lt;list&lt;str&gt;&gt;, sep:str = \",\", quote:str = \"\\\"\", eol:str = \"\\r\\n\", acc:str = \"\"):str\n</code></pre>\n\n<p>converts a list of rows (each a list of strings) to a CSV string.</p>\n\n<p>Fields are quoted automatically when they contain the separator, quote\ncharacter, or newline characters. The default line ending is <code class=\"language-plaintext highlighter-rouge\">\\r\\n</code>\n(RFC 4180). Each row is terminated by <code class=\"language-plaintext highlighter-rouge\">eol</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">rows</code></td>\n      <td>list&lt;list<str>&gt;</str></td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sep</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\",\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">quote</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\\\"\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">eol</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\\r\\n\"</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">toCsv([[\"a\", \"b\"]])  // =&gt; \"a,b\n\"\ntoCsv([[\"a\", \"b\"], [\"c\", \"d\"]])  // =&gt; \"a,b\nc,d\n\"\ntoCsv([[\"a\n\", \"qu\"ote\"]])  // =&gt; \"\"a\n\",\"qu\"\"ote\"\n\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.csv",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-crypto",
      "url": "https://sluglang.org/libraries/slug-crypto",
      "title": "crypto (slug)",
      "content_html": "<h2 id=\"slugcrypto\">slug.crypto</h2>\n\n<p>slug.crypto — cryptographic hash and HMAC functions</p>\n\n<p>Provides MD5, SHA-256, SHA-512, and HMAC variants. Each algorithm is\navailable in two forms:</p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">bytes</code> in → <code class=\"language-plaintext highlighter-rouge\">bytes</code> out — raw digest, useful for chaining or binary protocols</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">str</code> in → <code class=\"language-plaintext highlighter-rouge\">str</code> out — hex (for hashes) or base64 (for HMACs) encoded output</li>\n</ul>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">str</code> variants are the most common for web and API use cases.\nThe <code class=\"language-plaintext highlighter-rouge\">bytes</code> variants are lower-level and intended for composition.</p>\n\n<h2 id=\"example\">Example</h2>\n\n<pre><code class=\"language-slug\">val { sha256, hmacSha256 } = import(\"slug.crypto\")\n\nsha256(\"hello\")\n// =&gt; \"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824\"\n\nhmacSha256(\"hello\", \"slug\")\n// =&gt; \"NB9NMraxEE8IBLRWWoBShv99Pclb8b2Qqt6KxykFxx0=\"\n</code></pre>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#hmacsha256message-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha256(message, secret)</code></a></li>\n  <li><a href=\"#hmacsha256hexmessage-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha256Hex(message, secret)</code></a></li>\n  <li><a href=\"#hmacsha512message-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha512(message, secret)</code></a></li>\n  <li><a href=\"#hmacsha512hexmessage-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha512Hex(message, secret)</code></a></li>\n  <li><a href=\"#md5bytes\"><code class=\"language-plaintext highlighter-rouge\">md5(bytes)</code></a></li>\n  <li><a href=\"#sha256bytes\"><code class=\"language-plaintext highlighter-rouge\">sha256(bytes)</code></a></li>\n  <li><a href=\"#sha512bytes\"><code class=\"language-plaintext highlighter-rouge\">sha512(bytes)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"hmacsha256message-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha256(message, secret)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#hmacSha256(message:bytes, secret:bytes):bytes\nfn slug.crypto#hmacSha256(message:str, secret:str):str\n</code></pre>\n\n<p>returns the HMAC-SHA256 of a raw byte message using a raw byte key.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">secret</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">hmacSha256(\"hello\", \"slug\")  // =&gt; \"NB9NMraxEE8IBLRWWoBShv99Pclb8b2Qqt6KxykFxx0=\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"hmacsha256hexmessage-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha256Hex(message, secret)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#hmacSha256Hex(message:str, secret:str):str\n</code></pre>\n\n<p>returns the HMAC-SHA256 of a message using a secret key, as a hex string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">secret</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">hmacSha256Hex(\"hello\", \"slug\")  // =&gt; \"341f4d32b6b1104f0804b4565a805286ff7d3dc95bf1bd90aade8ac72905c71d\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"hmacsha512message-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha512(message, secret)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#hmacSha512(message:bytes, secret:bytes):bytes\nfn slug.crypto#hmacSha512(message:str, secret:str):str\n</code></pre>\n\n<p>returns the HMAC-SHA512 of a raw byte message using a raw byte key.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">secret</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">hmacSha512(\"hello\", \"slug\")  // =&gt; \"Yddv60iFAaAuAgusykYLW2fFE1LP8t14xw2ghx0VseQJAwANJ+OkKzRhoZltwUs8LqpdmtPR4lBbsW+5M+Ugkw==\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"hmacsha512hexmessage-secret\"><code class=\"language-plaintext highlighter-rouge\">hmacSha512Hex(message, secret)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#hmacSha512Hex(message:str, secret:str):str\n</code></pre>\n\n<p>returns the HMAC-SHA512 of a message using a secret key, as a hex string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">message</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">secret</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">hmacSha512Hex(\"hello\", \"slug\")  // =&gt; \"61d76feb488501a02e020bacca460b5b67c51352cff2dd78c70da0871d15b1e40903000d27e3a42b3461a1996dc14b3c2eaa5d9ad3d1e2505bb16fb933e52093\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"md5bytes\"><code class=\"language-plaintext highlighter-rouge\">md5(bytes)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#md5(bytes:bytes):bytes\nfn slug.crypto#md5(str:str):str\n</code></pre>\n\n<p>returns the MD5 hex digest of a string.</p>\n\n<p>MD5 is not cryptographically secure — use for checksums and legacy\ncompatibility only, not for security-sensitive applications.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">bytes</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">md5(\"hello\")  // =&gt; \"5d41402abc4b2a76b9719d911017c592\"\nmd5(\"\")  // =&gt; \"d41d8cd98f00b204e9800998ecf8427e\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"sha256bytes\"><code class=\"language-plaintext highlighter-rouge\">sha256(bytes)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#sha256(bytes:bytes):bytes\nfn slug.crypto#sha256(str:str):str\n</code></pre>\n\n<p>returns the SHA-256 hex digest of a string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">bytes</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-5\">Examples</h4>\n\n<pre><code class=\"language-slug\">sha256(\"hello\")  // =&gt; \"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824\"\nsha256(\"\")  // =&gt; \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"sha512bytes\"><code class=\"language-plaintext highlighter-rouge\">sha512(bytes)</code></h4>\n<pre><code class=\"language-slug\">fn slug.crypto#sha512(bytes:bytes):bytes\nfn slug.crypto#sha512(str:str):str\n</code></pre>\n\n<p>returns the SHA-512 hex digest of a string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">bytes</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-6\">Examples</h4>\n\n<pre><code class=\"language-slug\">sha512(\"hello\")  // =&gt; \"9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043\"\nsha512(\"\")  // =&gt; \"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.crypto",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-cli",
      "url": "https://sluglang.org/libraries/slug-cli",
      "title": "cli (slug)",
      "content_html": "<h2 id=\"slugcli\">slug.cli</h2>\n\n<p>slug.cli — command-line interface utilities</p>\n\n<p>Provides <code class=\"language-plaintext highlighter-rouge\">opt</code> for simple multi-source option coercion and <code class=\"language-plaintext highlighter-rouge\">argsWith</code>\nfor full declarative CLI argument parsing, validation, and help generation.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { argsWith } = import(\"slug.cli\")\n\nval spec = {\n  name:    \"backup\",\n  version: \"1.2.0\",\n  summary: \"Backup files to a remote location\",\n  strict: false,\n  alias:    { a: \"all\", u: \"user\" },\n  required: [\"user\"],\n  defaults: { all: false },\n  types:    { all: \"bool\", user: \"str\" },\n  desc:     { user: \"User account to run as\", all: \"Process all files\" },\n  positional: { min: 1, max: 1, name: \"file\" },\n}\n\nval result = argm() /&gt; argsWith(spec)\n\nmatch result {\n  { ok: true, options, positional } =&gt; run(options, positional)\n  { action: :help,    text }        =&gt; { println(text); import(\"slug.sys\").exit(0) }\n  { action: :version, text }        =&gt; { println(text); import(\"slug.sys\").exit(0) }\n  { errors }                        =&gt; { errors /&gt; map(fn(e) { println(e.msg) }); import(\"slug.sys\").exit(1) }\n}\n</code></pre>\n\n<h2 id=\"result-shapes\">Result shapes</h2>\n\n<p><code class=\"language-plaintext highlighter-rouge\">argsWith</code> always returns a map. The <code class=\"language-plaintext highlighter-rouge\">ok</code> field is the primary discriminator:</p>\n\n<p><strong>Success:</strong> <code class=\"language-plaintext highlighter-rouge\">{ ok: true, action: :none, options: map, positional: list, errors: [] }</code></p>\n\n<p><strong>Help/version:</strong> <code class=\"language-plaintext highlighter-rouge\">{ ok: false, action: :help | :version, text: str, options: {}, positional: [], errors: [] }</code></p>\n\n<p><strong>Validation failure:</strong> <code class=\"language-plaintext highlighter-rouge\">{ ok: false, action: :error, options: {}, positional: [], errors: list }</code></p>\n\n<h2 id=\"spec-fields\">Spec fields</h2>\n\n<table>\n  <thead>\n    <tr>\n      <th>Field</th>\n      <th>Type</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>Program name; used in help and version output</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">version</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>Version string; enables <code class=\"language-plaintext highlighter-rouge\">--version</code> / <code class=\"language-plaintext highlighter-rouge\">-v</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">summary</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">str</code></td>\n      <td>One-line description shown in help</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">strict</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">bool</code></td>\n      <td>Allow unrecognized parameters, true to treat as an error</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">alias</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Short name → canonical name; e.g. <code class=\"language-plaintext highlighter-rouge\">{ u: \"user\" }</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">required</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>Canonical option names that must be present</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">defaults</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Default values by canonical name</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">types</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Type hints: <code class=\"language-plaintext highlighter-rouge\">\"bool\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"str\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"num\"</code>, <code class=\"language-plaintext highlighter-rouge\">\"list\"</code> by canonical name</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">desc</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td>Option descriptions by canonical name</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">allow</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">list</code></td>\n      <td>Explicit allowlist; inferred from other fields if omitted</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">positional</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">map</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">{ min, max?, name }</code> positional argument constraints</td>\n    </tr>\n  </tbody>\n</table>\n\n<h2 id=\"error-shapes\">Error shapes</h2>\n\n<p>Each entry in <code class=\"language-plaintext highlighter-rouge\">errors</code> is a map with a <code class=\"language-plaintext highlighter-rouge\">type</code> and <code class=\"language-plaintext highlighter-rouge\">msg</code> field:</p>\n\n<table>\n  <thead>\n    <tr>\n      <th><code class=\"language-plaintext highlighter-rouge\">type</code></th>\n      <th>Extra fields</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"missing-required\"</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">option</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"unknown-option\"</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">option</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"invalid-type\"</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">option</code>, <code class=\"language-plaintext highlighter-rouge\">expected</code>, <code class=\"language-plaintext highlighter-rouge\">value</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"positional-min\"</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">min</code>, <code class=\"language-plaintext highlighter-rouge\">actual</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">\"positional-max\"</code></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">max</code>, <code class=\"language-plaintext highlighter-rouge\">actual</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#argswithraw-spec\"><code class=\"language-plaintext highlighter-rouge\">argsWith(raw, spec)</code></a></li>\n  <li><a href=\"#helptextspec\"><code class=\"language-plaintext highlighter-rouge\">helpText(spec)</code></a></li>\n  <li><a href=\"#optargs\"><code class=\"language-plaintext highlighter-rouge\">opt(args)</code></a></li>\n  <li><a href=\"#versiontextspec\"><code class=\"language-plaintext highlighter-rouge\">versionText(spec)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"argswithraw-spec\"><code class=\"language-plaintext highlighter-rouge\">argsWith(raw, spec)</code></h4>\n<pre><code class=\"language-slug\">fn slug.cli#argsWith(raw, spec):any\n</code></pre>\n\n<p>parses, normalizes, validates, and coerces CLI arguments against a spec.</p>\n\n<p>Receives the map returned by <code class=\"language-plaintext highlighter-rouge\">argm()</code> and returns a structured result.\nNever prints or exits — the caller decides how to handle each outcome.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">--help</code> / <code class=\"language-plaintext highlighter-rouge\">-h</code> are handled automatically and always take precedence.\n<code class=\"language-plaintext highlighter-rouge\">--version</code> / <code class=\"language-plaintext highlighter-rouge\">-v</code> are handled automatically when <code class=\"language-plaintext highlighter-rouge\">spec.version</code> is set.</p>\n\n<p>Processing order:</p>\n<ol>\n  <li>Check for <code class=\"language-plaintext highlighter-rouge\">--help</code> / <code class=\"language-plaintext highlighter-rouge\">-h</code> → return help action</li>\n  <li>Check for <code class=\"language-plaintext highlighter-rouge\">--version</code> / <code class=\"language-plaintext highlighter-rouge\">-v</code> → return version action</li>\n  <li>Resolve aliases to canonical option names</li>\n  <li>Apply defaults for missing options</li>\n  <li>Coerce option values to declared types</li>\n  <li>Validate: unknown options, required options, positional bounds</li>\n  <li>Return success or error result</li>\n</ol>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">raw</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">spec</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"helptextspec\"><code class=\"language-plaintext highlighter-rouge\">helpText(spec)</code></h4>\n<pre><code class=\"language-slug\">fn slug.cli#helpText(spec):any\n</code></pre>\n\n<p>renders the help text for a spec as a string.</p>\n\n<p>Produces the same output that <code class=\"language-plaintext highlighter-rouge\">argsWith</code> returns under <code class=\"language-plaintext highlighter-rouge\">action: :help</code>.\nUseful for displaying help outside the normal argument parsing flow.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">spec</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"optargs\"><code class=\"language-plaintext highlighter-rouge\">opt(args)</code></h4>\n<pre><code class=\"language-slug\">fn slug.cli#opt(...args):any\n</code></pre>\n\n<p>returns the first non-nil value from <code class=\"language-plaintext highlighter-rouge\">args</code>, coerced to the type of the last argument.</p>\n\n<p>The last argument acts as both the default value and the type hint.\nIf all arguments are nil, returns nil. Throws <code class=\"language-plaintext highlighter-rouge\">TypeError</code> if coercion\nis not possible.</p>\n\n<pre><code class=\"language-slug\">val port = opt(args.options.port, args.options.p, 8080)\n</code></pre>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">args</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:TypeError}</code></p>\n\n<hr />\n\n<h4 id=\"versiontextspec\"><code class=\"language-plaintext highlighter-rouge\">versionText(spec)</code></h4>\n<pre><code class=\"language-slug\">fn slug.cli#versionText(spec):any\n</code></pre>\n\n<p>renders the version text for a spec as a string.</p>\n\n<p>Produces the same output that <code class=\"language-plaintext highlighter-rouge\">argsWith</code> returns under <code class=\"language-plaintext highlighter-rouge\">action: :version</code>.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">spec</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.cli",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-channel",
      "url": "https://sluglang.org/libraries/slug-channel",
      "title": "channel (slug)",
      "content_html": "<h2 id=\"slugchannel\">slug.channel</h2>\n\n<p>slug.channel — channel-based concurrency primitives</p>\n\n<p>Provides buffered and unbuffered channels for communicating between\nconcurrent tasks, following Slug’s structured concurrency model.</p>\n\n<p>Channels are created with <code class=\"language-plaintext highlighter-rouge\">chan()</code> and closed with <code class=\"language-plaintext highlighter-rouge\">close()</code>. Use <code class=\"language-plaintext highlighter-rouge\">send</code>\nand <code class=\"language-plaintext highlighter-rouge\">recv</code> for blocking operations, or <code class=\"language-plaintext highlighter-rouge\">trySend</code>/<code class=\"language-plaintext highlighter-rouge\">tryRecv</code> for\nnon-blocking variants. Use <code class=\"language-plaintext highlighter-rouge\">await</code> to block until a spawned task completes.</p>\n\n<h2 id=\"example\">Example</h2>\n\n<pre><code class=\"language-slug\">val { chan, send, recv, close } = import(\"slug.channel\")\n\nval ch = chan()\n\nnursery {\n  spawn { send(ch, \"hello\") }\n  val msg = recv(ch)\n  println(msg)  // =&gt; \"hello\"\n}\n\nclose(ch)\n</code></pre>\n\n<h2 id=\"timeouts\">Timeouts</h2>\n\n<p>Both <code class=\"language-plaintext highlighter-rouge\">recv</code> and <code class=\"language-plaintext highlighter-rouge\">await</code> accept an optional <code class=\"language-plaintext highlighter-rouge\">timeout</code> in milliseconds.\nA timeout of <code class=\"language-plaintext highlighter-rouge\">0</code> (default) means wait indefinitely. When a timeout\nelapses a <code class=\"language-plaintext highlighter-rouge\">TimeoutError</code> is thrown.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#awaithandle-timeout\"><code class=\"language-plaintext highlighter-rouge\">await(handle, timeout)</code></a></li>\n  <li><a href=\"#chancapacity\"><code class=\"language-plaintext highlighter-rouge\">chan(capacity)</code></a></li>\n  <li><a href=\"#closechannel\"><code class=\"language-plaintext highlighter-rouge\">close(channel)</code></a></li>\n  <li><a href=\"#recvchannel-timeout\"><code class=\"language-plaintext highlighter-rouge\">recv(channel, timeout)</code></a></li>\n  <li><a href=\"#sendchannel-payload\"><code class=\"language-plaintext highlighter-rouge\">send(channel, payload)</code></a></li>\n  <li><a href=\"#tryrecvchannel\"><code class=\"language-plaintext highlighter-rouge\">tryRecv(channel)</code></a></li>\n  <li><a href=\"#trysendchannel-payload\"><code class=\"language-plaintext highlighter-rouge\">trySend(channel, payload)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"awaithandle-timeout\"><code class=\"language-plaintext highlighter-rouge\">await(handle, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#await(handle:task, timeout:num = 0):any\n</code></pre>\n\n<p>waits for a spawned task to complete and returns its result.</p>\n\n<p>If <code class=\"language-plaintext highlighter-rouge\">timeout</code> is greater than 0 and the task does not complete within\nthat many milliseconds, a <code class=\"language-plaintext highlighter-rouge\">TimeoutError</code> is thrown.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">handle</code></td>\n      <td>task</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:TimeoutError}</code></p>\n\n<hr />\n\n<h4 id=\"chancapacity\"><code class=\"language-plaintext highlighter-rouge\">chan(capacity)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#chan(capacity:num = 0):chan&lt;any|nil&gt;\n</code></pre>\n\n<p>creates a new channel with an optional buffer capacity.</p>\n\n<p>An unbuffered channel (capacity 0) blocks the sender until a receiver\nis ready. A buffered channel allows up to <code class=\"language-plaintext highlighter-rouge\">capacity</code> messages to be\nqueued before blocking.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">capacity</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"closechannel\"><code class=\"language-plaintext highlighter-rouge\">close(channel)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#close(channel:chan&lt;any|nil&gt;):nil\n</code></pre>\n\n<p>closes a channel, signalling that no more values will be sent.</p>\n\n<p>Receivers on a closed channel return nil. Sending to a closed channel\nis a runtime error.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">channel</code></td>\n      <td>chan&lt;any | nil&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"recvchannel-timeout\"><code class=\"language-plaintext highlighter-rouge\">recv(channel, timeout)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#recv(channel:chan&lt;any|nil&gt;, timeout:num = 0):any\n</code></pre>\n\n<p>receives a value from a channel, blocking until one is available.</p>\n\n<p>If <code class=\"language-plaintext highlighter-rouge\">timeout</code> is greater than 0 and no value arrives within that many\nmilliseconds, a <code class=\"language-plaintext highlighter-rouge\">TimeoutError</code> is thrown.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">channel</code></td>\n      <td>chan&lt;any | nil&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">timeout</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Throws:</strong> <code class=\"language-plaintext highlighter-rouge\">Error{type:TimeoutError}</code></p>\n\n<hr />\n\n<h4 id=\"sendchannel-payload\"><code class=\"language-plaintext highlighter-rouge\">send(channel, payload)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#send(channel:chan&lt;any|nil&gt;, payload):any\n</code></pre>\n\n<p>sends a value to a channel, blocking until a receiver is ready.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">payload</code> must not be nil.</p>\n\n<p>Returns the channel, allowing chains: <code class=\"language-plaintext highlighter-rouge\">ch /&gt; send(\"a\") /&gt; send(\"b\")</code></p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">channel</code></td>\n      <td>chan&lt;any | nil&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">payload</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"tryrecvchannel\"><code class=\"language-plaintext highlighter-rouge\">tryRecv(channel)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#tryRecv(channel:chan&lt;any|nil&gt;):any\n</code></pre>\n\n<p>attempts to receive a value from a channel without blocking.</p>\n\n<p>Returns the next value if one is immediately available, nil otherwise.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">channel</code></td>\n      <td>chan&lt;any | nil&gt;</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"trysendchannel-payload\"><code class=\"language-plaintext highlighter-rouge\">trySend(channel, payload)</code></h4>\n<pre><code class=\"language-slug\">fn slug.channel#trySend(channel:chan&lt;any|nil&gt;, payload):any\n</code></pre>\n\n<p>attempts to send a value to a channel without blocking.</p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">payload</code> must not be nil.</p>\n\n<p>Returns the channel if the send succeeded, nil if the channel was full.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">channel</code></td>\n      <td>chan&lt;any | nil&gt;</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">payload</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.channel",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-bytes",
      "url": "https://sluglang.org/libraries/slug-bytes",
      "title": "bytes (slug)",
      "content_html": "<h2 id=\"slugbytes\">slug.bytes</h2>\n\n<p>slug.bytes — byte buffer utilities</p>\n\n<p>Conversions between <code class=\"language-plaintext highlighter-rouge\">bytes</code>, <code class=\"language-plaintext highlighter-rouge\">str</code>, hex strings, base64, and numeric lists.\nAll functions are pure and operate on immutable byte values.</p>\n\n<p>Byte literals use the <code class=\"language-plaintext highlighter-rouge\">0x\"&lt;hex&gt;\"</code> syntax, e.g. <code class=\"language-plaintext highlighter-rouge\">0x\"ff0a\"</code>.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#base64decodes\"><code class=\"language-plaintext highlighter-rouge\">base64Decode(s)</code></a></li>\n  <li><a href=\"#base64encodeb\"><code class=\"language-plaintext highlighter-rouge\">base64Encode(b)</code></a></li>\n  <li><a href=\"#bytestohexstrb\"><code class=\"language-plaintext highlighter-rouge\">bytesToHexStr(b)</code></a></li>\n  <li><a href=\"#bytestonumbersb-i-acc\"><code class=\"language-plaintext highlighter-rouge\">bytesToNumbers(b, i, acc)</code></a></li>\n  <li><a href=\"#bytestostrb\"><code class=\"language-plaintext highlighter-rouge\">bytesToStr(b)</code></a></li>\n  <li><a href=\"#hexstrtobyteshex\"><code class=\"language-plaintext highlighter-rouge\">hexStrToBytes(hex)</code></a></li>\n  <li><a href=\"#repeatb-count-acc\"><code class=\"language-plaintext highlighter-rouge\">repeat(b, count, acc)</code></a></li>\n  <li><a href=\"#strtobytess\"><code class=\"language-plaintext highlighter-rouge\">strToBytes(s)</code></a></li>\n</ul>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"base64decodes\"><code class=\"language-plaintext highlighter-rouge\">base64Decode(s)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#base64Decode(s:str):bytes\n</code></pre>\n\n<p>decodes a standard base64 string to a byte buffer.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples\">Examples</h4>\n\n<pre><code class=\"language-slug\">base64Decode(\"\")  // =&gt; 0x\"\"\nbase64Decode(\"aGVsbG8gc2x1Zw==\")  // =&gt; 0x\"68656c6c6f20736c7567\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"base64encodeb\"><code class=\"language-plaintext highlighter-rouge\">base64Encode(b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#base64Encode(b:bytes):str\n</code></pre>\n\n<p>encodes a byte buffer as a standard base64 string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-1\">Examples</h4>\n\n<pre><code class=\"language-slug\">base64Encode(0x\"\")  // =&gt; \"\"\nbase64Encode(0x\"68656c6c6f20736c7567\")  // =&gt; \"aGVsbG8gc2x1Zw==\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"bytestohexstrb\"><code class=\"language-plaintext highlighter-rouge\">bytesToHexStr(b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#bytesToHexStr(b:bytes):str\n</code></pre>\n\n<p>encodes a byte buffer as a lowercase hex string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-2\">Examples</h4>\n\n<pre><code class=\"language-slug\">bytesToHexStr(0x\"\")  // =&gt; \"\"\nbytesToHexStr(0x\"68656c6c6f20736c7567\")  // =&gt; \"68656c6c6f20736c7567\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"bytestonumbersb-i-acc\"><code class=\"language-plaintext highlighter-rouge\">bytesToNumbers(b, i, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#bytesToNumbers(b:bytes, i = 0, acc:list&lt;num&gt; = []):list&lt;num&gt;\n</code></pre>\n\n<p>converts a byte buffer to a list of numeric byte values (0–255).</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">i</code></td>\n      <td> </td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>list<num></num></td>\n      <td><code class=\"language-plaintext highlighter-rouge\">[]</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-3\">Examples</h4>\n\n<pre><code class=\"language-slug\">bytesToNumbers(0x\"a8ff04\")  // =&gt; [168, 255, 4]\n</code></pre>\n\n<hr />\n\n<h4 id=\"bytestostrb\"><code class=\"language-plaintext highlighter-rouge\">bytesToStr(b)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#bytesToStr(b:bytes):str\n</code></pre>\n\n<p>converts a byte buffer to a UTF-8 string.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-4\">Examples</h4>\n\n<pre><code class=\"language-slug\">bytesToStr(0x\"\")  // =&gt; \"\"\nbytesToStr(0x\"68656c6c6f20736c7567\")  // =&gt; \"hello slug\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"hexstrtobyteshex\"><code class=\"language-plaintext highlighter-rouge\">hexStrToBytes(hex)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#hexStrToBytes(hex:str):bytes\n</code></pre>\n\n<p>decodes a lowercase hex string to a byte buffer.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">hex</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-5\">Examples</h4>\n\n<pre><code class=\"language-slug\">hexStrToBytes(\"\")  // =&gt; 0x\"\"\nhexStrToBytes(\"68656c6c6f20736c7567\")  // =&gt; 0x\"68656c6c6f20736c7567\"\nhexStrToBytes(\"a8ff04\")  // =&gt; 0x\"a8ff04\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"repeatb-count-acc\"><code class=\"language-plaintext highlighter-rouge\">repeat(b, count, acc)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#repeat(b:bytes, count:num, acc:bytes = 0x\"\"):bytes\n</code></pre>\n\n<p>repeats a byte buffer <code class=\"language-plaintext highlighter-rouge\">count</code> times and returns the concatenated result.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">b</code></td>\n      <td>bytes</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">count</code></td>\n      <td>num</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">acc</code></td>\n      <td>bytes</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">0x\"\"</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-6\">Examples</h4>\n\n<pre><code class=\"language-slug\">repeat(0x\"ff\", 3)  // =&gt; 0x\"ffffff\"\n</code></pre>\n\n<hr />\n\n<h4 id=\"strtobytess\"><code class=\"language-plaintext highlighter-rouge\">strToBytes(s)</code></h4>\n<pre><code class=\"language-slug\">fn slug.bytes#strToBytes(s:str):bytes\n</code></pre>\n\n<p>converts a UTF-8 string to a byte buffer.</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">s</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<h4 id=\"examples-7\">Examples</h4>\n\n<pre><code class=\"language-slug\">strToBytes(\"\")  // =&gt; 0x\"\"\nstrToBytes(\"hello slug\")  // =&gt; 0x\"68656c6c6f20736c7567\"\n</code></pre>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.bytes",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/slug-benchmark",
      "url": "https://sluglang.org/libraries/slug-benchmark",
      "title": "benchmark (slug)",
      "content_html": "<h2 id=\"slugbenchmark\">slug.benchmark</h2>\n\n<p>slug.benchmark — micro-benchmarking for Slug functions</p>\n\n<p>Provides tools to measure and compare the performance of Slug functions\nwith statistical rigour. Each benchmark runs a warmup phase, calibrates\niteration count to fill a target sample window, then collects multiple\nsamples to compute percentile statistics.</p>\n\n<p>Overhead from the benchmarking harness itself is measured and subtracted\nby default, giving a cleaner picture of the work under test.</p>\n\n<h2 id=\"quick-start\">Quick start</h2>\n\n<pre><code class=\"language-slug\">val { micro, printResult, compare, printCompareReport } = import(\"slug.benchmark\")\n\nval result = micro(\"string concat\", fn() { \"hello\" + \" \" + \"world\" })\nresult /&gt; printResult\n</code></pre>\n\n<h2 id=\"units\">Units</h2>\n\n<p>Results are reported in nanoseconds by default. Use <code class=\"language-plaintext highlighter-rouge\">UnitUs</code> or <code class=\"language-plaintext highlighter-rouge\">UnitMs</code>\nfor slower workloads.</p>\n\n<h3 id=\"toc\">TOC</h3>\n\n<ul>\n  <li><a href=\"#unitms\">UnitMs</a></li>\n  <li><a href=\"#unitns\">UnitNs</a></li>\n  <li><a href=\"#unitus\">UnitUs</a></li>\n  <li><a href=\"#comparebenches-warmupms-samplems-samples-miniters-maxiters-subtractoverhead-unit\"><code class=\"language-plaintext highlighter-rouge\">compare(benches, warmupMs, sampleMs, samples, minIters, maxIters, subtractOverhead, unit)</code></a></li>\n  <li><a href=\"#microname-workfn-warmupms-samplems-samples-miniters-maxiters-subtractoverhead-unit\"><code class=\"language-plaintext highlighter-rouge\">micro(name, workFn, warmupMs, sampleMs, samples, minIters, maxIters, subtractOverhead, unit)</code></a></li>\n  <li><a href=\"#printcomparereportreport\"><code class=\"language-plaintext highlighter-rouge\">printCompareReport(report)</code></a></li>\n  <li><a href=\"#printresultres\"><code class=\"language-plaintext highlighter-rouge\">printResult(res)</code></a></li>\n</ul>\n\n<h3 id=\"constants\">Constants</h3>\n\n<h4 id=\"unitms\"><code class=\"language-plaintext highlighter-rouge\">UnitMs</code></h4>\n\n<pre><code class=\"language-slug\">str slug.benchmark#UnitMs\n</code></pre>\n\n<h4 id=\"unitns\"><code class=\"language-plaintext highlighter-rouge\">UnitNs</code></h4>\n\n<pre><code class=\"language-slug\">str slug.benchmark#UnitNs\n</code></pre>\n\n<h4 id=\"unitus\"><code class=\"language-plaintext highlighter-rouge\">UnitUs</code></h4>\n\n<pre><code class=\"language-slug\">str slug.benchmark#UnitUs\n</code></pre>\n\n<h3 id=\"functions\">Functions</h3>\n\n<h4 id=\"comparebenches-warmupms-samplems-samples-miniters-maxiters-subtractoverhead-unit\"><code class=\"language-plaintext highlighter-rouge\">compare(benches, warmupMs, sampleMs, samples, minIters, maxIters, subtractOverhead, unit)</code></h4>\n<pre><code class=\"language-slug\">fn slug.benchmark#compare(benches:list, warmupMs:num = 100, sampleMs:num = 200, samples:num = 20, minIters:num = 1, maxIters:num = 10000000, subtractOverhead:bool = true, unit:str = UnitNs):map\nfn slug.benchmark#compare(a, b):num\n</code></pre>\n\n<p>benchmarks a list of named functions and returns results sorted by p50.</p>\n\n<p>Each entry in <code class=\"language-plaintext highlighter-rouge\">benches</code> must be a map with <code class=\"language-plaintext highlighter-rouge\">name</code> (str) and <code class=\"language-plaintext highlighter-rouge\">fun</code> (fn) fields.\nAll benchmarks share the same timing parameters. Results include a <code class=\"language-plaintext highlighter-rouge\">ratio</code>\nfield showing performance relative to the fastest (lowest p50) entry.</p>\n\n<p>Pass the result to <code class=\"language-plaintext highlighter-rouge\">printCompareReport</code> for formatted console output.</p>\n\n<pre><code class=\"language-slug\">val report = compare([\n  { name: \"concat\", fun: fn() { \"a\" + \"b\" } },\n  { name: \"fmt\",    fun: fn() { fmt(\"{}{}\", \"a\", \"b\") } },\n])\nreport /&gt; printCompareReport\n</code></pre>\n\n<p>@effects(‘time’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">benches</code></td>\n      <td>list</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">warmupMs</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">100</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sampleMs</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">200</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">samples</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">20</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">minIters</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">maxIters</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">10000000</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">subtractOverhead</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">true</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">unit</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">UnitNs</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n\n<hr />\n\n<h4 id=\"microname-workfn-warmupms-samplems-samples-miniters-maxiters-subtractoverhead-unit\"><code class=\"language-plaintext highlighter-rouge\">micro(name, workFn, warmupMs, sampleMs, samples, minIters, maxIters, subtractOverhead, unit)</code></h4>\n<pre><code class=\"language-slug\">fn slug.benchmark#micro(name:str, workFn:fn, warmupMs:num = 100, sampleMs:num = 200, samples:num = 20, minIters:num = 1, maxIters:num = 10000000, subtractOverhead:bool = true, unit:str = UnitNs):map\n</code></pre>\n\n<p>runs a single micro-benchmark and returns a result map with statistics.</p>\n\n<p>Warms up the JIT/runtime for <code class=\"language-plaintext highlighter-rouge\">warmupMs</code>, then calibrates iteration count\nso each sample takes approximately <code class=\"language-plaintext highlighter-rouge\">sampleMs</code> to collect. Runs <code class=\"language-plaintext highlighter-rouge\">samples</code>\nmeasurements and computes percentile statistics on the results.</p>\n\n<p>Returns a map with the shape:</p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>{\n  name, unit, itersPerSample, samples,\n  stats: { min, p50, p90, p99, max, mean, stdev },\n  raw:   { timesPerIter: [...] }\n}\n</code></pre></div></div>\n\n<p>Pass the result to <code class=\"language-plaintext highlighter-rouge\">printResult</code> for formatted console output.</p>\n\n<p>@effects(‘time’)</p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">name</code></td>\n      <td>str</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">workFn</code></td>\n      <td>fn</td>\n      <td>—</td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">warmupMs</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">100</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">sampleMs</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">200</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">samples</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">20</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">minIters</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">1</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">maxIters</code></td>\n      <td>num</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">10000000</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">subtractOverhead</code></td>\n      <td>bool</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">true</code></td>\n    </tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">unit</code></td>\n      <td>str</td>\n      <td><code class=\"language-plaintext highlighter-rouge\">UnitNs</code></td>\n    </tr>\n  </tbody>\n</table>\n\n<p><strong>Effects:</strong> <code class=\"language-plaintext highlighter-rouge\">time</code></p>\n\n<hr />\n\n<h4 id=\"printcomparereportreport\"><code class=\"language-plaintext highlighter-rouge\">printCompareReport(report)</code></h4>\n<pre><code class=\"language-slug\">fn slug.benchmark#printCompareReport(report):nil\n</code></pre>\n\n<p>prints a formatted comparison report to stdout.</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Benchmark report\n  concat         : p50 38 ns  x1.0\n  fmt            : p50 91 ns  x2.4\n</code></pre></div></div>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">report</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n\n<hr />\n\n<h4 id=\"printresultres\"><code class=\"language-plaintext highlighter-rouge\">printResult(res)</code></h4>\n<pre><code class=\"language-slug\">fn slug.benchmark#printResult(res):nil\n</code></pre>\n\n<p>prints a formatted summary of a <code class=\"language-plaintext highlighter-rouge\">micro</code> result to stdout.</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>string concat\n  p50: 42 ns  p90: 51  p99: 78\n  mean: 44  stdev: 8  min: 38  max: 91\n  iters/sample: 10000  samples: 20\n</code></pre></div></div>\n\n<table>\n  <thead>\n    <tr>\n      <th>Parameter</th>\n      <th>Type</th>\n      <th>Default</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">res</code></td>\n      <td> </td>\n      <td>—</td>\n    </tr>\n  </tbody>\n</table>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "slug.benchmark",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/migrate",
      "url": "https://sluglang.org/libraries/migrate",
      "title": "migrate",
      "content_html": "<h2 id=\"migrate\">migrate</h2>\n\n<p>Slug Migrate — database schema migration tool</p>\n\n<p>Applies, rolls back, and reports on versioned SQL migration scripts.</p>\n\n<p>Usage:</p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>slug migrate <span class=\"o\">[</span>options] <span class=\"o\">[</span>up|down|status]\n</code></pre></div></div>\n\n<p>Commands:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">up</code>       apply all pending migrations (default)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">down</code>     roll back the most recent migration(s)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">status</code>   show applied / pending / ineligible migrations</li>\n</ul>\n\n<p>Options:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">-h, --help</code>      show this screen</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">-v, --version</code>   show version</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--db</code>            database connection string (required)</li>\n  <li>\n    <table>\n      <tbody>\n        <tr>\n          <td><code class=\"language-plaintext highlighter-rouge\">--driver</code>        database driver: sqlite3</td>\n          <td>mysql</td>\n          <td>postgres (default: sqlite3)</td>\n        </tr>\n      </tbody>\n    </table>\n  </li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--env</code>           environment tag(s) to include; may be passed multiple times</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--base</code>          migrations directory (default: db/migrations)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--step</code>          number of migrations to roll back with <code class=\"language-plaintext highlighter-rouge\">down</code> (default: 1)</li>\n</ul>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "migrate",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/hello",
      "url": "https://sluglang.org/libraries/hello",
      "title": "hello",
      "content_html": "<h2 id=\"hello\">hello</h2>\n\n<p>A very simple <code class=\"language-plaintext highlighter-rouge\">Hello Slug</code> tool example</p>\n\n<p>Usage:</p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>slug hello <span class=\"o\">[</span>name]\n</code></pre></div></div>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "hello",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/libraries/doc",
      "url": "https://sluglang.org/libraries/doc",
      "title": "doc",
      "content_html": "<h2 id=\"doc\">doc</h2>\n\n<p>doc — Slug documentation tool</p>\n\n<p>Generates MANIFEST.ai or markdown documentation by reflecting over\nSlug modules in a source directory.</p>\n\n<p>Usage:</p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>slug doc <span class=\"o\">[</span>options] <span class=\"o\">[</span><span class=\"nt\">--</span><span class=\"o\">]</span> <span class=\"o\">[</span>manifest|markdown]\n</code></pre></div></div>\n\n<p>Commands:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">manifest</code>   generate a MANIFEST.ai file from source modules (default)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">markdown</code>   generate human-readable markdown documentation</li>\n</ul>\n\n<p>Options:</p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">-h, --help</code>       show this screen</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">-v, --version</code>    show version</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--dir</code>            source directory to scan for .slug modules (default: .)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--out</code>            output file path; omit to print to stdout</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--title</code>          document title for markdown output (default: Slug API Reference)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--multiPage</code>      generate a file per module in the –out directory (markdown only)</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">--moduleToc</code>      generate a table of contents for each module</li>\n</ul>\n",
      "date_published": "2026-11-17T05:06:25+00:00",
      "summary": "doc",
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-03-29-module-local-logging",
      "url": "https://sluglang.org/cookbook/2026-03-29-module-local-logging",
      "title": "Module-local logging",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want each module to have its own logger with a stable source name.</p>\n\n<p>Hardcoding the source is fragile:</p>\n\n<pre><code class=\"language-slug\">val log = import(\"slug.log\").logger(\"playground\")\n</code></pre>\n\n<p>This breaks when modules are copied or renamed.</p>\n\n<h3 id=\"idiom-derive-the-logger-source-from-the-module\"><strong>Idiom: Derive the logger source from the module</strong></h3>\n\n<p>Use <code class=\"language-plaintext highlighter-rouge\">moduleName()</code> from <code class=\"language-plaintext highlighter-rouge\">slug.std</code> when constructing the logger.</p>\n\n<pre><code class=\"language-slug\">val {*} = import(\n    \"slug.std\",\n)\n\nval log = import(\"slug.log\").logger(moduleName())\n</code></pre>\n\n<p>The module provides its own identity at the call site.</p>\n\n<p>This is the preferred, copy-paste-safe setup.</p>\n\n<h3 id=\"examples\"><strong>Examples</strong></h3>\n\n<h4 id=\"basic-usage\">Basic usage</h4>\n\n<pre><code class=\"language-slug\">val {*} = import(\"slug.std\")\n\nval log = import(\"slug.log\").logger(moduleName())\n\nlog.info(\"starting worker\")\n</code></pre>\n\n<h4 id=\"in-pipelines\">In pipelines</h4>\n\n<pre><code class=\"language-slug\">val {*} = import(\"slug.std\")\n\nval log = import(\"slug.log\").logger(moduleName())\n\nprocess()\n    /&gt; log.cInfo(\"processed input\")\n    /&gt; validate\n    /&gt; log.cDebug(\"validated result\")\n</code></pre>\n\n<h3 id=\"why-this-works\"><strong>Why this works</strong></h3>\n\n<ul>\n  <li>The logger source is always correct for the calling module.</li>\n  <li>No hidden context or runtime inspection is required.</li>\n  <li>The pattern is portable across files and libraries.</li>\n  <li>Logging remains explicit and composable.</li>\n</ul>\n\n<h3 id=\"notes\"><strong>Notes</strong></h3>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">moduleName()</code> returns the fully-qualified module name (for example <code class=\"language-plaintext highlighter-rouge\">\"slug.io.http\"</code>).</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">slug.log</code> does not infer the caller; the caller provides its identity explicitly.</li>\n  <li>This pattern composes cleanly with other module-level setup (imports, config, etc.).</li>\n</ul>\n",
      "date_published": "2026-03-29T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.log","slug.std","logging"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-02-18-variable-swapping-without-a-temp-variable",
      "url": "https://sluglang.org/cookbook/2026-02-18-variable-swapping-without-a-temp-variable",
      "title": "Variable swapping (without a temp variable)",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You have two variables and want to swap their values cleanly—without introducing a temporary variable.</p>\n\n<h3 id=\"idiom-redeclare-with-list-decomposition\"><strong>Idiom: Redeclare with list decomposition</strong></h3>\n\n<p>Slug lets you destructure lists, and (in the right scope) redeclare variables. Combine those to swap in one expression:</p>\n\n<ul>\n  <li>Build a pair <code class=\"language-plaintext highlighter-rouge\">[a, b]</code></li>\n  <li>Destructure it back into the opposite order <code class=\"language-plaintext highlighter-rouge\">[b, a]</code></li>\n</ul>\n\n<h3 id=\"recipe\"><strong>Recipe</strong></h3>\n\n<h4 id=\"1-swap-two-variables-in-place\">1) Swap two variables in-place</h4>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.test\")\n\nvar a = 1\nvar b = 2\n\n// swap via list decomposition (no temp variable)\nvar [b, a] = [a, b]\n\na /&gt; assertEqual(2)\nb /&gt; assertEqual(1)\n</code></pre>\n\n<h4 id=\"2-works-with-any-values-not-just-numbers\">2) Works with any values (not just numbers)</h4>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.test\")\n\nvar left  = \"L\"\nvar right = \"R\"\n\nvar [right, left] = [left, right]\n\nleft  /&gt; assertEqual(\"R\")\nright /&gt; assertEqual(\"L\")\n</code></pre>\n\n<h3 id=\"notes\"><strong>Notes</strong></h3>\n\n<ul>\n  <li>This pattern relies on <strong>(1) list decomposition</strong> and <strong>(2) redeclaration</strong> in the current scope.</li>\n</ul>\n",
      "date_published": "2026-02-18T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.std","slug.test"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-02-16-string-formatting-with-fmt",
      "url": "https://sluglang.org/cookbook/2026-02-16-string-formatting-with-fmt",
      "title": "String formatting with fmt",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want readable, consistent strings for logs, errors, tables, and user-facing output—without a pile of <code class=\"language-plaintext highlighter-rouge\">+</code>\nconcatenation.</p>\n\n<h3 id=\"idiom-use-fmttemplate-args-with--placeholders\"><strong>Idiom: Use <code class=\"language-plaintext highlighter-rouge\">fmt(template, ...args)</code> with <code class=\"language-plaintext highlighter-rouge\">{}</code> placeholders</strong></h3>\n\n<p><code class=\"language-plaintext highlighter-rouge\">fmt</code> builds a string from a template plus arguments.</p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">{}</code> inserts the next argument (auto-indexed).</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{0}</code>, <code class=\"language-plaintext highlighter-rouge\">{1}</code>, … inserts a specific argument (positional).</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:&lt;10s}</code>, <code class=\"language-plaintext highlighter-rouge\">{:&gt;8}</code>, <code class=\"language-plaintext highlighter-rouge\">{:^10s}</code> control alignment and width.</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:.2f}</code> controls numeric precision.</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:,}</code> adds thousands separators.</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">{:.1%}</code> multiplies by 100 and adds <code class=\"language-plaintext highlighter-rouge\">%</code>.</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">\\{</code> and <code class=\"language-plaintext highlighter-rouge\">\\}</code> let you print literal braces.</li>\n</ul>\n\n<h3 id=\"recipe\"><strong>Recipe</strong></h3>\n\n<h4 id=\"1-start-simple\">1) Start simple</h4>\n<pre><code class=\"language-slug\">var {*} = import(\"slug.std\")\n\nprintln(fmt(\"Hello {}\", \"Slug\"))\n</code></pre>\n\n<h4 id=\"2-use-positional-placeholders-when-order-matters\">2) Use positional placeholders when order matters</h4>\n<pre><code class=\"language-slug\">println(fmt(\"{1} then {0}\", \"A\", \"B\"))   // \"B then A\"\n</code></pre>\n\n<h4 id=\"3-control-numeric-precision-and-percent\">3) Control numeric precision (and percent)</h4>\n<pre><code class=\"language-slug\">println(fmt(\"x={:.2f} y={:.2f}\", 1.2, 3.4))  // \"x=1.20 y=3.40\"\nprintln(fmt(\"success={:.1%}\", 0.1234))       // \"success=12.3%\"\n</code></pre>\n\n<h4 id=\"4-print-integers-or-grouped-numbers\">4) Print integers or grouped numbers</h4>\n<pre><code class=\"language-slug\">println(fmt(\"id={:d}\", 12.9))          // \"id=12\"\nprintln(fmt(\"total={:,}\", 1234567))    // \"total=1,234,567\"\n</code></pre>\n\n<h4 id=\"5-make-quick-fixed-width-columns-alignment--width\">5) Make quick fixed-width columns (alignment + width)</h4>\n<pre><code class=\"language-slug\">println(fmt(\"|{:&gt;8}|\", 12.3))       // right-aligned\nprintln(fmt(\"|{:&lt;10s}|\", \"Slug\"))   // left-aligned (string)\nprintln(fmt(\"|{:^10s}|\", \"Slug\"))   // centered (string)\n</code></pre>\n\n<h4 id=\"6-escape-braces-when-you-mean-literal---\">6) Escape braces when you mean literal <code class=\"language-plaintext highlighter-rouge\">{</code> / <code class=\"language-plaintext highlighter-rouge\">}</code></h4>\n<pre><code class=\"language-slug\">println(fmt(\"value=\\\\{x\\\\}\"))  // \"value={x}\"\n</code></pre>\n\n<h3 id=\"notes\"><strong>Notes</strong></h3>\n\n<ul>\n  <li>Auto-indexed (<code class=\"language-plaintext highlighter-rouge\">{}</code>) and positional (<code class=\"language-plaintext highlighter-rouge\">{0}</code>) placeholders are both supported; prefer <code class=\"language-plaintext highlighter-rouge\">{}</code> until you need reordering.</li>\n  <li>Width/alignment is handy for debug output and small CLI tables—keep it simple and it stays readable tomorrow.</li>\n</ul>\n",
      "date_published": "2026-02-16T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.std.fmt","slug.std"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-25-standard-error-struct",
      "url": "https://sluglang.org/cookbook/2026-01-25-standard-error-struct",
      "title": "Standard Error struct",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want consistent, idiomatic error payloads that are easy to pattern-match and inspect.</p>\n\n<h3 id=\"idiom-throw-error----literals\"><strong>Idiom: Throw <code class=\"language-plaintext highlighter-rouge\">Error { ... }</code> literals</strong></h3>\n\n<p>Slug’s standard library defines a conventional <code class=\"language-plaintext highlighter-rouge\">Error</code> struct in <code class=\"language-plaintext highlighter-rouge\">slug.std</code>. Use struct literals at the throw site so\nstacktraces point at the exact source line.</p>\n\n<pre><code class=\"language-slug\">throw Error { type: \"ValidationError\", msg: \"name is required\" }\n</code></pre>\n\n<p>Add context via <code class=\"language-plaintext highlighter-rouge\">data</code> or chain failures via <code class=\"language-plaintext highlighter-rouge\">cause</code>:</p>\n\n<pre><code class=\"language-slug\">var openConfig = fn(path) {\n    defer onerror(err) {\n        // Wrap and rethrow with context\n        throw Error { type: \"ConfigError\", msg: \"failed to open config\", data: { path: path }, cause: err }\n    }\n\n    readFile(path) // throws its own Error on failure\n}\n</code></pre>\n",
      "date_published": "2026-01-25T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.std.Error","throw","defer","slug.std"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-24-comparing-implementations-with-compare",
      "url": "https://sluglang.org/cookbook/2026-01-24-comparing-implementations-with-compare",
      "title": "Comparing Implementations with compare",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You have multiple implementations of the same idea and want to know which one is faster.</p>\n\n<h3 id=\"idiom-comparing-benchmarks-by-median-time\"><strong>Idiom: Comparing Benchmarks by Median Time</strong></h3>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">compare</code> function runs <code class=\"language-plaintext highlighter-rouge\">micro</code> for each benchmark, sorts the results by median time (p50),\nand computes a relative ratio against the fastest implementation.</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\n\t\"slug.time\",\n\t\"slug.benchmark\",\n)\n\nvar slow = fn() { sleep(10) }\nvar fast = fn() { sleep(5) }\n\nvar report =\n\tcompare([\n\t\t{name: \"slow version\", fun: slow},\n\t\t{name: \"fast version\", fun: fast},\n\t],\n\t)\n\nreport /&gt; printCompareReport\n</code></pre>\n\n<p>The fastest benchmark is shown as <code class=\"language-plaintext highlighter-rouge\">x1</code>, with slower implementations reported relative to it.</p>\n",
      "date_published": "2026-01-24T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.benchmark","performance"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-24-benchmarking-real-work-avoid-setup-bias",
      "url": "https://sluglang.org/cookbook/2026-01-24-benchmarking-real-work-avoid-setup-bias",
      "title": "Benchmarking Real Work (avoid setup bias)",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want to benchmark a function without accidentally measuring setup or allocation work.</p>\n\n<h3 id=\"idiom-keep-setup-outside-the-benchmarked-function\"><strong>Idiom: Keep Setup Outside the Benchmarked Function</strong></h3>\n\n<p>Move any setup outside the function passed to <code class=\"language-plaintext highlighter-rouge\">micro</code>, so the benchmark measures only the work you care about.</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\n\t\"slug.time\",\n\t\"slug.benchmark\",\n)\n\nvar f = fn() {\n\tsleep(100)\n}\n\nmicro(\"sleep 100ms\", f)\n\t/&gt; printResult\n</code></pre>\n\n<p>This produces more stable and meaningful results.</p>\n",
      "date_published": "2026-01-24T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.benchmark","performance"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-24-benchmarking-a-function-with-micro",
      "url": "https://sluglang.org/cookbook/2026-01-24-benchmarking-a-function-with-micro",
      "title": "Benchmarking a Function with micro",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want to measure how long a small piece of code takes to run, without setting up an external profiler or harness.</p>\n\n<h3 id=\"idiom-benchmarking-a-zero-argument-function\"><strong>Idiom: Benchmarking a Zero-Argument Function</strong></h3>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">micro</code> function benchmarks a single zero-argument function and reports timing statistics such as median (p50),\np90, and p99.</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\n\t\"slug.time\",\n\t\"slug.benchmark\",\n)\n\nvar f = fn() {\n\tsleep(100)\n}\n\nmicro(\"sleep 100ms\", f)\n\t/&gt; printResult\n</code></pre>\n\n<p>Focus on <strong>p50</strong> for typical performance, and <strong>p90/p99</strong> to understand jitter or tail latency.</p>\n",
      "date_published": "2026-01-24T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["slug.benchmark","performance"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-21-inline-unit-testing-with-testwith",
      "url": "https://sluglang.org/cookbook/2026-01-21-inline-unit-testing-with-testwith",
      "title": "Inline Unit Testing with @testWith",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>You want to verify the correctness of a function immediately after defining it, without setting up a separate test file\nor complex test suite.</p>\n\n<h3 id=\"idiom-table-driven-testing-with-testwith\"><strong>Idiom: Table-Driven Testing with <code class=\"language-plaintext highlighter-rouge\">@testWith</code></strong></h3>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">@testWith</code> decorator allows you to define a list of inputs and expected outputs directly above your function. Use\nthe slug test runner to execute the test cases <code class=\"language-plaintext highlighter-rouge\">slug test slug.std</code> (or <code class=\"language-plaintext highlighter-rouge\">slug -root . test hello</code>).</p>\n\n<pre><code class=\"language-slug\">@testWith(\n\t[1, 2], false,\n\t[1, 1], true,\n\t[\"1\", \"2\"], false,\n\t[\"1\", \"1\"], true,\n\t[true, true], true,\n\t[false, true], false,\n)\nvar equals = fn(v1, v2) {\n\tv1 == v2\n}\n</code></pre>\n",
      "date_published": "2026-01-21T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["test","testWith"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-18-pattern-matching-for-behavior-selection",
      "url": "https://sluglang.org/cookbook/2026-01-18-pattern-matching-for-behavior-selection",
      "title": "Pattern Matching for Behavior Selection",
      "content_html": "<h3 id=\"problem\"><strong>Problem</strong></h3>\n\n<p>Execute logic based on value shape or type.</p>\n\n<h3 id=\"idiom-match-over-conditionals\"><strong>Idiom: Match Over Conditionals</strong></h3>\n\n<pre><code class=\"language-slug\">match response {\n  { status: 200 } =&gt; \"OK\"\n  { status: 404 } =&gt; \"Not Found\"\n  _               =&gt; \"Error\"\n}\n</code></pre>\n\n<p><strong>Slug mindset</strong></p>\n\n<blockquote>\n  <p><em>Describe the world; let the runtime choose.</em></p>\n</blockquote>\n",
      "date_published": "2026-01-18T00:00:00+00:00",
      "summary": "Problem",
      "tags": ["match"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-17-connecting-to-an-sqlite-database",
      "url": "https://sluglang.org/cookbook/2026-01-17-connecting-to-an-sqlite-database",
      "title": "Connecting to an Sqlite database",
      "content_html": "<p>To interact with Sqlite, import <code class=\"language-plaintext highlighter-rouge\">slug.io.db</code> and use a standard DSN (Data Source Name) string.</p>\n\n<pre><code class=\"language-slug\">var db = import(\"slug.io.db\")\n\n// Format: \"file:path/to/database.db\"\nvar dsn = \"file:my_app.db\"\n\nvar conn = dsn /&gt; db.connect(db.SQLITE_DRIVER)\ndefer { db.close(conn) }\n\n// Execute a query\nvar users = db.query(conn, \"SELECT id, email FROM users WHERE active = ?\", true)\n\nprintln(users)\n</code></pre>\n\n<p>Sqlite also supports an in memory database using <code class=\"language-plaintext highlighter-rouge\">var dsn = \":memory:\"</code>.</p>\n",
      "date_published": "2026-01-17T00:00:00+00:00",
      "summary": "To interact with Sqlite, import slug.io.db and use a standard DSN (Data Source Name) string.",
      "tags": ["slug.io.db","defer"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-16-connecting-to-a-mysql-database",
      "url": "https://sluglang.org/cookbook/2026-01-16-connecting-to-a-mysql-database",
      "title": "Connecting to a MySQL database",
      "content_html": "<p>To interact with MySQL, import <code class=\"language-plaintext highlighter-rouge\">slug.io.db</code> and use a standard DSN (Data Source Name) string.</p>\n\n<pre><code class=\"language-slug\">var db = import(\"slug.io.db\")\n\n// Format: \"user:password@tcp(host:port)/dbname\"\nvar dsn = \"root:secret@tcp(127.0.0.1:3306)/my_app?parseTime=true\"\n\nvar conn = dsn /&gt; db.connect(db.MYSQL_DRIVER)\ndefer { db.close(conn) }\n\n// Execute a query\nvar users = db.query(conn, \"SELECT id, email FROM users WHERE active = ?\", true)\n\nprintln(users)\n</code></pre>\n",
      "date_published": "2026-01-16T00:00:00+00:00",
      "summary": "To interact with MySQL, import slug.io.db and use a standard DSN (Data Source Name) string.",
      "tags": ["slug.io.db","defer"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-15-anonymous-recursive-functions-use-recur",
      "url": "https://sluglang.org/cookbook/2026-01-15-anonymous-recursive-functions-use-recur",
      "title": "Anonymous recursive functions (use recur)",
      "content_html": "<p>In Slug, you don’t need to name a function to make it recursive. The <code class=\"language-plaintext highlighter-rouge\">recur</code> keyword allows an anonymous function to\ncall itself.</p>\n\n<pre><code class=\"language-slug\">var factorialResult = fn(n, acc = 1) {\n    if (n &lt;= 1) {\n        acc\n    } else {\n        recur(n - 1, n * acc)\n    }\n}(5)\n\nprintln(\"factorial(5)\", factorialResult) // 120\n</code></pre>\n",
      "date_published": "2026-01-15T00:00:00+00:00",
      "summary": "In Slug, you don’t need to name a function to make it recursive. The recur keyword allows an anonymous function to call itself.",
      "tags": ["recur"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-timeout-any-work-the-canonical-pattern",
      "url": "https://sluglang.org/cookbook/2026-01-01-timeout-any-work-the-canonical-pattern",
      "title": "Timeout any work (the canonical pattern)",
      "content_html": "<p>Timeouts apply to <code class=\"language-plaintext highlighter-rouge\">await</code>, so to timeout a call (sync or nursery), wrap it in a spawn:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nnursery fn handler(req) {\n    var resT = spawn { doWork(req) }\n    var res  = await(resT, 2000)\n    res\n}\n</code></pre>\n\n<p>This works for:</p>\n\n<ul>\n  <li>normal <code class=\"language-plaintext highlighter-rouge\">fn</code></li>\n  <li><code class=\"language-plaintext highlighter-rouge\">nursery fn</code></li>\n  <li>blocking foreign calls (FFI)</li>\n</ul>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "Timeouts apply to await, so to timeout a call (sync or nursery), wrap it in a spawn:",
      "tags": ["nursery","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-timeout-a-blocking-ffi-call-safely",
      "url": "https://sluglang.org/cookbook/2026-01-01-timeout-a-blocking-ffi-call-safely",
      "title": "Timeout a blocking FFI call safely",
      "content_html": "<p>If <code class=\"language-plaintext highlighter-rouge\">read/accept/write</code> are blocking FFI, do this:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nfn readWithTimeout(conn, n, ms) {\n    var t = spawn { read(conn, n) }\n    await(t, ms)\n}\n</code></pre>\n\n<p>This is the simplest portable approach.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "If read/accept/write are blocking FFI, do this:",
      "tags": ["spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-spawn-early-await-late",
      "url": "https://sluglang.org/cookbook/2026-01-01-spawn-early-await-late",
      "title": "Spawn early, await late",
      "content_html": "<p>Start tasks as soon as you can, await when you must:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nnursery fn handler(req) {\n    var aT = spawn { fetchA(req) }\n    var bT = spawn { fetchB(req) }\n\n    var a = await(aT)\n    // do some CPU work here while b runs...\n    var b = await(bT)\n\n    combine(a, b)\n}\n</code></pre>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "Start tasks as soon as you can, await when you must:",
      "tags": ["nursery","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-pipeline-friendly-timeout-helper",
      "url": "https://sluglang.org/cookbook/2026-01-01-pipeline-friendly-timeout-helper",
      "title": "Pipeline-friendly timeout helper",
      "content_html": "<p>If you like keeping the spawn+await pattern tidy:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nvar withTimeout = fn(ms, f) {\n    await(spawn { f() }, ms)\n}\n</code></pre>\n\n<p>Usage:</p>\n\n<pre><code class=\"language-slug\">var res = withTimeout(2000, fn() { app(req) })\n</code></pre>\n\n<p>No language magic—just an idiom.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "If you like keeping the spawn+await pattern tidy:",
      "tags": ["spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-per-request-nursery-server-pattern",
      "url": "https://sluglang.org/cookbook/2026-01-01-per-request-nursery-server-pattern",
      "title": "Per-request nursery (server pattern)",
      "content_html": "<p>Put limits at the right scope: connection, request, or whole server.</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nvar handleRequest = nursery limit 20 fn(req) {\n    // at most 20 concurrent spawns inside this request\n    var userT  = spawn { fetchUser(req.id) }\n    var postsT = spawn { fetchPosts(req.id) }\n\n    var user  = await(userT, 200)\n    var posts = await(postsT, 400)\n\n    render(user, posts)\n}\n</code></pre>\n\n<p>This gives request-local backpressure without affecting the whole server.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "Put limits at the right scope: connection, request, or whole server.",
      "tags": ["nursery","limit","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-long-running-loops-use-recur",
      "url": "https://sluglang.org/cookbook/2026-01-01-long-running-loops-use-recur",
      "title": "Long-running loops (use recur)",
      "content_html": "<pre><code class=\"language-slug\">nursery fn acceptLoop(listener, app) {\n    var conn = accept(listener)\n    spawn { handleConn(conn, app) }\n    recur(listener, app)\n}\n</code></pre>\n\n<p>Important: <code class=\"language-plaintext highlighter-rouge\">recur</code> is a loop construct; it must <strong>not</strong> trigger nursery joins.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "nursery fn acceptLoop(listener, app) { var conn = accept(listener) spawn { handleConn(conn, app) } recur(listener, app) }",
      "tags": ["nursery","recur"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-gather-a-list-of-tasks-then-join",
      "url": "https://sluglang.org/cookbook/2026-01-01-gather-a-list-of-tasks-then-join",
      "title": "Gather a list of tasks, then join",
      "content_html": "<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nnursery fn fetchAll(ids) {\n    var tasks = ids /&gt; map(fn(id) { spawn { fetchUser(id) } })\n    tasks /&gt; map(fn(t) { await(t) })\n}\n</code></pre>\n\n<p>This is the cleanest “fan-out/fan-in” shape for N items.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "var {*} = import(\"slug.channel\") nursery fn fetchAll(ids) { var tasks = ids /> map(fn(id) { spawn { fetchUser(id) } }) tasks /> map(fn(t) { await(t) }) }",
      "tags": ["nursery","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-fail-fast-behavior-structured-cancellation",
      "url": "https://sluglang.org/cookbook/2026-01-01-fail-fast-behavior-structured-cancellation",
      "title": "Fail-fast behavior (structured cancellation)",
      "content_html": "<p>By default, if a task fails and you <code class=\"language-plaintext highlighter-rouge\">await</code> it:</p>\n\n<ul>\n  <li>the error propagates normally</li>\n  <li>sibling tasks in the same nursery should be cancelled (fail-fast)</li>\n</ul>\n\n<p>Typical pattern:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nnursery fn handler(req) {\n    var aT = spawn { taskA() }\n    var bT = spawn { taskB() }\n\n    var a = await(aT);    // if this throws, nursery cancels siblings\n    var b = await(bT)\n\n    {a:a, b:b}\n}\n</code></pre>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "By default, if a task fails and you await it:",
      "tags": ["nursery","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-concurrency-anti-patterns",
      "url": "https://sluglang.org/cookbook/2026-01-01-concurrency-anti-patterns",
      "title": "Concurrency Anti-patterns",
      "content_html": "<h2 id=\"dont-share-mutable-bindings-across-tasks\">Don’t share mutable bindings across tasks</h2>\n\n<p>Even with immutable values, rebinding a <code class=\"language-plaintext highlighter-rouge\">var</code> from multiple tasks can lose updates.</p>\n\n<p>Prefer:</p>\n\n<ul>\n  <li>returning values from tasks and awaiting them</li>\n</ul>\n\n<h2 id=\"dont-expect-function-calls-to-join\">Don’t expect function calls to “join”</h2>\n\n<p>A function call is not a join point. Only:</p>\n\n<ul>\n  <li>nursery exit</li>\n  <li><code class=\"language-plaintext highlighter-rouge\">await</code> on a handle</li>\n</ul>\n\n<h2 id=\"dont-hide-concurrency\">Don’t hide concurrency</h2>\n\n<p>If it runs concurrently, you should see <code class=\"language-plaintext highlighter-rouge\">spawn</code>.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "Don’t share mutable bindings across tasks",
      "tags": ["spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-bounded-concurrency-backpressure-with-a-nursery",
      "url": "https://sluglang.org/cookbook/2026-01-01-bounded-concurrency-backpressure-with-a-nursery",
      "title": "Bounded concurrency (backpressure) with a nursery",
      "content_html": "<p>Create a nursery to limit concurrent spawns:</p>\n\n<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\nvar loadUsers = nursery limit 10 fn(ids) {\n    ids\n        /&gt; map(fn(id) { spawn { fetchUser(id) } })\n        /&gt; map(fn(t) { await(t) })  // join handles\n}\n</code></pre>\n\n<p>Notes:</p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">limit 10</code> caps in-flight tasks in this nursery.</li>\n  <li>Join is explicit (await each handle), or implicit at nursery exit if you don’t need results.</li>\n</ul>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "Create a nursery to limit concurrent spawns:",
      "tags": ["nursery","limit","spawn","await"],
      "authors": [{
        "name": "Knuckles"
      }]
    },
    {
      "id": "https://sluglang.org/cookbook/2026-01-01-always-close-resources-with-defer",
      "url": "https://sluglang.org/cookbook/2026-01-01-always-close-resources-with-defer",
      "title": "Always close resources with defer",
      "content_html": "<pre><code class=\"language-slug\">var {*} = import(\"slug.channel\")\n\nnursery fn handleConn(conn, app) {\n    defer { close(conn) }\n\n    var rawT = spawn { read(conn, 64_000) }\n    var raw  = await(rawT, 30000)\n\n    var resT = spawn { app(parseRequest(raw)) }\n    var res  = await(resT, 2000)\n\n    write(conn, formatResponse(res))\n}\n</code></pre>\n\n<p><code class=\"language-plaintext highlighter-rouge\">defer</code> keeps cleanup deterministic even with timeouts/errors.</p>\n",
      "date_published": "2026-01-01T00:00:00+00:00",
      "summary": "```slug var {*} = import(“slug.channel”)",
      "tags": ["nursery","spawn","await","defer"],
      "authors": [{
        "name": "Knuckles"
      }]
    }
    
  ]
}
