[ANN] GNU Guile 1.0.0 - Bindings to GNU Guile for OCaml

Hi everyone! I am pleased to announce a brand new package for the OCaml ecosystem: Guile-ocaml

Guile-ocaml is a Free Software library that provides high-level OCaml bindings to the FFI interface for GNU Guile Scheme. The aim of these bindings are to provide an easy way for OCaml developers to extend their OCaml applications with GNU Guile scheme scripting capabilities, providing simple combinators to translate terms and send queries between the two languages.

You can find the documentation here - alongside a fairly comprehensive documentation of all the bindings, it provides a step by step guide on implementing the classical GNU Guile based turtle drawing program, except using OCaml’s graphics module.

Here’s a sneak preview from that guide of what passing an OCaml function to GNU Guile looks like using these bindings:

let move_by n =
  if not @@ Guile.Number.is_integer n then
    failwith "expected numeric arg";
  let n = Guile.Number.int_from_raw n in
  let x, y =
    let cur_pos = Graphics.current_point () in
    move n cur_pos !direction in
  if !pen_down then
    Graphics.lineto x y;
  Graphics.moveto x y;

let () = ignore @@ Guile.Functions.register_fun1 "move-by" move_by

Also, I’d like to give extra thanks to opam-repository’s tireless maintainers! The package was in limbo for a while because I couldn’t work out why conf-guile was failing to build on certain distributions, but thankfully @mseri and @kit-ty-kate were able to fix the issue!


Fantastic! This combines two of my favorite programming languages. Thank you!

Just submitted this as a package to Guix (gnu: Add ocaml-guile.). Slightly confusingly the name in Guix is ocaml-guile following the Guix naming convention for OCaml packages.

1 Like