CAMLMIX(1) | User Manuals | CAMLMIX(1) |
camlmix - preprocessor which converts text with embedded OCaml
camlmix [Options...] files...
camlmix processes text templates with embedded OCaml code to generate text again. From one or several input files it generates an OCaml text generation program and executes this to obtain the result. Using option -fun one can also convert the text template into an OCaml text generation function.
Text enclosed with ## markers is considered as a block of OCaml code. It can be any kind of toplevel expressions such as definitions or application of printing functions:
If the OCaml code starts with = then it is interpreted as an expression of type string that will printed like the rest of the text:
The text block are printed together with the evaluated OCaml pieces using the print function. Include ### to print ##.
White space can be controlled with ##. and .##:
Blocks of code that start with the @ character (possibly preceded by spaces) are directives for Camlmix. There are two directives. include inserts a camlmix file, and skip skips the next block. For instance
The -fun option, used in combination with -c and often -co produces an OCaml source file which provides a function render with the following signature:
The polymorphic argument is called param in the generated code and can be used to pass runtime arguments into the render function. The print function is used to set the initial value of Camlmix.printer (see below). It's default value is:
The text generation program, which camlmix generates, contains a module Camlmix at the beginning, which can be used in code blocks. This module has the following signature.
end
This manual page was written by Sylvain Le Gall <gildor@debian.org> and Hendrik Tews <hendrik@askra.de>, specifically for the Debian project (and may be used by others).
May 2013 | CAMLMIX |