An OCaml 5 rewrite of DataScript, focused on matching the behavior of the ClojureScript implementation while providing a native OCaml API and js_of_ocaml build support.
This project is still under active development. Compatibility with upstream DataScript is verified through OCaml tests and cross-runtime parity checks against the ClojureScript implementation.
- Preserve DataScript semantics for transactions, datoms, indexes, entities, pull, and query.
- Keep public APIs close enough to upstream behavior that Logseq can share the same data model assumptions.
- Support native OCaml and js_of_ocaml runtimes.
- Prefer clear OCaml implementations over shortcuts that change observable behavior.
Requirements:
- OCaml 5.2.1 or newer
- Dune 3.17 or newer
- Node.js for js_of_ocaml smoke tests and cross-runtime checks
Common commands:
dune build
dune runtestCross-runtime parity checks compare this implementation with the upstream ClojureScript DataScript behavior:
git clone https://github.com/logseq/datascript.git _deps/datascript
cd _deps/datascript && lein with-profile test cljsbuild once release && cd -
dune build test/cross_runtime_ocaml.exe
bash test/cross_runtime_parity_test.sh _build/default/test/cross_runtime_ocaml.exe script/cross_runtime_upstream.jsBy default, the parity script expects an upstream DataScript checkout at
_deps/datascript. Set UPSTREAM_DATASCRIPT_REPO or UPSTREAM_DATASCRIPT_JS
to use a different checkout or compiled JS bundle.
type/: shared public type definitionsimpl/: implementation modulestest/: unit, integration, js_of_ocaml, and cross-runtime testsexamples/: small executable examplesbench/: benchmark entry pointsscript/: parity and benchmark helper scripts
This project is a port of DataScript's ideas and behavior to OCaml.
Primary credit goes to the upstream DataScript ClojureScript project:
The OCaml implementation is written independently, but upstream DataScript remains the semantic reference for compatibility work.