Skip to content

Support "Voldemort" types for common structures (e.g. key/value mappings) #5

@ascjones

Description

@ascjones

Following up on #3, required before cutting a 0.1 release. From @Robbepop #3 (comment)

I was having a chat with @jacogr and we had the idea to conceptualize certain common structures in the generated JSON SCALE info.
For example we conceptualize the structure of mapping types.
A mapping type encodes as a sequence over some other type that has a key and value field. That's it. Below you can see the JSON that could conceptualize such a scenario concretely. Note that it might be nice to have so-called Voldemord composites that do not have a name since it isn't needed here. We just generate the type at index 1 upon serialization and will never need its name.

{
    names: [
        "BTreeMap", # ID: 1
        "KeyValue", # ID: 2
        "K",        # ID: 3,
        "V",        # ID: 4,
        "key",      # ID: 5,
        "value",    # ID: 6,
    ]
    types: [
        { # ID: 1
            composite: {
                path: [ 2 ], # We actually don't need this.
                             # Could we define composite types without names?
                             # Does that make sense at all? It would be similar
                             # to the concept of Voldemord types.
                fields: [
                    { name: 5, type: 4 },
                    { name: 6, type: 5 },
                ]
            }
        },
        { # ID: 2
            sequence: {
                type: 1
            }
        },
        { # ID: 3
            composite: {
                path: [ 1 ],
                params: [ 4, 5 ],
                fields: [
                    type: 2
                ]
            }
        },
        ...
    ],
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions