ppx_include

Include OCaml source files in each other
README

include is a syntax extension that allows to include an OCaml source file inside another one.

include requires OCaml 4.02 or later.

Installation

include can be installed via OPAM:

$ opam install ppx_include

Usage

In order to use include, require the package ppx_include.

Syntax

The structure item [%%include "file.ml"] or signature item [%%include "file.mli"]
is replaced with the structure or signature items inside file.ml or file.mli.
Whether the file is parsed as an interface or an implementation depends on the context
of the [%%include] node; the extension is immaterial.
The file can be located anywhere in the OCaml include path.

This can be most useful if you want to have the contents of recursive modules
in several files:

module rec A : sig [%%include "a.mli"] end = struct [%%include "a.ml"] end
and B : sig [%%include "b.mli"] end = struct [%%include "b.ml"] end

Buildsystem integration

If your buildsystem uses separate source and build trees (like ocamlbuild does),
include will not be able to find the included files. Since it is not possible
to use existing mechanisms, such as ocamldep, to provide the dependencies to
the buildsystem, it is necessary to specify dependencies manually.

ocamlbuild

For ocamlbuild, the myocamlbuild.ml file should look like this:

open Ocamlbuild_plugin

let () = dispatch (
  function
  | After_rules ->
    dep ["file:src_test/test_ppx_include.ml"]
        ["src_test/a.mli"; "src_test/b.mli"; "src_test/a.ml"; "src_test/b.ml"]
  | _ -> ())

License

include is distributed under the terms of MIT license.

Install
Published
22 Aug 2016
Sources
v1.1.tar.gz
md5=83f647db794cad43fad29bc95a23233b
Dependencies
cppo
build
ocaml
>= "4.02.0" & < "4.08.0"
Reverse Dependencies
ketrew
< "2.0.0"