Hello,
Following on my previous work with mini/micro kanren with wiredtiger storage engine.
I made a in-memory triple store with minikanren querying.
The source is attached to this mail. It can also be found at
source hut.
There is a few tests in
yiwen.test.scm. The full minikanren language is
supported even recursive queries like appendo. There is no tests for that,
tho, because I did not find a good example of recursive queries in triple store
setting.
In the code 'azul logic' is minikanren from the reasoned schemer second edition.
It rely on r7rs scheme mapping module that is actually
srfi 146 which is
(like wiredtiger) an ordered mapping. It is less that 200 sloc.
This should be easy to port to any scheme that has some kind of ordered mapping.
The current implementation rely on a red-black tree.
Also, it is not RDF. It is not datomic either because I does not force to declare a
schema upfront. Garbage in, garbage out!
All scheme base data types (string, fixnum, floatnum, array, cons/lists, symbol) are
supported as subject, predicate and value. They are compared using their respective
records like srfi-9 too.
I am currently experimenting with that triple store as an application tree to build an
editor. An editor has more or less deeply nested structures think about the rendering
tree of horizontal and vertical panes. You might think zippers or cursors.
The triple store allows to easily represent recursive data structures in a single flat
namespace by introducing indirection between a key-value pair (predicate-object)
and its 'subject'. Also, the fact that the triple store is a sort-of global unique data
structure that stores everything, it makes it easy to debug state. Not introducing
zipper or cursors is easier to my mind because at the end of the day a triple store
is a mapping that is ordered.