Add high-level serializer for 3D types #127
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an additional
as_serializer : t:typ ... -> serializer (as_parser t)
function to the 3D interpreter.Some notable complications:
parse_nlist
cannot be the type of all lists of elements. Instead the type needs to be refined to lists whose serialization issz
bytes long. (SeeFLData.parse_fldata
vs.FLData.parse_fldata_strong
.)as_type
function now depends onas_serializer
. Naturally, we would implement this is a mutual recursion ontyp
but here we can't do this because of type dependencies. AFAICT F* does not support mutual recursion for functions whose types depend on the other functions' values, so I manually packed it into a dependent pair.as_type : typ ... -> Type
as_parser : t:typ ... -> parser ... (as_type t)
as_serializer : t:typ ... -> serializer (as_parser t)
WeakKindStrongPrefix
to satisfy the preconditions of the serializer. This breaks some creative applications which specify a byte-length for a variable-length type by treating it as an array with a specified byte-size (with at most one element), like inTestAllBytes.3d
:[@@erasable]
annotation does not seem to work forserializer
. I have no idea why, it works just fine for the analogously definedparser
type.