Hey all! I am just posting to announce a new package I’ve been working on: OCaml bindings to SWI-Prolog (ver 8.5 or higher)!
It’s currently in the process of being submitted to OPAM, but it’s my first time writing a package with bindings to C (using ctypes), so some further changes might be needed? maybe?, but you can find the source code repository here: repo/github mirror.
As a sneak peek of what the API looks like, here’s a hello world:
(* initialise SWIProlog *) let () = Swipl.initialise () (* setup the prolog database with some facts *) let () = Swipl.load_source "hello :- writeln('hello world')." (* construct a Swipl term in OCaml *) let hello = Swipl.Syntax.(!"hello") (* send the term to the Prolog engine *) let () = Swipl.with_ctx @@ fun ctx -> Swipl.call ctx hello
I’ve taken care to provide some detailed documentation + quick start guide using odoc (see index (swipl.index)) - the quick start guide shows a step by step walkthrough on using the library to write a type inference algorithm for lambda calculus using OCaml+Prolog (no need to write your own UF).
Anyway, hope this might be useful for others - I have spent way too long racking my brains on writing dumb custom unification algorithms, but now, no more!