diff options
author | Profpatsch <mail@profpatsch.de> | 2020-06-02 00:15:13 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2020-06-02 00:15:13 +0200 |
commit | b1717c994907eb6ff1b1021c1706573781f846c2 (patch) | |
tree | d7e34668175dd6ff0581ca3d614d38c33927bfa5 /pkgs/profpatsch/encode | |
parent | 1b1fe266f12a4edf3e8cab6c1e59554eb83555f6 (diff) |
pkgs/profpatsch/encode: listify spec examples
Diffstat (limited to 'pkgs/profpatsch/encode')
-rw-r--r-- | pkgs/profpatsch/encode/spec.md | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/pkgs/profpatsch/encode/spec.md b/pkgs/profpatsch/encode/spec.md index 163ad414..d3624c84 100644 --- a/pkgs/profpatsch/encode/spec.md +++ b/pkgs/profpatsch/encode/spec.md @@ -13,7 +13,7 @@ where size is a natural number without leading zeroes. The unit (`u`) has only one value. -The unit is: `u,` +* The unit is: `u,` ### numbers @@ -21,11 +21,11 @@ Naturals (`n`) and Integers (`i`), with a maximum size in bits. Bit sizes are specified in 2^n increments, 1 to 9 (`n1`..`n9`, `i1`..`n9`). -Natural `1234` that fits in 32 bits (2^5): `n5:1234,` -Integer `-42` that fits in 8 bits (2^3): `i3:-42,` -Integer `23` that fits in 64 bits (2^6): `i64:23,` -Integer `-1` that fits in 512 bits (2^9): `i9:-1,` -Natural `0` that fits in 1 bit (2^1): `n1:0,` +* Natural `1234` that fits in 32 bits (2^5): `n5:1234,` +* Integer `-42` that fits in 8 bits (2^3): `i3:-42,` +* Integer `23` that fits in 64 bits (2^6): `i64:23,` +* Integer `-1` that fits in 512 bits (2^9): `i9:-1,` +* Natural `0` that fits in 1 bit (2^1): `n1:0,` An implementation can define the biggest numbers it supports, and has to throw an error for anything bigger. It has to support everything smaller, so for example if you support up to i6/n6, you have to support 1–6 as well. An implementation could support up to the current architecture’s wordsize for example. @@ -35,10 +35,10 @@ Floats are not supported, you can implement fixed-size decimals or ratios using Text (`t`) that *must* be encoded as UTF-8, starting with its length in bytes: -The string `hello world` (11 bytes): `t11:hello world,` -The string `今日は` (9 bytes): `t9:今日は,` -The string `:,` (2 bytes): `t2::,,` -The empty sting `` (0 bytes): `t0:,` +* The string `hello world` (11 bytes): `t11:hello world,` +* The string `今日は` (9 bytes): `t9:今日は,` +* The string `:,` (2 bytes): `t2::,,` +* The empty sting `` (0 bytes): `t0:,` Binary data is not supported, it hinders human readability. Try to use structured data, or use a different format. @@ -48,19 +48,19 @@ Binary data is not supported, it hinders human readability. Try to use structure A tag (`<`) gives a value a name. The tag is UTF-8 encoded, starting with its length in bytes and proceeding with the value. -The tag `foo` (3 bytes) tagging the text `hello` (5 bytes): `<3:foo|t5:hello,` -The tag `` (0 bytes) tagging the 8-bit integer 0: `<0:|i3:0,` +* The tag `foo` (3 bytes) tagging the text `hello` (5 bytes): `<3:foo|t5:hello,` +* The tag `` (0 bytes) tagging the 8-bit integer 0: `<0:|i3:0,` ### records (products/records), also maps A record (`{`) is a concatenation of tags (`<`). It needs to be closed with `}`. If tag names repeat the later ones should be ignored. Ordering does not matter. -There is no empty record. (TODO: make the empty record the unit type, remove `u,`?) -A record with one empty field, `foo`: `{<3:foo|u,}` -A record with two fields, `foo` and `x`: `{<3:foo|u,<1:x|t3:baz,}` -The same record: `{<1:x|t3:baz,<3:foo|u,}` -The same record (later occurences of fields are ignored): `{<1:x|t3:baz,<3:foo|u,<1:x|u,}` +* There is no empty record. (TODO: make the empty record the unit type, remove `u,`?) +* A record with one empty field, `foo`: `{<3:foo|u,}` +* A record with two fields, `foo` and `x`: `{<3:foo|u,<1:x|t3:baz,}` +* The same record: `{<1:x|t3:baz,<3:foo|u,}` +* The same record (later occurences of fields are ignored): `{<1:x|t3:baz,<3:foo|u,<1:x|u,}` ### sums (tagged unions) @@ -70,10 +70,10 @@ Simply a tagged value. The tag marker `<` indicates it is a sum if it appears ou A list (`[`) imposes an ordering on a sequence of values. It needs to be closed with `]`. Values in it are simply concatenated. -The empty list: `[]` -The list with one element, the string `foo`: `[t3:foo,]` -The list with text `foo` followed by i3 `-42`: `[t3:foo,i3:-42,]` -The list with `Some` and `None` tags: `[<4:Some|t3:foo,<4None|u,<4None|u,]` +* The empty list: `[]` +* The list with one element, the string `foo`: `[t3:foo,]` +* The list with text `foo` followed by i3 `-42`: `[t3:foo,i3:-42,]` +* The list with `Some` and `None` tags: `[<4:Some|t3:foo,<4None|u,<4None|u,]` ## motivation |