scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Documentation for using Scryer as a Rust dependency

Open constraintAutomaton opened this issue 9 months ago • 5 comments

I'm working on a project written in Rust and would like to use Scryer as a dependency. However, I couldn't find any documentation or guidance on how to integrate it into a Rust project and the crate documentation is pretty bare bone. Is it because it is bad idea to do so or it is not intended?

constraintAutomaton avatar Apr 13 '25 06:04 constraintAutomaton

I think there is an example in https://github.com/mthom/scryer-prolog/tree/master/src/machine/lib_machine, does it help?

triska avatar Apr 13 '25 06:04 triska

There are some things that just don't work at all (see the problems found by @guregu in #2825) and it's definitely not as performant or flexible as it could be, but it is already good enough for many cases and the interface probably won't change much until the stable release. As for examples, the tests linked above are indeed the best we have right now.

If you do end up using it, feedback would be very appreciated.

bakaq avatar Apr 13 '25 07:04 bakaq

Ah, I believe you are already aware, but notice that the crates.io (and therefore docs.rs) package is still 0.9.4, which is very outdated and doesn't have the new Rust embedding interface or really any documentation at all. If you run cargo doc --open in the current master you should have some pretty bare bones but complete API documentation.

bakaq avatar Apr 13 '25 07:04 bakaq

All this help thank you! I did not realize the version of the crate... I guess the best is to link it with the master branch of the repo instead of crate.io at the moment.

constraintAutomaton avatar Apr 13 '25 07:04 constraintAutomaton

The fact that the improved API is not yet in a published version is probably the biggest downside of being an early adopter, though for most cases you could just use a git dependency or vendor it and use a path dependency. If for some reason you really can't use a git or path dependency (if you need to publish your thing to crates.io for example), the Scryer license allows you to just publish the current master yourself and then depend on that. Scryer itself used this trick a few times in the past to get crucial bug fixes in dependencies that weren't published at the time. You could then switch to the official crate when it finally comes out.

bakaq avatar Apr 13 '25 07:04 bakaq