I have been working on a package to handle RDF data in Elm for a while now, and finally found time to write some documentation and publish it: hereon-mb/elm-rdf.
RDF (Resource Description Framework) is framework for encoding arbitrary data in graph form. It comes with a variety of serialization formats (for example Turtle or JSON-LD) and a query language (SPARQL), and there exist some databases (sometimes called triple stores) which support these standards. I think, the RDF Primer gives a good overview about what RDF is and why it’s useful. Other interesting standards in the ecosystem are SHACL, a language for writing validation schemes, and OWL, a language for defining semantic frameworks.
The Elm package contains a parser and a serializer for the Turtle and N-Triples formats, and offers a decoding/encoding API similar to elm/json for extracting/creating RDF data within Elm. We are using it ourselves within the electronic lab notebook/research database we are developing. (Herbie, if you are curious.)
Herbie looks really interesting, and I want to play with it.
That took me down a deep rabbit hole and along the way HIFIS grabbed my attention. It reminds me of a more polished/high-level/full-featured equivalent of Jetstream2 (which I work on) or NRP. I’ve suggested that we implement something like HIFIS at Jetstream2, and it’s great to see an example in the wild.
Good to know you are working in this area. I’m also building elm libraries for RDF, SPARQL and SHACL. The approach I am using is to work with the JS libraries for RDF and SPARQL.
I’m always happy to hear about more people using Elm and RDF together.
I like your approach of using the existing JS implementations and aligning with the RDF/JS data model. There actually is a JSON decoder in elm-rdf (Rdf.Graph.decoder) which decodes a list of Quads. It ignores the graph attribute though as there is no support for datasets in the package yet. So, I would say, there already is also some alignment here, but definitely room for improvement. Just as an example, having something which decodes SPARQL/JSON results would be great.
In the beginning I actually also used N3.js, but then needed something which I can also use in elm-test, which was one reason to write the Turtle parser actually. I never did any rigorous performance measurements, but I wouldn’t be surprised if the graph parsing is much faster with N3.js.
Looking at your types, I think the main difference is that in elm-rdf the Rdf.Term type is opaque, and extracting Elm values is done via elm/json-like decoding. So I’m curious how this modelling affects your application code.
I would be very happy to discuss all of this further! Also I would be very interested in the work you did on SHACL. Right now, I have some ad hoc implementations in our application to work with it. But it does not cover the whole specification and contains some extensions which are only relevant in our setting. I think it would be good, to have a package which gives you exactly what https://www.w3.org/TR/shacl/ defines.