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 
<https://git.sr.ht/~amz3/azul/tree/master/src/azul/data/base/yiwen.scm>.
There is a few tests in yiwen.test.scm 
<https://git.sr.ht/~amz3/azul/tree/master/src/azul/data/base/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 
<https://git.sr.ht/~amz3/azul/tree/master/src/azul/data/base/yiwen.scm> 
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
equal predicate and comparator (see SRFI 128 comparators 
<https://srfi.schemers.org/srfi-128/>). It seems to work with
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.

-- 
You received this message because you are subscribed to the Google Groups 
"minikanren" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/minikanren.
For more options, visit https://groups.google.com/d/optout.

Attachment: yiwen.scm
Description: Binary data

Attachment: yiwen.test.scm
Description: Binary data

Attachment: logic.scm
Description: Binary data

Attachment: logic.test.scm
Description: Binary data

Reply via email to