IRC channel logs

2017-12-13.log

back to list of logs

<kristofer>amz3: can you help me understand how this (list-posts-query) on line 813 of https://framagit.org/a-guile-mind/azul/blob/master/web/web.scm
<kristofer>?
<amz3>kristofer: yes, ping me later today
<kristofer>amz3: I'd like to make a similar query for https://github.com/kristoferbuffington/gnupaste/blob/master/gnupaste/paste.scm
<amz3>kristofer: tx for considering wiredtiger :)
<amz3>kristofer: first things, with-env must be called once per program
<amz3>it will setup a fluid and then you are good to go, you don't need to pass around anything around
<amz3>(except if you use threads)
<amz3>anyway
<amz3>kristofer: the query you want is similar to this https://www.paste.org/89217
<amz3>mind the fact that I change reverse to reverse! and sort to sort!, because I think it's more performant and in this context doesn't introduce a side effect outside the procedure
<amz3>the run* procedure inside 'list-posts-query' is similar to 'run' form provided by minikanren/microkanren
<amz3>so basically it runs the declared logic problem and returns the variables that appear such as arguments
<amz3>(run* (post/body post/time) ...) will return a list of post/body and post/time
<amz3>the 'fresh' form introduce variables in the logic program, I see now that's it's a mistake
<amz3>I will paste a fixed code. you don't need to vote? variable in this problem
<amz3>BUT a empty 'toplevel' fresh form must always follow run* but I don't know why
<amz3>fresh is like 'let' for minikanren programs
<amz3>'fs:queryo' is the magic procedure that allows to query the databae
<amz3>Here is the definition of fs:queryo https://framagit.org/a-guile-mind/guile-wiredtiger/blob/master/wiredtiger/feature-space.scm#L107
<amz3>so in the feature space, the 'atoms' are tuples that look like (unique-idenfiier attribute-name value)
<amz3>several tuples of this form with the same unique identifier make a feature (or document in mongodb parlance (or row in RDBMS))
<amz3>if a set of tuples have the same identifier you can 'factor' the identifier and build an alist that as attribute-names as key and values as value
<amz3>anywa
<amz3>what fs:queryo does, is try to pattern match the tuples that are found in the database
<amz3>the following query https://www.paste.org/89217 could be rewritten without fs:queryo like the following
<amz3> https://hastebin.com/uziwubuxus.lisp
<amz3>things that appear with ? at the end are return variables
<amz3>(microkanren use that char ^ instead)
<amz3>oops I changed convention in the mean time
<amz3>anyway
<amz3>what I mean, is that fs:queryo forms a declarative query of what the databae looks like
<amz3>and you can use variables in the place of the unique identifier or the value
<amz3>but not the attribute name
<amz3>(basically the attribute name must be known in advance)
<amz3>(you can't ask for all attributes in the database)
<amz3>so
<amz3>if you for instance want the unique identifier of 'paste you use (fs:queryo uid? 'kind 'paste)
<amz3>if you know the uid of a feature and you want to some of it attributes you can do
<amz3>(run* (user/name user/age) (fresh () (fs:queryo "P4X4324" 'user/name user/name) (fs:queryo "P4X432" 'user/age user/age)))
<amz3>so the use of microkanren is two side: 1) you can filter features by "pattern matching" attribute name with values, and return the matching features' unique identifiers
<amz3>2) you can retrieve a subset of the attributes of given feature
<amz3>sorry kristofer this is not documented
<amz3>kristofer: also some experience of minikanren might be helpful... see Reasoned Schemer book
<amz3>kristofer: let me know what you understand or what I did not explain well
<amz3>kristofer: also, it's possible to avoid the use of fs:queryo by using fs:find directly https://framagit.org/a-guile-mind/guile-wiredtiger/blob/master/wiredtiger/feature-space.scm#L92
<amz3>so now you know the database is made of tuples (U A V)
<amz3>and a feature is a set of UAV tuples where U is the same
<amz3>the index of the database will be built with all the (U A V) tuples by changing the order to the elements of the tuple
<amz3>(U A V) becomes (A V U) this way it's possible to quickly find out which U has (A V) as prefix
<amz3>kristofer: also, if you are experienced with SQL maybe avoiding feature-space might be easier, though there is not SQL layer yet
<amz3>kristofer: see http://hyperdev.fr/notes/somewhat-relational-database-library-using-wiredtiger.html
<atheia>hello!
<atheia>Is anyone else having issues with Guix Pull?
<atheia>"no code for module (guix profiling)"
<atheia>Oops, wrong channel :-D
<lloda>daviid: format ~y just calls truncated-print. Guile shouldn't crash anyway! :O
<kristofer>is there some emacs feature to put the copyright header in source files?
<holomorph>not in emacs, but there is legalese.el
<lloda>"Too many root sets"
<lloda>fun
<buenouanq>looking for more guile web server examples
<buenouanq>if anyone here knows of any beyond what's in the manual, please let me know
<kristofer>buenouanq: look at guix-publish, tekuti, guix-web
***do is now known as w1gz
***do is now known as w1gz
<michaelis>Hi. Is it possible to extend c with guile so that I from a c runtime can call guile functions that can manipulate variables in my c runtime?
<cmaloney>michaelis: Have you looked at https://www.gnu.org/software/guile/manual/guile.html#Programming-Overview ?
<michaelis>cmaloney, Thank you, I will look into it. I also found this short and concise information https://www.ibm.com/developerworks/library/l-guile/index.html.
<kristofer>amz3: can you show me how I might get a list of uids of kind paste from the feature-space?
<kuwze>could someone point me to a project that uses both guile and c? I am looking for something to emulate.
<jeko>kuwze, I don't know such thing
<jeko>maybe you can find some ref on Guile web-site
<kuwze>jeko: thank you
<jeko>kuwze: I wish I could have give you more insightful ideas
<jeko>in the ref you can find how to give Guile support to Dia