These are some thoughts about the design of a F# library to serialize partially abstract finite tree-shaped data.
Basis
See the considerations in bonsai.
Practical considerations
- tuples
- struct tuples MS doc: treat as normal tuples
- arrays
- sequences: are not data and therefore forbidden
- although in practice sequences over immutable containers seem to be reiterable, there is no guarantee on the .NET level for this
- discriminated unions MS doc: treat as variants
unit
equals typevoid
- has no value
- must be special cased and map to the empty tuple
option<'a>
- None has value
null
- this must be special cased
- None has value
list<'a>
: is a recursive DU (variant)- can not be treated with normal machinery
- special case and treat as immutable
array<'a>
- treat as immutable
Array 'a
- recursiveness check for DUs
- enums: should automatically represent as the underlying integer type MS doc
- records
- std lib containers (optional default representation)
Map<'k, 'v>
asarray<'k * 'v>
Set<'a>
asarray<'a>