-
Notifications
You must be signed in to change notification settings - Fork 1
New work item: crate r2c2_statement
#6
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It's definitely the most important goal of our CG but sadly likely one of the trickiest to get right. We need to find a compromise between ease of use and versatility and I fear it won't be easy.
term/src/lib.rs
Outdated
//! 1. define or import simple wrapper types for building blocks | ||
//! (IRIs, language tags...) | ||
//! 2. define traits for different kinds of terms | ||
//! (Subject, Predicate, Object, GraphName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is imho going a bit too much into the "how" direction. It does not sound obvious that these should be traits and not enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll argue in favor of traits here:
What I aim is to avoid as much data transformation as possible when communicating between two implementations. That's why I try to favor lighweight wrapper types, and traits.
Imagine I want to consume some triples produced by oxttl
to canonicalize them with sohpia_c14n
. (I'll focus on subjects but of course the same would apply to predicates and objects). If Subject
was an enum, I would have to transform the subjects produced by oxttl
into that enum. And then sophia_c14n
would have to transform this enum again into its own internal representation.
If OTOH Subject
is a trait, which the types of oxttl
implement, and which sophia_c14n
accepts as input, then the data produced by oxttl
can be passed directly to sophia_c14n
, which then will transform it directly into its own internal representation. That's one transformation less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other side having an enum makes manipulation easier. I tend to think this is a compromise to be done when we know more about how we represent IRIs/blank nodes/... and should not be set in stone at the beginning of this work item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to defer this discussion, the goal was not to set anything in stone. I've just pushed a commit to clarify that the proposed design was just an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Perfect!
Agreed. I tried to not be too specific in the PR, but on the other hand, keeping things too abstract make them without substance. I don't think it would make sense to agree an a very abstract work-item if we don't have some agreement on what it will contain. But of course, we don't need to figure out all the details up-front. |
Yes! What about something in the line of "It would provide types to encode and manipulate RDF concepts like IRI, blank node, literal, term and triple", making the scope clear while leaving the
I would tend to prefer |
Re. terminology:
|
Add comment to clarify that the proposed design can be challenged.
thinking a little more about this... |
I've been giving this more thoughts, and I believe that there is a way to have the best of both words (traits and enums). More specifically, a That method enum providing everything there is to know about the subject (resp. predicate, object), any other method that the traits may provide could have a default impl based on the result of |
r2c2_term
r2c2_statement
in addition to defining the core traits and types, it proposes 2 proof-of-concept implementations, for oxrdf and rdf_types, (behind the feature gate 'poc_impl') and demonstrate interoperability between the two by testing roundtripping of both implementation via the other
Thank you so much for pushing this. Some major pain points I have with it as a starting point:
|
Absolutely agreed. The I'm happy to comment out the
I hear your point, but I still have mixed feelings about this...
Here we go :) If IRIs in R2C2 (the same reasoning applies to language tags) did not provide any guarantee of validity, it would mean that
This is not ideal, in particular because many producers will actually produce valid IRIs (hopefully!), but consumers will still need to check them every time. With the proposed design:
As you can see, the sweet spot is for implementations following Postel's law: conservative producers and lenient consumers. The burden of additional checks is taken only by the implementations who depart from Postel's law. For this to work, we need to ensure that the guarantees provided by R2C2 correspond to the MUSTs in the spec, nothing more, nothing less. That's why, for example, blank node labels are not constrained (while several implementations, including mine, constrain them to be valid SPARQL bnode labels). |
I just had a long discussion about this with @labra and an idea came up to hide all validation code behind a feature gate:
In my story above, strict producer would probably use the crate without the feature (they only need the @Tpt would that be an acceptable middle-ground for you? |
@pchampin Sorry for the answer delay. This sounds much better. However, I am still a bit scared that mixing the two features in the same crate will make versioning more painful: it is likely we will want the traits crates to be as stable as possible whereas it is more fine for implementations to see breaking changes |
that's a very valid point, thanks.
This way, we could keep the versioning of the API independant from the versioning of the validation code. |
The idea of this crate is to be the first component of the "common API".
It would focus on RDF terms, triples and quads, and would provide
Subject
,Predicate
,Object
,GraphName
)MaybeIri
,MaybeLiteral
...)Also, since triple terms will force use to define a notion of Triple, it might make sense to also define Quad in this crate, although this stretches the scope of the crate a little bit. Should we name it instead
r2c2_term_statement
, which is more accurate, but a little verbose...