Skip to main content

Crate flow_value

Crate flow_value 

Source
Expand description

The Flow runtime value model.

This crate is what a value is while a program runs, and the operations the language fixes on values rather than on any one program:

  • the built-in data types of data.md — unbounded Int, exact Decimal, code-point Text, Bytes, List, Dict and Set sorted by key, Duration and Instant — with the operators std declares for them, including where they fault (Fault);
  • records, enum values and tuples by declaration (Record, Variant, Tuple);
  • types.md’s structural equality and total order over every data value (compare, equal), and the text form interpolation inserts (interpolate, text_form);
  • the values a run holds that are not data — functions and other evaluator-made values (Native), task handles (TaskId) and host tokens (HostToken) — which have none of those operations and are refused by each of them (DataError).

Every rule here is exact and independent of the host’s word size, locale, hash order and floating-point unit: replay computes pure work again, so two implementations that disagreed on any result would disagree on a run.

§What is deliberately absent

Types. The checker owns types; at run time a value carries no type beyond the declaration a record or enum value needs for its text.

Encoding. The JSON value encoding and its canonical form are abi.md’s and live with the protocol; this crate exposes the parts an encoder reads.

Limits. An Int has no bound and a Text no size here; the host’s limits on a program’s own values are the evaluator’s to enforce, and every measure it needs — Int::bits, Text::byte_len, Bytes::len — costs constant time.

§Unicode

Normalization, case mapping, grapheme segmentation and a Regex’s classes use the tables of one Unicode version, UNICODE_VERSION, which std’s version fixes. Every table comes from a pinned crate; none is the Rust toolchain’s.

§Depth

Equality, order, text and dropping walk a value with a stack on the heap, never the native one, so a value nested as deeply as memory allows is compared, printed and dropped like any other.

Structs§

BigInt
A big signed integer type.
Bytes
A finite sequence of bytes: raw, unnormalized, ordered lexicographically by unsigned byte value with a proper prefix first.
Constructor
One constructor of an enum declaration.
Decimal
An exact decimal number.
Dict
A dictionary: keys mapped to values, sorted by key.
Duration
A length of time, ordered by length.
EnumShape
An enum declaration: its name and its constructors in declaration order.
HostToken
The token a host chose for a @tool type value. Flow stores it, compares nothing about it, and hands it back unchanged (abi.md).
Instant
A point in time, ordered chronologically.
Int
An integer, with no bound.
List
A list: a finite sequence, in order.
Native
A value the evaluator owns, carried opaquely.
Record
A record value.
RecordShape
A record declaration: its name and its fields in declaration order.
Set
A set: distinct values, sorted.
TaskId
Which task a task handle names. What the number means is the evaluator’s.
Text
A finite sequence of Unicode code points, stored as UTF-8.
Tuple
A tuple’s parts, in order.
Variant
An enum value.

Enums§

DataError
Why equality, ordering or text was refused.
Fault
Why an arithmetic operation produced no value.
Payload
What a constructor carries.
Value
A run-time value.

Constants§

DIVISION_DIGITS
How many significant digits a quotient with no finite expansion keeps.
UNICODE_VERSION
The Unicode version normalization, case mapping, grapheme segmentation and a Regex’s classes use (data.md, Text).

Traits§

Holding
A value that a Native carries and that holds values of its own.

Functions§

compare
Returns how left orders against right.
equal
Returns whether left == right: structural equality, which holds exactly when compare answers Equal.
interpolate
Returns what interpolating value inserts: a Text value’s own code points, and any other data value’s text form.
text_form
Returns value’s text form, with a Text written as a literal.
text_form_within
Returns value’s text form when its UTF-8 takes at most max_bytes bytes, and None otherwise.