Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

serde.md
# serde.sprak
Library for (de)serialising data.

## Functions
### `serialise_string`
Returns the serialised form of a string input where `\` and `"` characters have been prepended with `\`.
#### Type
`string -> string`
#### Arguments
* `input`: String to serialise.
#### Examples
```sprak
Print(equal(serialise_string('foo"\\'), 'foo\"\\\\'))
```

### `serialise_array`
Returns the serialised version of an `array`. Excludes elements whose keys are not of type `bool`, `number`, `string`, or `unknown`. Keys of type `unknown` are assumed to be `array` indices and will be converted to `number`.
#### Type
`array -> string`
#### Arguments
* `input`: Array to serialise.
#### Examples
```sprak
Print(equal(serialise_array([true, false]), "{0:t,1:f}"))
```

### `serialise`
Returns the serialised version of the input. Assumes data of type `unknown` are `array` indices and are converted to `number`. Data of type `number` are rounded to include only up to 6 decimal places of precision.
#### Type
`var -> string`
#### Arguments
* `input`: Input to serialise.
#### Examples
```sprak
Print(equal(serialise(true), "t"))
Print(equal(serialise(false), "f"))
Print(equal(serialise(-273.15), "-273.15"))
Print(equal(serialise([true, "false"]) == '{0:t,1:"false"}'))
```

### `deserialise_string`
Returns the deserialised form of the input.
#### Type
`string -> string`
#### Arguments
* `input`: Serialised string to deserialise.
#### Examples
```sprak
Print(equal(deserialise_string('"foo\"\\\\"'), 'foo"\\'))
```

### `is_digit`
Determines if the input character is a numeric digit. `CharToInt` isn't used as this isn't always available.
#### Type
`string -> bool`
#### Arguments
* `input`: Character to test.
#### Examples
```sprak
Print(is_digit(0))
Print(!is_digit(a))
```

### `deserialise_array`
Returns the deserialised form of the input.

Assumptions:
* "\\" and whitespace characters only occur in strings.
* Keys are only of type `bool`, `number` or `string`.
* Input is valid.
#### Type
`string -> array`
#### Arguments
* `input`: Serialised array to deserialise.
#### Examples
```sprak
Print(equal(deserialise_array("{0:t,1:f}"), [true, false]))
```

### `deserialise`
Returns the deserialised form of the input.

Assumptions:
* "\\" and whitespace characters only occur in strings.
* `array` keys are only of type `bool`, `number` or `string`.
* Input is valid.
#### Type
`string -> var`
#### Arguments
* `input`: Input to deserialise.
#### Examples
```sprak
Print(equal(deserialise("t"), true))
Print(equal(deserialise("f"), false))
Print(equal(deserialise("-273.15"), -273.15))
Print(equal(deserialise('{0:t,1:"false"}'), [true, "false"]))
```

## TODO
* Handle failures during deserialisations by outputting `[true, parse]` or `[false, error]`.
* Replace mutual recursions with iterations in:
	* `serialise_array` and `serialise`