-
Notifications
You must be signed in to change notification settings - Fork 123
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
Rework library interface #2582
Draft
bakaq
wants to merge
21
commits into
mthom:master
Choose a base branch
from
bakaq:rework_library_interface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Rework library interface #2582
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
bakaq
force-pushed
the
rework_library_interface
branch
from
October 12, 2024 22:29
a5f87ec
to
8b57b35
Compare
As always, documentation current to the tip of this branch is available here. |
Actually, the integration tests depend on JSON serialization. Should I integrate #2493 into this PR? I think it would be a better idea to merge this first and then rebase that one onto master, because I think JSON serialization still needs a lot of discussion that is mostly disconnected to the discussion that this PR needs. |
bakaq
force-pushed
the
rework_library_interface
branch
from
October 13, 2024 19:28
8b57b35
to
463d44a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This completely reworks the library interface, moving in the direction of #2490. This already has
#![deny(missing_docs)]
, but I just did very basic documentation. This isn't intended to be a final version, and we probably want to adjust it a little1, especially in the naming. For now this is mostly about the interface and I haven't properly implemented a lot of them or even migrated the old tests yet, but I plan to do that soon. After we decide a good direction for the APIs, implement most of it and migrate the tests, we can write proper proper documentation, new tests and examples2.I have a rendered version of the
cargo doc
output from this PR here so that it's easier to review the interface. I will try to keep it updated with the tip of this branch.Some things I want to bring attention to:
PrologTerm
3 (the oldValue
) usesOrderedFloat<f64>
,Integer
andRational
, which are from theordered_float
anddashu
crates. This is a semver hazard, because we would need a breaking change every time one of those crates has a breaking change. It's specially hazardous because neither of them are1.0
yet, which tends to mean "unstable" in the Rust ecosystem. I don't think this is too bad actually, as the cadence of major versions of both of those crates seem to be very slow. I also think it wouldn't be very wise to wrap lot ofdashu
in Scryer Prolog to try to avoid this. On the other hand, I don't thinkOrderedFloat<f64>
is necessary inPrologTerm
. Usingf64
instead would mean that we loseEq
, which isn't that bad.StreamConfig
andMachineConfig
are now opaque and (kind of) use the builder pattern, which is a very common thing in the Rust ecosystem and means we can freely change the internal representation of these types (which I plan to do a lot in the future to enable some really cool stuff in Wasm).CompleteAnswer
type. I don't really see a benefit of using it instead of just collectingQueryState
into aVec<LeafAnswer>
or something like that. Please give any examples if you think of any.The following are some things I think I'm already going to do. If someone disagrees with any of them, please let me know!
Machine::new_lib()
should just be aDefault
implementation. Maybe also get rid ofMachine::new()
in favor of something likeMachineConfig::build()
to get the full benefits of the builder pattern.MachineConfig::with_toplevel()
to accept non-static strings, so that people can use a runtime generated toplevel without having to leak. This would need some deep changes probably, so I'm not sure if it's very simple to do.@mthom @Skgland @triska @lucksus I will appreciate if you take a look at this.
Footnotes
For example, I would really like if we leave space in the API for "lazy" APIs that don't need to allocate. They would be specially useful for the C API. ↩
It will also unblock ISSUE-2464: exposing scryer prolog functionality in libscryer_prolog.so for client library consumption #2465, because I think the interface will be mostly stable after that so there will not be many conflicts. ↩
I wanted to call it
Term
, but becauseTerm
already exists in the parser and we have wildcard imports everywhere there are a lot of conflicts that seem kind of complicated to fix. It seems that therebis-dev
branch gets rid of that type, so that's kind of exciting. ↩