Skip to content

Experiment with producing arbitrary data types from the schemas #46

@Adzz

Description

@Adzz

Currently the library is focused around emitting a Struct from some arbitrary input data.
This is fine and good but the way we do that is with a reduce, which makes me wonder if it's possible to have schemas reduce into any arbitrary data type. It would be fun to explore this.

A use case could be using data_schema to parse API responses, but then also wanting to serialise requests from a struct, for example. So the flow would be:

API response (xml) => Struct => biz logic happens 
                                  ||
API request (xml) <============ Struct

An early idea is perhaps schemas have another attr like @accumulator %MyStruct{} or @serialises_to "" that we can provide as the accumulator.
We'd probably end up making another fn that to_struct calls that does the reduce.

This could possible clean up the whole "reducing to a map" thing in the runtime schemas....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions