m-ld / m-ld-js

m-ld Javascript engine
https://js.m-ld.org
MIT License
37 stars 2 forks source link

List representation in RDF/JS #172

Open gsvarovsky opened 1 year ago

gsvarovsky commented 1 year ago

Lists in m-ld, using the @list JSON-LD keyword, do not transform to RDF Collections. They are more like RDF Containers (but still, not quite 🙂). Plain RDF Collections don't converge nicely with concurrent edits – more about this in our Semantics poster. If you want to use lists we'll have to consider what to do here.

I read the semantics poster. I can adapt the system to also support the structure m-ld is using. Another idea could be to abstract lists away. Do I see it correct that I could propagate list changes in m-ld specific format, but keep them in my own dataset as a rdf list?

Originally posted by @danielbeeke in https://github.com/m-ld/m-ld-spec/discussions/117#discussioncomment-6873375

gsvarovsky commented 1 year ago

Do I see it correct that I could propagate list changes in m-ld specific format, but keep them in my own dataset as a rdf list?

It would work quite well for m-ld to represent Lists as RDF Containers (I think!).

So, this JSON-LD:

{
  "@id": "ex.shopping",
  "@list": ["bread", "milk"]
}

would look like this:

<ex:shopping>
    a      rdf:Seq, mld:List ;
    rdf:_1 "bread" ;
    rdf:_2 "milk" .

The use of the m-ld vocabulary type would cause m-ld to maintain the List's coherence. So, for example INSERT <ex:shopping> rdf:_2 "cheese" would give:

<ex:shopping>
    a      rdf:Seq, mld:List ;
    rdf:_1 "bread" ;
    rdf:_2 "cheese";
    rdf:_3 "milk" .

(Note that milk has been re-indexed.)

Similarly, deleting items and concurrent edits also always maintain the list to be a continuous sequence, with one item per position.