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

Deprecate tuple decoders #121

Closed
3 tasks done
mlms13 opened this issue Mar 25, 2023 · 1 comment · Fixed by #129
Closed
3 tasks done

Deprecate tuple decoders #121

mlms13 opened this issue Mar 25, 2023 · 1 comment · Fixed by #129
Labels
code quality Internal improvements
Milestone

Comments

@mlms13
Copy link
Owner

mlms13 commented Mar 25, 2023

tupleFromFields should definitely go... there have been times I wanted that in the past, and even I didn't remember it exists. With the addition of let-ops, that one is way more easily expressed as:

let+ first = field("first", string)
and+ second = field("second", boolean);
(first, second);

And while thinking about that, I started to wonder if the helpers like tuple2 and tuple3 could also be simplified. I'm thinking something like:

let+ first = arrayAt(0, string)
and+ second = arrayAt(1, boolean)
and+ third = arrayAt(2, date);
(first, second, third);

The downside is that it's more verbose than what we currently have, but I see several upsides:

  • the syntax is consistent with decoding objects/records, so there are fewer concepts to remember
  • you aren't arbitrarily capped at a 5-tuple... tuples can get as big as you want
  • picking specific positions out of arrays might be generally useful even outside of tuples

JSON-encoded tuples aren't a supper common occurrence in my experience, and the current approach requires quite a bit of code to support. I'll have to think about it, and I'm happy to hear any feedback.

The Plan:

  • add arrayAt
  • deprecate tupleN
  • deprecate tupleAtLeastN

And when these are actually removed in 2.0, I'll make sure to add tuple examples to the docs and also include this change in an upgrade guide.

@mlms13 mlms13 changed the title Consider removing tuple decoders Consider deprecating tuple decoders Apr 8, 2023
@mlms13
Copy link
Owner Author

mlms13 commented Apr 8, 2023

This would be consistent with the goal to remove mapN functions (see: #123).

I was previously on the fence, but I think I've decided that the increased flexibility and the fewer concepts for library users to learn makes this change worth it, even if the resulting user code is just a little more verbose.

@mlms13 mlms13 changed the title Consider deprecating tuple decoders Deprecate tuple decoders Apr 8, 2023
@mlms13 mlms13 added this to the v1.2 milestone Apr 8, 2023
@mlms13 mlms13 added the code quality Internal improvements label Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Internal improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant