chris613
2020-1-10 16:03:48

if i have a file using #lang racklog can i require that into a #lang racket file and “use” it somehow ??


chris613
2020-1-10 16:04:27

sort of define all the data and relations in racklog, then execute quireies from racket ?


soegaard2
2020-1-10 16:05:01

In general it depends on the language. If racklog exports bindings you can import them using require as usual.


chris613
2020-1-10 16:05:11

best way to find that out ?


chris613
2020-1-10 16:05:15

just try it ?


soegaard2
2020-1-10 16:05:33

Try it - but also study the docs of racklog.


chris613
2020-1-10 16:06:45

okies, well it “worked” in that it didnt blow up and it ouput to the console the output of my existing query, no idea what new functions its introduced though, can i name the import/require and inspect it ?


soegaard2
2020-1-10 16:08:36

You can use (require (only-in racklog a b c)to import only a, b and c. You can also use(require (rename-in racklog [old new])` to rename an import in the importing module.


chris613
2020-1-10 16:09:31

so there isnt an easy way to inspect what (require "data.logic.rkt") provided ?


soegaard2
2020-1-10 16:10:39

Yes, you can use module->all-exported-names


soegaard2
2020-1-10 16:11:07

Actually, module->exports is probably better.


chris613
2020-1-10 16:11:10

brill thanks :smile:


chris613
2020-1-10 16:11:46

okies. it exports bugger all lol :wink:


chris613
2020-1-10 16:12:01

(module->exports "data.logic.rkt") '((0 (ingredient ()) (name ()) (recipe ()))) '() >


soegaard2
2020-1-10 16:12:47

You can get the racklog primitives from the racklog module.


chris613
2020-1-10 16:13:03

yeah i think i just came to an understanding …


chris613
2020-1-10 16:13:15

that importing this sort of loaded up a global logic DB


chris613
2020-1-10 16:13:31

so the racklog module functions should work on these facts now …


soegaard2
2020-1-10 16:14:26

The docs doesn’t say much on #lang racklog


chris613
2020-1-10 16:14:36

no … its a shame …


chris613
2020-1-10 16:15:24

im playing about with a recipe store / meal planner and id like to try and do some clever “automation” so storing all the info in a logic DB seemed like it might be a sensible aproach.


chris613
2020-1-10 16:15:55

i also dont know if it would be possible to perist that DB again if i were to manipulate it after it was loaded though


soegaard2
2020-1-10 16:17:33

Good question. There is got to be a solution for that.


soegaard2
2020-1-10 16:18:01

I found the piece of code, that produces the exports of a module written in #lang racklog.


soegaard2
2020-1-10 16:18:15

<https://github.com/racket/racklog/blob/master/lang/compiler.rkt#L16>


soegaard2
2020-1-10 16:18:50

Your conclusion is spot on. All assertations are provided.


chris613
2020-1-10 16:25:26

thanks :slightly_smiling_face: i notice your around a lot helping out, i (and i assume others) really do appreciate it :smile:


soegaard2
2020-1-10 16:42:06

Thanks!