Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
iter
Experimental lazy iterator library to test the capabilities of go generics in 1.18 (by urandom)
I faced the same issue when migrating genesis from code generation to generics. Before it used to have the same streaming API as you describe but now I decided to go with functional API. That means, you basically "pipe" data with temporary variables. So your last example would look something like this:
Yes, it requires you to come up with more variable names but it doesn't make code much longer or less readable. The proposal add elixir-like pipe operator has a long discussion on the subject. That said, I'm still trying to figure out if it is possible to implement with generics some kind of pipe or lenses.
Came to pretty similar conclusions regarding the ergonomics myself: https://github.com/urandom/iter/blob/main/README.md