Skip to main content

Module value_json

Module value_json 

Source
Expand description

dive’s JSON values (trace format version 1).

TLC’s -dumpTrace json form (dive_value::json) cannot be read back exactly: a set and a sequence are both arrays, a string and a model value are both strings. This form distinguishes them. It is a value transport, not a stored-representation transport: it does not record how TLC happened to store a value (a tuple or a function with domain 1..n, for instance). Scalars remain plain JSON:

ValueJSON
TRUE, FALSEtrue, false
an integer in i64 rangea number: 3, -7
any other integer{"int": "123456789012345678901234567890"}
a string "a""a"
a model value m1{"model": "m1"}
a set {1, 2}{"set": [1, 2]}
a tuple or sequence <<1, "a">>{"seq": [1, "a"]}
a record [a |-> 1]{"record": {"a": 1}}
any other function (1 :> "a" @@ 3 :> "b"){"fcn": [[1, "a"], [3, "b"]]}

A function whose domain is 1..n is a seq; one whose domain is a non-empty set of strings is a record. Reading normalizes, so a fcn with domain {1, 2} reads as the sequence it equals. Sets are written in the run’s normalized order. Reading reconstructs mathematical sets, so mixed structured values round-trip independently of input order. Literal/function and Raw/normalized representation flags are not preserved. Infinite sets (Nat) have no form.

Functions§

from_json
Reads a value in dive’s JSON form, interning names in names.
to_json
Writes v in dive’s JSON form.