Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with producing arbitrary data types from the schemas #46

Open
Adzz opened this issue Feb 4, 2023 · 0 comments
Open

Experiment with producing arbitrary data types from the schemas #46

Adzz opened this issue Feb 4, 2023 · 0 comments

Comments

@Adzz
Copy link
Owner

Adzz commented Feb 4, 2023

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....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant