HackerTrans
TopNewTrendsCommentsPastAskShowJobs

deosjr

no profile record

Submissions

Datalog in miniKanren

deosjr.github.io
134 points·by deosjr·ปีที่แล้ว·17 comments

comments

deosjr
·30 วันที่ผ่านมา·discuss
Working on my version of Dynamicland. Today I got this small thing working where I can now live-edit the behaviour of the editor script, see https://www.youtube.com/shorts/ZjxPIv-XwoU

Repo is here if anyone wants to have a look: https://github.com/deosjr/unreal-talk

And a browser-based version can be found here: https://deosjr.github.io/dynamicland/live
deosjr
·2 เดือนที่ผ่านมา·discuss
Wow that is cool, thanks for that!
deosjr
·2 เดือนที่ผ่านมา·discuss
This might be your jam. I should revisit this, most of it is unimplemented. But the parsing part was interesting, since MTG has such a codified language for explaining the rules. My idea here was to take a card's rules text from the official API and parse it into smth that can be used in the game, so you could keep up with new sets with implementation. The weird rule-breaking edge cases will always fail, but a large set of design space can fit, I think.

See https://github.com/deosjr/pmtg/blob/master/parse.pl
deosjr
·2 เดือนที่ผ่านมา·discuss
A while ago I was playing the romhack Run&Bun, which drastically ups the difficulty of Pokemon Emerald. Watching others play, most of the game was doing 'calcs': calculating how to approach a battle. This was done using a javascript frontend to a simulator, and a lot of excel sheets.

So I forked the calculator and added a Prolog wrapper so I could find solutions to battles based on the team of Pokemon that I caught. https://github.com/deosjr/runbuncalc/blob/master/main.pl

My runs died pretty early, but there are some notes here as I was implementing that are fun to read. I implemented each battle as a test case and let my solver find a solution, then amended the plan and commented on what actually happened. For example: https://github.com/deosjr/runbuncalc/blob/master/run10.pl#L2...
deosjr
·ปีที่แล้ว·discuss
Such an amazing project.

I've made a lot of progress recently working on my own homebrew version, running it in the browser in order to share it with people. Planning to take some time soon to take another stab at the real (physical) thing.

Progress so far: https://deosjr.github.io/dynamicland/
deosjr
·ปีที่แล้ว·discuss
Exploring the implementation of Dynamicland (dynamicland.org) using Guile Scheme, Hoot (scheme->wasm) and miniKanren. Main write-up can be found here: https://deosjr.github.io/dynamicland/

I cycle between learning about scheme macro hygiene and implementing more and more realtalk/dynamicland demos and trying to grok the programming model. Doing this in the browser is a weird but fun constraint that makes things shareable.

My latest project is a wikipedia explorer: https://deosjr.github.io/dynamicland/wiki.html
deosjr
·ปีที่แล้ว·discuss
I recently shared a project I did using Hoot, by Spritely institute. It's Guile Scheme compiling to WASM, and it works really well! See https://spritely.institute/hoot/

Latest on my project, in case you want to try it out: https://deosjr.github.io/dynamicland/whiskers.html
deosjr
·ปีที่แล้ว·discuss
Cheers, this is super useful. I will have to do some reading. Being able to build up n-ary predicates using triples that way makes a lot of sense.
deosjr
·ปีที่แล้ว·discuss
Thanks Dave, high praise! I was inspired after seeing you all take over the declarative & minimalist programming room at FOSDEM this year.

If you thought this was cool, wait until you see what I ended up using it for: https://deosjr.github.io/dynamicland/ I personally think this is much cooler :) But it needs some more explaining before I can broadly share, I think.

Now that I have you here, a question: am I correct in thinking that in Hoot, eval in the browser does not currently work with macros?
deosjr
·ปีที่แล้ว·discuss
I appreciate it; this kind of exchange is exactly why I read HackerNews. If you have any good sources on extending Datalog to N-ary relations, I'd love to know. Just had a look at the implementation I based mine on and it exclusively talks about triples: https://www.instantdb.com/essays/datalogjs

Coming from Prolog I'd like to get closer to the original if possible :)
deosjr
·ปีที่แล้ว·discuss
Thank you for the feedback! I agree with all of the above.

Should've probably been a bit more clear on the dl-find syntax; I find it just as unacceptable as you do. It is the result of laziness: my intended use of this minimal Datalog does not include any querying whatsoever but abuses fixpoint analysis for side-effects (see https://github.com/deosjr/deosjr.github.io/blob/master/dynam... which I intend to go over in a future post). I initially had it working like you described but butchered it for the above and haven't repaired it yet (see https://github.com/deosjr/whistle?tab=readme-ov-file#datalog). This version relied on some monstrous eval-hacking using a homebrew Lisp, which I've mostly cleaned up now in this version (https://github.com/deosjr/whistle/blob/main/datalog/datalog.... is a crime, for example).

The semantics are indeed limited to binary relations atm, which I agree is the main thing that disqualifies this as a proper Datalog. iirc the tutorial on Datalog that I based this implementation on only handled triples as well so I stopped there, but extending to N-ary relations is on my list to look into for sure.
deosjr
·ปีที่แล้ว·discuss
Guile Scheme. See https://github.com/deosjr/deosjr.github.io/blob/master/dynam... for more.
deosjr
·ปีที่แล้ว·discuss
Seems like interest in Datalog is high this week, so I thought I'd share a write-up of a minimal Datalog implementation I did a while ago.

Runs in the browser using Hoot (https://spritely.institute/hoot/) which compiles Guile Scheme to WebAssembly.
deosjr
·ปีที่แล้ว·discuss
I recently implemented a version of Bret Victor's Dynamicland in the browser using miniKanren, Datalog, and WebAssembly: https://deosjr.github.io/dynamicland/

Knowing how to implement a small logic programming language from scratch really feels like a superpower sometimes.
deosjr
·ปีที่แล้ว·discuss
A bit late, but just saw this and wanted to say I appreciate the minimalism of this a lot!