A Datalog implementation with an OCaml inspired module system
OCaml
44
243 commits
updated Apr 24, 2026
This is an implementation of Datalog with an OCaml like module system, including module signatures and higher order modules via functors. The addition of a module system endows Datalog with two previously missing features: code reuse and type abstraction. Modulog was motivated by previous attempts to use the C preprocessor or other text munging to do hacky code reuse in Datalog for points to analysis.
At the moment Modulog has the following features:
Example:
module type Edges = sig
type vertex
pred edge : vertex * vertex
end
module MyEdges = struct
type vertex = int
define edge : vertex * vertex
edge(1, 2)
edge(2, 3)
edge(3, 4)
edge(4, 1)
end
module Path (E : Edges) = struct
type vertex = E.vertex
define path : E.vertex * E.vertex
path(?X,?Y) :- E.edge(?X,?Y)
path(?X,?Z) :- path(?X,?Y), E.edge(?Y,?Z)
end
module P = Path (MyEdges)
Still to do:
A calculus for the construction of modular prolog programs by Donald T. Sannella and Lincoln A. Wallen, J. Logic Programming, vol 12, issues 1-2, January 1992, pages 147-177.
QL: Object-oriented Queries on Relational Data by Pavel Avgustinov, Oege de Moor, Michael Peyton Jones, and Max Schäfer, ECOOP 2016: 2:1-2:25. DOI: 10.4230/LIPIcs.ECOOP.2016.2
243 commits
OCaml
92.6%
C
5.2%
Nix
1.6%
A Datalog implementation with an OCaml inspired module system
OCaml
44
243 commits
updated Apr 24, 2026
This is an implementation of Datalog with an OCaml like module system, including module signatures and higher order modules via functors. The addition of a module system endows Datalog with two previously missing features: code reuse and type abstraction. Modulog was motivated by previous attempts to use the C preprocessor or other text munging to do hacky code reuse in Datalog for points to analysis.
At the moment Modulog has the following features:
Example:
module type Edges = sig
type vertex
pred edge : vertex * vertex
end
module MyEdges = struct
type vertex = int
define edge : vertex * vertex
edge(1, 2)
edge(2, 3)
edge(3, 4)
edge(4, 1)
end
module Path (E : Edges) = struct
type vertex = E.vertex
define path : E.vertex * E.vertex
path(?X,?Y) :- E.edge(?X,?Y)
path(?X,?Z) :- path(?X,?Y), E.edge(?Y,?Z)
end
module P = Path (MyEdges)
Still to do:
A calculus for the construction of modular prolog programs by Donald T. Sannella and Lincoln A. Wallen, J. Logic Programming, vol 12, issues 1-2, January 1992, pages 147-177.
QL: Object-oriented Queries on Relational Data by Pavel Avgustinov, Oege de Moor, Michael Peyton Jones, and Max Schäfer, ECOOP 2016: 2:1-2:25. DOI: 10.4230/LIPIcs.ECOOP.2016.2
243 commits
OCaml
92.6%
C
5.2%
Nix
1.6%