Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate adding support for Prolog #211

Open
taybenlor opened this issue Oct 10, 2022 · 4 comments
Open

Investigate adding support for Prolog #211

taybenlor opened this issue Oct 10, 2022 · 4 comments
Labels
new language Adds a new language to Runno

Comments

@taybenlor
Copy link
Owner

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).

@taybenlor taybenlor added the new language Adds a new language to Runno label Oct 10, 2022
@guregu
Copy link

guregu commented Oct 10, 2022

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.

@taybenlor
Copy link
Owner Author

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!)

@taybenlor
Copy link
Owner Author

@guregu It seems to run locally!

Screen Shot 2022-12-03 at 1 57 40 pm

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?

@guregu
Copy link

guregu commented Dec 4, 2022

@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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new language Adds a new language to Runno
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants