Skip to main content

Standard Library

The standard library lives in common/ and is written in Raven – it's the best large example of Raven code, and worth a browse. It's imported implicitly, so everything below is available without an import.

This page is a map of what lives where; for now, the source (and its @doc strings) is the reference.

Core (core.rv)

The primitives everything else builds on: Tag, Ref, Closure, structural equality ==/!=, arithmetic and comparison operators, show/print/println, and abort. Also the two workhorse bundles:

bundle Optional { Some(x), Nil() } # with nil, nil?, notnil
bundle Result { Ok(x), Err(e) } # with unwrap

Numbers (numbers.rv, integer.rv, bigint.rv, complex.rv)

The numeric tower and its traits (Integer, Real, Number):

  • integer.rvBits[N], Bool, Int64/Int32, UInt64/UInt32/UInt16/UInt8, true/false, bits, typemin/typemax/bitsize.
  • numbers.rvcoerce/promote, min/max, zero/one, div/rem/round, abs/abs2/conj/real/imag, factorial, and the scientific functions (sqrt, exp, log*, trig and hyperbolic families).
  • bigint.rvBigInt and big, arbitrary precision via JS bigints.
  • complex.rvComplex(re, im).

Collections (list.rv, sequence.rv, iterate.rv, record.rv)

  • list.rvList, length, append, pop, set, empty?.
  • sequence.rv – linked lists: Sequence, seq, first/rest/prepend, seqRange, repeat, sum.
  • iterate.rv – the iteration protocol: iterate/next, Range/range, map/mapping, collect, reduce, count, nth, IndexIterator.
  • record.rv – ordered tag/value pairs: Record, record, getkey/setkey/haskey/merge.

Strings (strings.rv)

String, Char, Regex; string and concat; chars/utf8/utf16 encoding views; contains? and matches. See the Strings chapter.

Patterns (patterns.rv)

The machinery behind pattern matching: match, matchTrait, isa?, and the Any/NotNil traits.

Platform (wasm.rv, wasm/, io.rv, channel.rv)

  • wasm/js.rvJS interop: js, JSObject, await, async, new, import, typeof, sleep, readline.
  • wasm/numeric.rvFloat64/Float32, Inf/NaN/pi, and the wasm implementations of the math functions.
  • wasm/memory.rv, wasm/malloc.rv – low-level memory: Ptr, Cell, malloc!/free!, reference counting internals. See WebAssembly.
  • io.rvargs, readFile. (Yes, that's the whole of IO so far.)
  • channel.rvChannel, put!/take!, RingBuffer – early concurrency primitives.

What's missing

No hash maps or sets, very little IO, no dates, no networking. The roadmap has the plan; in the meantime, much of this can be reached through JS interop.