The ideas were a bit more complicated than I knew how to break down into a quick running example. XD;; That's kinda why I just brain-dumped them into that post.
As a basic outline of the technique, imagine building a library of simple functions that construct FleetDB queries (which is to say, a combinator library), and then building macros on top of those to make them a bit nicer to use. That's most of what I'd do, except that I'd probably put in two extra abstraction layers:
- A translator for optimizing queries just before they're sent to FleetDB. This may or may not turn out to be helpful, depending on whether FleetDB does its own optimization. Also, this is a bit of a computational complexity rabbit hole, and I'm not sure how I'd begin to approach it. I'd probably just make it extensible so other people could try. :)
- A macro that takes an s-expression DSL and manually walks over it and converts it into calls to the combinator library. This would allow us to use operator names like 'or and '< without redefining Arc's own 'or and '<. This is probably where I can best help you out with a code example: