Eve System Library

The Standard Library is what every program has without an import: the built-in functions and the standard streams. The System Library is the set of modules that connect a program to the machine around it: the console, the file system, the clock, the shell and the network. A module of the system library is imported with from … use, like any other module, from $EVE_LIB.
Status: the built-in names need no import and are complete for level 1. The modules of level 5 (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

ModuleWhat it holdsStatusPage
built-in namesprint, write, read, error, warning, log_err, log_wrn, raise, expect, assertlevel 1, completeStandard Library
system variables$EVE_DIR, $EVE_ASP, $EVE_LIB, $EVE_OUT, $HOME, $OS_PWD, $NAME and every environment variable as $NAMElevel 1, draftEVE VM
math, statsnumbers 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, testedbelow
fsfiles, folders and paths: read and write text and bytes, lines as a stream, list a folder, glob; the operator / joins pathslevel 5, draftFiles and ETL
timethe clock, Instant, DateTime with a zone from the IANA database (the zone of the machine too, on Windows through the CLDR names), sleepinglevel 5, draftDate and Time
osrun! to run a command and env for the environmentlevel 5, draftShell Commands
secretSecret: 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_FILElevel 5, draftDatabases
csv, json, txtread 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 pathlevel 5, draftFiles and ETL
gzip, zipcompressed files and archives: gzip.write, gzip.open!, zip.write, zip.list!, zip.read! (see Compressed files)level 5, testedbelow
cryptohash, HMAC and the random bytes used by tokenslevel 5, draftCryptography
netTCP and UDP sockets, the wire protocollevel 5, draftNetworking
database, checkpointconnections, Record and Table, tracked records, transactions per job, direct SQL, checkpointslevel 5, draftDatabases
configthe eve.cfg file of a projectlevel 6, draftEVE VM
httpthe client (get!, post!, request!) and the serverlevels 5 and 6, draftNetworking
route, service, rpcthe routes of a server, a service script and the remote callslevel 6, draftThe Eve Server
testcheck, equal and summary for the tests a user writes in Evelevel 5, draftQuality

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.

LibraryModulesWhat it gives
mathbasic, explog, trig, numtheory, linear, random, rational, complexnumbers, vectors and matrices, random numbers
statsdescribe, correlate, regress, distrib, sample, histogram, movingstatistics (see above)
calendarperiod, holidays, businessquarters, fiscal years, the public holidays of DE, FR, GB, RO and US, business days
textregex, encode, slug, template, diff, unicoderegular 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
financemoney, percent, interest, loan, invest, tax, depreciation, invoicemoney as Decimal rounded by the digits of its currency, sharing an amount without losing a cent, loans, net present value, VAT, invoices
engconstants, units, numeric, signal, geometrythe constants of physics, about a hundred units, roots, integrals, differential equations, Fourier transform, polygons
datarows, quality, infer, streamgroup, 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
idsbase32, ulid, checkULID, 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 external declarations, implemented by the virtual machine in Zig (see EVE VM);
  • Errors are values of the language. A module raises the errors of the exception module, so one recover region 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 aspect can call it only then (see Thread safety);
  • Documented from the code. eve --doc builds 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