aboutsummaryrefslogtreecommitdiff

ocaml-rdf

A RDF library for OCaml

Content

ocaml-rdf consists of multiple sub-libraries that can be used individually:

  • rdf: Core RDF types and functions.

Serialization

  • rdf_json: RDF/JSON. The parser and serializer are complete and should be compliant. However there are no official test cases published.
  • rdf_xml: RDF/XML. The parser does not support XML canonicalisation. Apart from that the parser and serializer should be compliant and pass the official test cases.
  • rdf_turtle: Turtle. The parser is incomplete and can only parse a fragment of the Turtle syntax.

Testing

  • rdf_alcotest: Implements Alcotest.testable for the core RDF types. Useful when testing applications that use these types.
  • rdf_gen: Generators for QCheck. This is used within ocaml-rdf for property-based testing. It may also be useful for applications/libraries that use ocaml-rdf.
  • rdf_serd: Bindings to the Serd library for parsing Turtle and NTriples. This is only usable on systems where the Serd library is available. This is only intended for testing the parsers implemented in pure OCaml.
  • rdf_graph_isomorphism_z3: Uses the Z3 Theorem Prover to check if two graphs are isomorphic. Checking isomorpism of graphs that contain Blank Nodes is an NP-complete problem. This is only used for the serialization test cases. For real applications: don't use Blank Nodes.

Experimental

Contributing

Contributions are welcome as pull requests to the repository hosted at codeberg or via email to pukkamustard [at] posteo [dot] net.

Copyright for submitted changes remain with the author and must be published under the same license as the project source code (AGPL-3.0-or-later).

Please make sure OCaml code is formatted with ocamlformat and appropriate SPDX copyright headers have been added (use the reuse tool).

Development

You may create a suitable environment for working on ocaml-rdf with Guix:

guix shell -D -f guix.scm

This will create an environment where you can run dune build to compile the library.

Currently it is hard to get a working development environment without Guix as some OCaml dependencies are not published to OPAM yet (ocaml-cbor).

Related Software

OCaml-RDF by zoggy

There is another RDF library for OCaml developed by zoggy: OCaml-RDF (in the following referred to as zoggy/ocaml-rdf). zoggy/ocaml-rdf is older and more mature than this RDF library and provides functionalities that are not included in this library (e.g. executing SPARQL queries). We were aware of zoggy/ocaml-rdf at the time we started implementing this library. We decided to create this alternate implementations for following reasons:

  • Platform support: We needed an RDF library that works with MirageOS and js_of_ocaml. zoggy/ocaml-rdf is currently limited to Unix platforms as it uses the Crytpokit library (which includes C code).
  • Environment for experimentation: This library was also developed to facilitate experimentation for research towards content-addressable RDF (see the rdf_fragment_graph module) and novel serializations (see rdf_cbor). We believe that following design decisions, that distiguish this library from zoggy/ocaml-rdf, made such experimentation easier:
    • Functional API: This library uses the standard library Map for a functional/persistent graph data structure, whereas zoggy/ocaml-rdf uses a mutable graph. We also use a neat little trick with phantom types for making the Rdf.Triple API type-safer.
    • Multiple packages: In this library functionality is split into multiple sub-packages whereas zoggy/ocaml-rdf everyting is provided in a single package.

Acknowledgments

ocaml-rdf was initially developed for the DREAM project and has been supported trough the NGI Pointer fund.

Further work has been done for the openEngiadina project and has been supported by the NLnet Foundation trough the NGI0 Discovery Fund.

License

AGPL-3.0-or-later