Open taybenlor opened 2 years ago
Let me know if there's anything I can do to help! I'll take a look at what QuickJS is doing about terminal input and see if I can fix it on my end.
Thanks heaps! For the way Runno currently works I don't think any changes will be necessary. It doesn't currently use my new WASI runtime (though I'd like it to!)
@guregu It seems to run locally!
I'm having difficulty understanding how things piece together in prolog programs.
How would you expect a program to run in Runno?
I've been reading "Learn Prolog Now" and it seems to separate knowledge bases from queries. It seems like maybe I should run the file, and then open the interpreter? But when I run their code examples they don't work.
Do you have a good resource to learn Prolog that will run in Trealla?
@taybenlor Nice!
For resources, I'd recommend The Power of Prolog by @triska. He recently uploaded a very detailed video about how Prolog toplevels (REPLs) here: https://www.youtube.com/watch?v=op17-dlcSRQ. Power of Prolog targets Scryer Prolog, but Trealla Prolog is mostly compatible with it so it should generally work.
I think it could work with the same layout and a small tweak. Instead of sending the code input to the stdin, you can "consult" (Prolog term for loading a file) the input and then provide the user with the prompt as normal to write queries themselves. Maybe even provide an extra input box for the query and the program code to allow for the user to specify a query they want to run.
If you can use a virtual file system, you could for example write input.pl
and then run tpl
as such: tpl input.pl -g user_query_goes_here
. You can also have it read from stdin with --consult
although I've found that to be finnicky depending on the WASI implementation.
Let me know if that helps! There are some other ways to approach this too, so we should be able to find a way to get it working nicely. Also, if something seems broken it might be a bug in my WASI implementation so feel free to reach out!
There are a few online REPLs that might provide some inspiration:
See work here: https://github.com/guregu/trealla-js
Looks like this should actually be pretty doable. Trealla supports WASI as a target (https://github.com/trealla-prolog/trealla) and is already on WAPM (https://wapm.io/guregu/trealla).