Mycelium
Mycelium is a typed data serialization format. Mycelium values are made up of fundamental values: Bits, Refs, and Ports, and all other types composed from this fundamental set.
Mycelium values are immutable; any change to a Value is necessarily a new Value.
0. Opaque
Opaque is a type that gives no information; it cannot be instantiated. It exists mostly to make the 0 value for TypeCodes an obvious error.
1. Bit
The Bit type requires no additional information; it has two Values 0 and 1.
2. Array
An Array is a finite sequence of elements, all the same type, where the length of the sequence and the type of an element are known at compile time. Arrays are parameterized by 1 type (the element type) and 1 value (the length).
3. Run
A Run is a contiguous segment of elements, all the same type, where the length is unknown. Runs cannot be used directly; they must always exist within a Ref.
4. Ref
A Ref is a reference to another value, kept in the store. Refs are all the same size, and are redeemable for a Value. A Ref can be converted to a Value by reading from the store. Refs are parameterized by 1 type and 0 values.
5. Sum
A Sum has several possible integer-identified fields. Each field has its own independent type. Only one field may be set at a time.
6. Product
A Product is a collection of fields, each of which has an independent Value of an independent type. All fields must be set. Products are parameterized by N types and 0 values.
7. List
A List is an ordered collection of elements, all the same type, with a length known at runtime.
A List is represented as a Ref[Run] of known length, where the length is tracked in the list.
Lists are parameterized by 1 type and 0 values.
8. Lazy
Lazy is a program which requires no additional input, producing an output of a known type. Lazys are parameterized by 1 type and 0 values.
9. Procedure (Proc)
A Procedure is a program which requires additional input, producing an output of a known type. Procs are parameterized by 2 types (input and output) and 0 values.
10. Port
A Port is a token for communication outside the Mycelium virtual machine.
11. Distinct
A Distinct type is marked with a value. This causes the type to become distinct from its base type. A Distinct type is parameterized by 1 type (the base) and 1 value (the mark).
12. Any
Any is a family of formats that can hold a wide variety of values with different types. These values must be converted to another type in order to be used.
AnyValue
AnyValue is a type capable of holding any value.
AnyType
AnyType is a type capable of holding the type of any value.
AnyProg
AnyProg is a type capable of holding any program. Programs are Runs of B32 instructions.
255. Type2
The type of a Type is a Type2.
Type2s always take up 32 bits in Mycelium.