This is a follow-up to my previous question.
As I understand from Haxl and Stitch they use a monad for data access. The monad is actually a tree of data access commands. The children are the commands the node depends on. The siblings are executed concurrently.
The business logic creates the monad and then a separate function fetch
interprets it.
Now, the question: Suppose I am performing a few data access operations concurrently. I can use an applicative functor (not a monad), which is just a list of commands (not a tree).
Does it make sense ? What if the list contains duplicate commands ?
I think by construction of the Fetch
values the possibility of repeating the same query is avoided, even in the same round of queries (when they are "siblings" as you say). If you look at the paper, the figure 4 explains the implementation of dataFetch
, which is the constructor of Fetch
values. It accounts for three possibilities:
In the last case you will notice that the value returned has an empty sequence of BlockedRequest
s, because in this case some other Blocked
fetch has it. This way, when the ap
function is called with this value it won't concatenate the same repeated request.
BTW I have been trying to implement Haxl in Scala here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With