-
Notifications
You must be signed in to change notification settings - Fork 78
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
Batchable doesn't seem to work with anything complex #133
Comments
Replicated issue at https://scastie.scala-lang.org/tRxoUdXNQpesymVEhkcQfw |
I have the full solution on my other laptop but I will try to explain and reproduce here. When you want to batch queries you have a bunch of effects returning results upon evaluation
You also assume that there's a way to "batch" several of those queries into a "batched" one:
Here Now if we come back to your example, you have queries returning
In the case class above Then:
This works but unfortunately is completely type-unsafe. Maybe we could try to define laws that a given I will send you the code tonight if you cannot write it with the indications above. |
I figured it was something like that. That makes sense, I actually ditched using it because I needed ordering I just wanted to smash a bunch of the ones next to each other, together. Seq(
Add(1),
Add(2),
Get(2),
Add(1),
)
= Seq(Add(3), Get(2), Add(1)) So Maybe the answer should be leaving something like this comment in the source code at Batchable, it really isn't explained super well. And you're right, its not really representable in the type system, at least that I could think of. |
I wonder if the
Super untyped but that leaves you the opportunity to batch exactly what you want:
But the opportunity for making mistakes is so big! And also very coupled to how commands are being interpreted. Which makes me this that maybe this is better left to each interpreter to do this dispatch/distribution internally by privately creating batched commands and redistributing results. So my last thought is: maybe I should just drop the functionality and give an example of a batching interpreter? |
I am closing to close this for now until we can come up with something more sensible. |
I've got an example that compiles but throws a head error. The only thing different from the example is the interpreter looks different (less raw) and we can't combine all the effects. In the example there are two effects getUser and getUsers, all of which can be combined. This example adds something orthogonal that cannot be be combined.
Below is an example of it throwing.
https://gist.github.com/dispalt/28ece72e3bace1dece4b1edd6e4706a8
The text was updated successfully, but these errors were encountered: