examples/typed-arrays.umsg
%unimsg 0 example/typed-arrays/v0 · 38 lines · 1359 bytes of text · 402 bytes canonical · the raw file
Point at anything below — a sigil, a literal, a brace — and the card says what it is. Keyboard: tab through the document. Every explanation is also printed in full beneath the source.
%unimsg 0 example/typed-arrays/v0
-- Typed arrays, adopted 2026-09-02: a homogeneous numeric array as a kernel
-- value, with a text form a person reads and a diff aligns. See the arrays
-- block of spec/unimsg-v0.umsg and docs/52 for why.
--
-- In the corpus so that every implementation carries one of each kind on
-- every run of check.sh. An implementation that has not implemented the sigil
-- refuses this document, which is the point of its being here.
typed-arrays @example/typed-arrays/v0 {
title "One of each kind of typed array"
-- The type is the marker: no f inside ^f64, and 1.5 inside ^u8 is an error.
readings ^f64 [ 315.71, 317.45, 317.51, 317.27, 315.87 ]
counts ^u16 [ 31, 28, 31, 30, 31, 30 ]
offsets ^i8 [ -3, 0, 2, -1 ]
identifier ^u64 [ 18446744073709551615 ]
-- A shape has at least two extents, joined by x; rows run along the last.
rotation ^f32:3x3 [
0.8660254, -0.5, 0
0.5, 0.8660254, 0
0, 0, 1
]
-- null is a missing POSITION, not a value: the array carries a validity mask.
sensor ^f64 [ 20.5, null, 20.7, 20.6, null ]
-- Half precision, and the three values the text spells specially.
half ^f16 [ 1.5, -0, 65504, 6e-8, nan, inf, -inf ]
-- Empty, shaped and masked at once, and one element.
nothing ^u8 []
grid ^i32:2x2 [ 1, null, null, 4 ]
one ^f64 [ 0.1 ]
}
The canonical encoding
Produced by the reference encoder when this page was built. Decoding these bytes and printing them in the text form returns the document above, byte for byte — that round trip is the claim the whole format rests on.
a1 6c 74 79 70 65 64 2d 61 72 72 61 79 73 da 00 01 11 d5 82 81 da 00 01
11 d6 77 65 78 61 6d 70 6c 65 2f 74 79 70 65 64 2d 61 72 72 61 79 73 2f
76 30 ab 63 6f 6e 65 d8 52 48 3f b9 99 99 99 99 99 9a 64 67 72 69 64 da
00 01 11 db 82 41 09 d8 28 82 82 02 02 d8 4a 50 00 00 00 01 00 00 00 00
00 00 00 00 00 00 00 04 64 68 61 6c 66 d8 50 4e 3e 00 80 00 7b ff 00 01
7e 00 7c 00 fc 00 65 74 69 74 6c 65 78 1f 4f 6e 65 20 6f 66 20 65 61 63
68 20 6b 69 6e 64 20 6f 66 20 74 79 70 65 64 20 61 72 72 61 79 66 63 6f
75 6e 74 73 d8 41 4c 00 1f 00 1c 00 1f 00 1e 00 1f 00 1e 66 73 65 6e 73
6f 72 da 00 01 11 db 82 41 0d d8 52 58 28 40 34 80 00 00 00 00 00 00 00
00 00 00 00 00 00 40 34 b3 33 33 33 33 33 40 34 99 99 99 99 99 9a 00 00
00 00 00 00 00 00 67 6e 6f 74 68 69 6e 67 d8 40 40 67 6f 66 66 73 65 74
73 d8 48 44 fd 00 02 ff 68 72 65 61 64 69 6e 67 73 d8 52 58 28 40 73 bb
5c 28 f5 c2 8f 40 73 d7 33 33 33 33 33 40 73 d8 28 f5 c2 8f 5c 40 73 d4
51 eb 85 1e b8 40 73 bd eb 85 1e b8 52 68 72 6f 74 61 74 69 6f 6e d8 28
82 82 03 03 d8 51 58 24 3f 5d b3 d7 bf 00 00 00 00 00 00 00 3f 00 00 00
3f 5d b3 d7 00 00 00 00 00 00 00 00 00 00 00 00 3f 80 00 00 6a 69 64 65
6e 74 69 66 69 65 72 d8 43 48 ff ff ff ff ff ff ff ff
examples/typed-arrays.umsg 402 bytesEvery construct on this page
The formal columns are read from the specification when this page is generated. The last column is this site's plain-language gloss and is not normative — where they differ, the specification is right.
| construct | glyph | carries | example | gloss |
|---|---|---|---|---|
| :annotation | — | — | — | A bare name qualifying the value after it—for example a language tag or a unit such as kg. It is not a value itself; a bare name with nothing after it is an error, not a guess. |
| :array | ^ | type, or type:shape; then [ elements ] | ^f64 [ 1.5, 2.5 ] or ^i16:2x3 [ … ] | A packed, homogeneous numeric array. The ^ marker gives every element its type and may also give the row-major shape: ^f64:2x3 [ … ]. |
| :array-element | — | — | — | One element of a typed array. Its type comes from the ^ marker, so 1.5 inside ^f64 is binary64 rather than an exact decimal. |
| :array-missing | — | — | — | A missing position in a typed array. null here is not an element value: it adds a validity mask while preserving the array's shape. |
| :block | — | — | — | A block: named pairs, in braces. Its keys are sorted in the encoding and shown here as written. |
| :bytes | ~ | encoding:data | ~hex:ff00 or ~b64:iVBORw0KGgo= | Raw octets, carried as octets. No base64 tax, no pretending they are text. |
| :comment | -- | to end of line | -- a note | A note for people. It travels with the pair it precedes and never reaches the bytes. |
| :decimal | — | — | — | An exact decimal. 19.99 is nineteen and ninety-nine hundredths, not the nearest double to it. |
| :extension | ! | name, then value | !acme/hint { zone 4 } | A qualifier this reader may not know. It survives the round trip intact, and stays legible on the way past — the rule that separates an extension from a private convention. |
| :float | — | — | — | A binary float, marked so it can never be mistaken for the exact decimal beside it. |
| :hash | # | algorithm:hex | #sha256:deadbeef | The digest of some content, with the algorithm said out loud so it is still meaningful in ten years. |
| :header | % | unimsg only | %unimsg 0 label | Declares the format version and what this document is. Optional, and useful exactly when a file arrives without context. |
| :identifier | @ | word | @ord-88213 | Gives this value a name, so another document can point at it without copying it. |
| :integer | — | — | — | A whole number of any size. Past 2^53 it is still exact, which is the whole reason this is not JSON. |
| :key | — | — | — | A field name: the first thing in a pair. It is bare when possible and quoted when needed, and names the content without becoming part of the value. |
| :reference | -> | an identifier or a path | -> @cust-4471, -> @lexicon.entries.kitāb | Points at a name. Nothing follows it while reading — resolution is somebody else's job, deliberately. |
| :reserved-literal | — | — | — | One of six bare words that are values rather than names. The list is fixed, so no value is coerced by what it looks like. |
| :sequence | — | — | — | An ordered list. Order is preserved and is meaning. |
| :string | — | — | — | Text. May span lines, so prose does not have to be escaped into one. |
| :symbol | : | word | :dispatched | A name from a fixed vocabulary, not free text. :high is a value someone chose; "high" is a phrase someone typed. |
| :table-row | | | cells | | sku qty | One record of a table. A table is sugar for a sequence of blocks with the same keys, and encodes identically to the longhand. |
| — | — | — | A temporal value at the precision written. 2026-08 stays a month, and 03:52 stays a wall-clock time; neither is widened into an invented instant. |