Await as query for a Receipt #30
andrewzhurov
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to share an insight (perhaps not that surprising for some 😄) on how Await resembles a query for a Receipt's value.
E.g.,
behaves as a query for a Receipt where instruction is
bafy...getMailingList
and result isok
, selecting/pulling data that's underok
.I wonder what values we could get by expanding on this idea, embracing Await as a way to query.
First of all, what if we'd have a more expressive DSL for "where" / pattern-matching?
Say we have sendEmail instruction that awaits on getMailingList instruction
An alternative way to express the above await is to treat it as pattern-matching on Receipt,
we could express it as:
Interestingly, it allows us to pattern-match on any Receipt values that's been previously outside of our reach,
e.g., on
meta
field of TaskWhich is equivalent to
or on
iss
of the Receiptand oh well, nothing stops us from specify it down to the exact Receipt!
And now to the "select" bit of query,
atm we have
await/ok
expressing two things 1) await / query 2) select "ok"We could decouple the two!
And now we're able to pull arbitrary data out of those Receipts, say it's
iss
All this lands us a foot short from treating Receipts as graph data and implementing yet another graph querying engine over it.
What are the values out of a more expressive "where" and "select" is yet to be defined. 😄
And it comes with its costs, as now implementation of Promise Pipelines is more heavy.
Where previously implementations would simply filter Receipts by Instruction and "ok"/"error" fields, now they need to pattern-match Receipts with
where
.Where previously they would simply select "ok"/"error"/"*", now they need to
getIn(Receipt, select)
(ok this one is not that heavy :laugh:)Side-thought.
Interestingly, an Executor could attenuate Task down to its exact awaited Receipts before executing it.
Perhaps this may be an elegant way to "how capture exact Receipt awaited" that #22 rumbles about.
Beta Was this translation helpful? Give feedback.
All reactions