Skip to content

Standard Library

The standard library is the set of tools that come with Emerald, for jobs most programs end up needing: reading and writing files, working with dates, matching patterns in text, talking to the web. Like the built-ins, they need no import; every one is already there when a program starts.

  • Math, Program, and Random: Math for constants, trigonometry, logarithms, and powers; Program for the running program’s own command-line arguments, and pausing it; and Random for seeded random numbers.
  • Files: File and Directory to read, write, and list; Path for working with file names; FileHandle and FileWriter for streaming; and FileError.
  • Dates and Times: Date, Time, DateTime, Instant, Duration, TimeZone, Weekday, Stopwatch, and DateTimeError, with advice on which to use.
  • Regular Expressions: Regex and Regex.Match, to find, replace, and split text by pattern, and RegexError.
  • Console: Console and Console.Color, for styled output, tables, and prompts.
  • JSON: Json, Json.Kind, and JsonError, to read and write JSON text.
  • CSV: Csv and CsvError, to read and write comma-separated tables.
  • Base64 and Digest: Base64 to write binary data as text, and Digest for SHA-256 and HMAC-SHA256 fingerprints. Their errors are an EncodingError.
  • HTTP: Http and Http.Response, to make web requests, and HttpError.
  • Tasks and Channels: Tasks, Task, TaskGroup, and Channel, to let several pieces of work wait at once and pass values between them, with CancelledError and DeadlockError.

A name that a program declares itself always wins over one of these, so a program with its own File still works. The library’s version stays reachable as Emerald.File; see Projects and Namespaces.