Skip to content

Commit

Permalink
Tidy up datalog library a little
Browse files Browse the repository at this point in the history
  • Loading branch information
bobatkey committed Aug 21, 2017
1 parent 9635edb commit 675491d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
8 changes: 8 additions & 0 deletions datalog.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
opam-version: "1.2"
name: "datalog"
version: "0.3"
maintainer: "Robert Atkey <[email protected]>"
authors: "Robert Atkey <[email protected]>"
license: "MIT"
build: [["jbuilder" "build" "-p" name "-j" jobs "@install"]]
available: [ ocaml-version >= "4.04.0" ]
1 change: 1 addition & 0 deletions datalog/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

(library
((name datalog)
(public_name datalog)
(libraries (ocamlgraph fmt))))
14 changes: 5 additions & 9 deletions datalog/ruleset.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,11 @@ module Builder = struct
| [] ->
Ok ()
| Atom {pred;args} :: atoms ->
(* match PredicateNameMap.find pred pred_info with
| exception Not_found ->
Error (Undeclared_predicate pred)
| {arity} ->*)
let used_arity = List.length args in
if pred.arity <> used_arity then
Error (Arity_mismatch { pred; used_arity })
else
check_atoms pred_info atoms
let used_arity = List.length args in
if pred.arity <> used_arity then
Error (Arity_mismatch { pred; used_arity })
else
check_atoms pred_info atoms

let add_rule ({pred;args;rhs} as rule) t =
match check_atoms t.predicates_so_far rhs with
Expand Down
2 changes: 2 additions & 0 deletions datalog/ruleset.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(** Datalog programs as sets of rulesets. *)

type predicate_name =
{ ident : string
; arity : int
Expand Down

0 comments on commit 675491d

Please sign in to comment.