Skip to content

Commit

Permalink
prepare for 0.7; generate opam files from dune-project; format dune f…
Browse files Browse the repository at this point in the history
…iles
  • Loading branch information
c-cube committed Oct 16, 2024
1 parent 08cfaf5 commit 0480969
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# 0.7

- compat with OCaml 5.2
- fix location reporting in parse errors
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ You need **OCaml >= 4.02** with [dune](https://github.com/ocaml/dune). Just type

```sh non-deterministic
$ make
$ cp src/bottom_up_cli/datalog_cli.exe ./datalog_cli
```

## How to use it
Expand All @@ -147,7 +148,7 @@ There are two ways to use `datalog`:
installed it on your system; just type in

```sh non-deterministic
$ datalog_cli <problem_file>
$ ./src/datalog_cli <problem_file>
```

- The libraries `datalog`, `datalog.top_down`, `datalog.unix`, `datalog.caml_interface`.
Expand Down Expand Up @@ -179,7 +180,7 @@ edge(7, 8).
edge(8, 9).
edge(9, 10).
edge(10, 7).
$ datalog_cli tests/clique10.pl --pattern 'same_clique(1,X)'
$ ./datalog_cli tests/clique10.pl --pattern 'same_clique(1,X)'
% start datalog
% parse file tests/clique10.pl
% process 15 clauses
Expand All @@ -198,7 +199,7 @@ $ datalog_cli tests/clique10.pl --pattern 'same_clique(1,X)'
Or

```sh
$ datalog_cli tests/graph200.pl --size --sum reachable
$ ./datalog_cli tests/graph200.pl --size --sum reachable
% start datalog
% parse file tests/graph200.pl
% process 205 clauses
Expand All @@ -212,7 +213,7 @@ $ datalog_cli tests/graph200.pl --size --sum reachable
Or

```sh
$ datalog_cli tests/graph10.pl --goal 'increasing(3,7)' --pattern 'increasing(3,X)'
$ ./datalog_cli tests/graph10.pl --goal 'increasing(3,7)' --pattern 'increasing(3,X)'
% start datalog
% parse file tests/graph10.pl
% process 15 clauses
Expand All @@ -232,7 +233,7 @@ $ datalog_cli tests/graph10.pl --goal 'increasing(3,7)' --pattern 'increasing(3,
Or

```sh
$ datalog_cli tests/small.pl --query '(X,Y) :- ancestor(X,john), father(X,Y), not mother(Y,Z)'
$ ./datalog_cli tests/small.pl --query '(X,Y) :- ancestor(X,john), father(X,Y), not mother(Y,Z)'
% start datalog
% parse file tests/small.pl
% process 12 clauses
Expand Down
45 changes: 24 additions & 21 deletions datalog.opam
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
name: "datalog"
version: "0.6"
version: "0.7"
synopsis: "An in-memory datalog implementation for OCaml"
maintainer: "simon.cruanes.2007@m4x.org"
maintainer: ["simon.cruanes.2007@m4x.org"]
authors: ["Simon Cruanes"]
homepage: "https://github.com/c-cube/datalog"
license: "BSD-2-Clause"
doc: ["https://c-cube.github.io/datalog"]
tags: [
"datalog"
"relational"
"query"
"prolog"
]
build: [
["dune" "build" "@install" "-p" name "-j" jobs]
["dune" "build" "@doc" "-p" name] {with-doc}
["dune" "runtest" "-p" name] {with-test}
]
tags: ["datalog" "relational" "query" "prolog"]
homepage: "https://github.com/c-cube/datalog"
bug-reports: "https://github.com/c-cube/datalog/issues"
depends: [
"dune"
"ocaml" { >= "4.08" }
"dune" {>= "2.0"}
"ocaml" {>= "4.08"}
"odoc" {with-doc}
"mdx" { >= "1.3" & with-test}
"mdx" {>= "1.3" & with-test}
]
dev-repo: "git://github.com/c-cube/datalog"
bug-reports: "https://github.com/c-cube/datalog/issues"
build: [
["dune" "subst"] {pinned}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/c-cube/datalog.git"
19 changes: 10 additions & 9 deletions dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

(alias
(name runtest)
(deps (:readme README.md)
(source_tree tests))
(action (progn
(run ocaml-mdx test %{readme})
(diff? %{readme} %{readme}.corrected))))

(rule
(alias runtest)
(deps
(:readme README.md)
./src/bottom_up_cli/datalog_cli.exe
(source_tree tests))
(action
(progn
(run ocaml-mdx test %{readme})
(diff? %{readme} %{readme}.corrected))))
20 changes: 19 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
(lang dune 1.0)
(lang dune 2.0)
(generate_opam_files true)

(name datalog)
(version 0.7)
(source (github c-cube/datalog))
(maintainers "simon.cruanes.2007@m4x.org")
(authors "Simon Cruanes")
(license "BSD-2-Clause")

(package
(name datalog)
(synopsis "An in-memory datalog implementation for OCaml")
(tags (datalog relational query prolog))
(depends
(dune ( >= "2.0" ))
(ocaml ( >= "4.08" ))
(odoc :with-doc)
(mdx (and ( >= "1.3" ) :with-test))))
27 changes: 15 additions & 12 deletions src/bottom_up/dune
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@

(rule
(targets version.ml)
(action
(with-stdout-to %{targets}
(echo "let version = \"%{version:datalog}\""))))
(targets version.ml)
(action
(with-stdout-to
%{targets}
(echo "let version = \"%{version:datalog}\""))))

(library
(name datalog)
(public_name datalog)
(synopsis "An in-memory datalog implementation for OCaml")
(libraries)
(flags :standard -color always -safe-string -warn-error -a+8 -w -50))
(name datalog)
(public_name datalog)
(synopsis "An in-memory datalog implementation for OCaml")
(libraries)
(flags :standard -color always -safe-string -warn-error -a+8 -w -50))

(ocamlyacc
(modules Parser))

(ocamlyacc (modules Parser))
(ocamllex (modules Lexer))
(ocamllex
(modules Lexer))
7 changes: 3 additions & 4 deletions src/bottom_up_cli/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

(executable
(name datalog_cli)
(public_name datalog_cli)
(libraries datalog))
(name datalog_cli)
(public_name datalog_cli)
(libraries datalog))
7 changes: 3 additions & 4 deletions src/caml_interface/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

(library
(name datalog_caml_interface)
(public_name datalog.caml_interface)
(libraries datalog.top_down unix))
(name datalog_caml_interface)
(public_name datalog.caml_interface)
(libraries datalog.top_down unix))
16 changes: 9 additions & 7 deletions src/top_down/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

(library
(name datalog_top_down)
(public_name datalog.top_down)
(libraries datalog)
(flags :standard -color always -safe-string -warn-error -a+8))
(name datalog_top_down)
(public_name datalog.top_down)
(libraries datalog)
(flags :standard -color always -safe-string -warn-error -a+8))

(ocamllex
(modules Lexer))

(ocamllex (modules Lexer))
(ocamlyacc (modules Parser))
(ocamlyacc
(modules Parser))
6 changes: 2 additions & 4 deletions src/top_down_cli/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

(executable
(name topDownCli)
(libraries datalog datalog.top_down datalog.unix))

(name topDownCli)
(libraries datalog datalog.top_down datalog.unix))
9 changes: 4 additions & 5 deletions src/unix/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

(library
(name datalog_unix)
(public_name datalog.unix)
(optional)
(libraries datalog.top_down unix))
(name datalog_unix)
(public_name datalog.unix)
(optional)
(libraries datalog.top_down unix))

0 comments on commit 0480969

Please sign in to comment.