Eve System Library
from … use, like any other module, from $EVE_LIB.
fs, time, os, secret, csv, json, txt, crypto, net, database) and the modules of levels 6 and 7 (http, route, service, rpc) are designed and specified; their members are still being completed. Only the members called by a test are listed in the specification.The standard modules are in scope in every script without an import: write fs.read!(path), csv.read!(:Order)(path) or database.connect("sales") directly. A project module with the name of a standard module is a compile error. A Secret is made with Secret(text) or secret.get(name), and prints as ***.
The modules
| Module | What it holds | Status | Page |
|---|---|---|---|
| built-in names | print, write, read, error, warning, log_err, log_wrn, raise, expect, assert | level 1, complete | Standard Library |
| system variables | $EVE_DIR, $EVE_ASP, $EVE_LIB, $EVE_OUT, $HOME, $OS_PWD, $NAME and every environment variable as $NAME | level 1, draft | EVE VM |
math, stats | numbers and statistics written in Eve: from lib use (math, stats); gives math.sqrt, stats.mean, stats.regress.linear, stats.distrib.norm_cdf and the rest (see Statistics) | levels 1 and 3, tested | below |
fs | files, folders and paths: read and write text and bytes, lines as a stream, list a folder, glob; the operator / joins paths | level 5, draft | Files and ETL |
time | the clock, Instant, DateTime with a zone from the IANA database (the zone of the machine too, on Windows through the CLDR names), sleeping | level 5, draft | Date and Time |
os | run! to run a command and env for the environment | level 5, draft | Shell Commands |
secret | Secret: tokens and passwords that never appear in logs or in code; secret.get("name") reads the variable EVE_SECRET_NAME, else the file named by EVE_SECRET_NAME_FILE | level 5, draft | Databases |
csv, json, txt | read and write files as streams of rows or nodes, typed by a record class, in Unicode; .gz files are read and written on the fly, and a reader takes a stream of bytes in place of a path | level 5, draft | Files and ETL |
gzip, zip | compressed files and archives: gzip.write, gzip.open!, zip.write, zip.list!, zip.read! (see Compressed files) | level 5, tested | below |
crypto | hash, HMAC and the random bytes used by tokens | level 5, draft | Cryptography |
net | TCP and UDP sockets, the wire protocol | level 5, draft | Networking |
database, checkpoint | connections, Record and Table, tracked records, transactions per job, direct SQL, checkpoints | level 5, draft | Databases |
config | the eve.cfg file of a project | level 6, draft | EVE VM |
http | the client (get!, post!, request!) and the server | levels 5 and 6, draft | Networking |
route, service, rpc | the routes of a server, a service script and the remote calls | level 6, draft | The Eve Server |
test | check, equal and summary for the tests a user writes in Eve | level 5, draft | Quality |
Compressed files
A path that ends in .gz is a gzip file for the readers and the writers of csv, json, txt and for fs.lines!: the file is compressed when it is written and inflated when it is read, and a file that is not gzip is a FormatError. gzip.write(path, data) writes a String or Bytes; gzip.open!(path) gives the content as a stream of Bytes, which a reader accepts in place of a path. A zip archive keeps many entries: zip.write takes a map of names to String or Bytes, zip.list! gives the sorted names and zip.read! one entry as Bytes; a missing name is FileError. An archive does not hold a clock, so the same entries give the same bytes. The files are processed whole, in memory, and an archive over 4 GB or with more than 65,535 entries is not supported.
primary aspect archive is
class Item = {name: String, qty: Integer} <: Record;
process main is
new items := (Item(name: "bolt", qty: 4), Item(name: "nut", qty: 9));
csv.write("out/items.csv.gz", items); ** compressed on the fly
for r in csv.read!(:Item)(gzip.open!("out/items.csv.gz")) do
print "{r.name} {r.qty}";
done;
zip.write("out/pack.zip", {"items.csv": "name,qty;bolt,4", "note.txt": "two items"});
for name in zip.list!("out/pack.zip") do
print name;
done;
print zip.read!("out/pack.zip", "note.txt").text();
return;
end archive;
Statistics
The library stats is written in Eve, in the folder lib/stats. from lib use (stats); gives the descriptive functions (mean, median, mode, modes, variance, stddev, quantile, range, skew, kurtosis, describe), the correlations (covariance, pearson, spearman) and the modules regress, distrib, sample, histogram and moving. The sample forms of the variance and the deviation divide by n - 1 (Excel VAR.S); the population forms have the suffix _p. A list that is empty, too short or not made of numbers is ArgumentError.
primary aspect numbers is
from lib use (stats);
process main is
new xs := (2, 4, 4, 4, 5, 5, 7, 9);
print stats.mean(xs), stats.median(xs), stats.modes(xs); ** 5 4.5 (4)
print stats.stddev_p(xs); ** 2
new d := stats.describe(xs);
print d["count"], d["min"], d["max"]; ** 8 2 9
new line := stats.regress.linear((1, 2, 3, 4, 5), (2.2, 4.1, 6.2, 7.9, 10.1));
print line["slope"], line["intercept"], line["r2"]; ** 1.96 0.22 0.9988...
print stats.distrib.norm_cdf(1.96, 0, 1); ** 0.975...
print stats.moving.simple((1, 2, 3, 4, 5), 3); ** (null,null,2,3,4)
for b in stats.histogram.bins((1, 2, 2, 3, 9, 10), 3) do
print "{b.low} {b.high} {b.count}"; ** 1 4 4, 4 7 0, 7 10 2
done;
return;
end numbers;
The tool commands eve fmt and eve lint work on the scripts of a project, see Tools for scripts.
The libraries written in Eve
The folder lib holds libraries written in Eve itself; from lib use (name); imports one, and each has a page in the specification (spec/library). Their functions are members of the library (calendar.add_business_days) and the modules inside are reached by name (text.regex, finance.money). Only the few functions that need the machine are native.
| Library | Modules | What it gives |
|---|---|---|
math | basic, explog, trig, numtheory, linear, random, rational, complex | numbers, vectors and matrices, random numbers |
stats | describe, correlate, regress, distrib, sample, histogram, moving | statistics (see above) |
calendar | period, holidays, business | quarters, fiscal years, the public holidays of DE, FR, GB, RO and US, business days |
text | regex, encode, slug, template, diff, unicode | regular expressions that cannot take exponential time (they are also what the operator =~ uses), Base64, hexadecimal and percent encoding, slugs, templates with {name} holes, the difference of two texts, normalization and width |
finance | money, percent, interest, loan, invest, tax, depreciation, invoice | money as Decimal rounded by the digits of its currency, sharing an amount without losing a cent, loans, net present value, VAT, invoices |
eng | constants, units, numeric, signal, geometry | the constants of physics, about a hundred units, roots, integrals, differential equations, Fourier transform, polygons |
data | rows, quality, infer, stream | group, join and pivot lists of records, the quality of a column, the types of a CSV table, generators that read a source one value at a time |
ids | base32, ulid, check | ULID, short UUID texts, random ids, Luhn, ISBN-13 and IBAN check digits |
primary aspect libraries is
from lib use (calendar, text, finance, eng, data, ids);
process main is
** calendar: holidays and business days
print calendar.add_business_days(time.date(2026, 4, 3), 1, "GB"); ** 2026-04-07: Good Friday and Easter Monday are skipped
print calendar.fiscal_year(time.date(2026, 4, 1), 4); ** 2027
** text: regular expressions, encodings, slugs and templates
print text.regex.replace("2026-10-26", "/(\d+)-(\d+)-(\d+)/", "$3/$2/$1"); ** 26/10/2026
print text.slug("Héllo, Wörld!"), text.url("a b&c"), text.base64("hi"); ** hello-world a%20b%26c aGk=
print text.fill("Dear \{name\}", {"name": "Ana"}); ** Dear Ana
** finance: money is a Decimal rounded to the unit of its currency
print finance.allocate(100.00d, (1, 1, 1), "EUR"); ** (33.34,33.33,33.33)
print finance.vat_add(100.00d, 0.19, "EUR"), finance.round(2.675d, "EUR"); ** 119.00 2.68
** eng: units and numerical methods
print eng.convert(100, "C", "F"), eng.simpson((x) => (x ^ 2), 0, 3, 10); ** 212 9
** data: rows and streams
print data.count_by(("a", "b", "a"), (x) => (x)); ** {"a":2,"b":1}
print data.collect(data.take(data.map((1, 2, 3, 4), (x) => (x * x)), 2)); ** (1,4)
** ids: check digits and ULID
print ids.luhn_valid("4539 1488 0343 6467"), ids.iban_valid("GB82 WEST 1234 5698 7654 32");
print ids.ulid_from(Instant.parse("2026-10-26T12:00:00Z"), "00112233445566778899");
return;
end libraries;
Money is always a Decimal: Decimal has round(scale, mode) with seven modes (half_up, half_even, half_down, up, down, ceiling, floor), scale(), units(), Decimal.of(units, scale) and Decimal.parse(text). The digits of a currency (2 for the euro, 0 for the yen, 3 for the dinar) and the holidays rules come from the same data as the time zones: the file lib/meta/meta.db for the currencies, the rules of a calendar in the library.
Rules of the system library
- Written in Eve. A module is Eve code. Only the few primitives that need the machine are
externaldeclarations, implemented by the virtual machine in Zig (see EVE VM); - Errors are values of the language. A module raises the errors of the
exceptionmodule, so onerecoverregion handles them all; - Thread safety is declared by the compiler. A function of a module is thread safe only if it keeps no plain shared variable; a
concurrent aspectcan call it only then (see Thread safety); - Documented from the code.
eve --docbuilds the reference of a module from its**comments and signatures.
Example
The built-in names are always available. The example below reads a name and writes a line; it uses only the standard streams.
# ask a name and greet
primary aspect greeting is
process main is
new name := read("name: ");
if name <> null then
print "Hello,", name;
else
print "Hello, stranger";
done;
return;
end greeting;
Read next: EVE VM