Solan reference

Built-in Native Libraries

A source-linked reference to modules bundled with the Solan executable: JSON, HTTP, WebSocket, SQLite, regex, compression, crypto, time, and FFI.

Loading and use

What are native modules?

These modules are built into the Solan executable rather than downloaded as external packages. Programs import them with استورد "name". README identifies نظام, جيسون, شبكة, سوكت, and حلقة as always available without an explicit import; import the other modules before use.

ModulesArea
رياضيات, ضخم, عشوائي, زمنMath, arbitrary-size integers, randomness, and time.
نظام, ملفات, جيسون, نمطEnvironment/processes, files, JSON, and regular expressions.
تشفير, ضغطHashes, HMAC, Base64/hex, gzip/zlib.
شبكة, سوكت, ويبسوكت, حلقةHTTP/TLS, TCP/UDP, WebSocket, event-loop handles and timers.
قاعدة, ffiSQLite and calling C libraries or loading native modules.

Networking

HTTP and web servers

FunctionSource-described behavior
شبكة.جلب(url, options?)Blocking HTTP/HTTPS request returning a map with status, body, headers, success, and final URL. Options include method, headers, body, timeout, redirects, TLS verification, and form encodings.
شبكة.جلب_متدفق(url, callback, options?)Calls back with transport chunks before completion, then returns the usual response map. The call itself is synchronous/blocking.
شبكة.خادم(port, handler, options?)Blocking HTTP server; handler receives a request map. Returning text produces HTML; a map can specify status, headers, and body.
شبكة.خادم_حلقة(...)Event-loop HTTP server; supports an asynchronous handler.
شبكة.ترميز_رابط(text) / فك_رابط(text)URL component encoding and decoding.
شبكة.اقرا_طلب(...) / اكتب_رد(...)Lower-level HTTP handling over sockets.

With جلب_متدفق, an SSE event or UTF-8 character may span chunks. Buffer and reassemble before parsing events or decoding text. A failure after partial data raises rather than returning a partial response as complete.

HTTPS and WSS require runtime OpenSSL in the configuration described by README; without TLS, ordinary HTTP/TCP still works. Do not disable certificate verification without a specific reason.

Networking

TCP, UDP, WebSocket, and the event loop

  • سوكت provides listen, accept, connect, send, bounded/exact/line reads, timeouts, nonblocking mode, readiness waits, DNS, UDP operations, and handle closure.
  • ويبسوكت connects to ws:// or wss://, upgrades inbound HTTP, sends/receives messages and ping, and closes channels.
  • حلقة is a single-threaded event loop with one-shot/repeating timers, handle watchers, step/run/stop operations.
README-shaped calls (not rerun)
خل مقبض = سوكت.اتصل("localhost", 9000)
سوكت.ارسل(مقبض, "مرحبا")

خل م = حلقة.كل(1, دالة() { اطبع("tick") })
حلقة.الغ(م)

Data and cryptography

JSON, regex, SQLite, compression, and cryptography

ModuleDocumented API and behavior
جيسونترميز(value, spacing?) encodes a value; فك(text) parses JSON and maps null to عدم.
نمطابحث, هل, مطابق_كامل, كل, قسم, ابدل; supports named groups and case-insensitive, normalization, multiline, and dotall options.
قاعدةافتح, نفذ, استعلم, اغلق; SELECT returns a list of maps. Pass values separately in a list of ? parameters rather than concatenating SQL text.
ضغطgzip, gunzip, zlib, فك; core compression is bundled and documented output limit is 512 MiB for decompression protection.
تشفيرsha256, sha1, hmac_sha256, base64/فك_base64, hex/فك_hex, عشوائي_بايتات.
SQLite pattern from README (not rerun)
استورد "قاعدة"
خل ق = قاعدة.افتح("t.db")
قاعدة.نفذ(ق, "INSERT INTO ت VALUES (?, ?)", [1, "س"])
خل صفوف = قاعدة.استعلم(ق, "SELECT * FROM ت WHERE ا = ?", [1])
قاعدة.اغلق(ق)

Data and cryptography

Big integers, time, and FFI

  • ضخم accepts integer values as strings and returns strings to avoid precision loss; documented operations include add, subtract, multiply, integer divide, remainder, power, factorial, compare, and normalization.
  • زمن provides Unix time, a monotonic duration clock, sleep, date conversion, strftime formatting, and parsing. نوم blocks; README recommends نم in asynchronous code.
  • ffi opens a library, binds functions using signatures such as d(d), and manages memory/pointers. It requires the اصلي permission and is inherently unsafe.
  • Documented FFI limits: x86-64 and AArch64 only; up to 6 integer and 8 floating-point arguments; no float ABI, varargs, or callbacks.

Native loading and FFI execute external code within the process. Do not use them with untrusted libraries; understand the اصلي permission and platform limits first.

Loading and use

Module sources and verification

The signatures above are concise and do not replace the README or source files. Examples on this page were not executed; follow the install page, then use solan --check when testing new syntax.

Source files

Direct links pinned to the source snapshot used by this reference; the main branch may change later.