Skip to content

Search customization & instrumentation

David Nolen edited this page Jan 5, 2013 · 8 revisions

Currently if you want search different from miniKanren search, you're out of luck. Jamie Brandon has done some work to make this more flexible but I think we can take it a step further.

The key insight is that search is completely driven by data structures. The problem is that what data structures we produce is hard coded to a particular type, Substitution. Instead Substitution should contain a new field, call it st for "strategy" which is an ISearch (a protocol) instance. We could imagine that ISearch looks something like the following:

(defprotocol ISearch
  (conjunct [_])
  (disjunct [_])
  (commit [_])
  (cut [_]))

We should of course be skeptical of commit and cut, perhaps better to put those in a separate protocol.

(defprotocl IMKSearch
  (commit [_])
  (cut [_]))

Eventually we should see if these could be constructed on lower level primitives such as described in Search Combinators.

Going down this route would also free us to experiment with instrumenting search for debugging, performance analysis, etc. This could be done cleanly without mucking around with the basic search behavior.

The main thing to be concerned with here is degrading search perfomance, but seeing as it's only one more inline protocol dispatch I'm pretty confident that this can perform well.

Clone this wiki locally