Signatures Last updated May 5, 2022

A signature expressed as a file is traditionally called an "interface" file. The filename conventionally has a ".mli" extension, but this is not required. The standard compilers support options that allow the programmer to designate a different extension for interface files.

OBazl calls such files signature files, or sigfiles for short.

There are two ways to compile a sigfile. One is to pass the sigfile as a direct dependency of an ocaml_module target, using the sig attribute:

module_binding/proper/sigsrcdep
├── BUILD.bazel
├── hello.ml
├── hello.mli
module_binding/proper/sigsrcdep/BUILD.bazel
ocaml_module(name = "Hello", struct = "hello.ml", sig = "hello.mli")

The other way is to compile the signature separately, using the ocaml_signature rule:

ocaml_signature(name = "Hello_cmi", src = "hello.mli")
ocaml_module(name = "Hello", struct = "hello.ml", sig = ":Hello_cmi")