OnWorks favicon

camlmix - Online in the Cloud

Run camlmix in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command camlmix that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



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.


-o output
write the generated text into file output

-c Only generate the text generation program, don't execute it. By default, the
program is called lastfile.ml when lastfile is the last file argument.

-co file
specify the name of the text generation program

-fun generate OCaml code for text generation function from the input (see ADVANCED USAGE

-e ocamlc
set the name of the OCaml executable

-clean remove the text generation program after execution

-insert ocaml_code
insert ocaml_code at the beginning of the text generation program

-remix try a conversion to the camlremix syntax

print version and exit

-help | --help
print help and exit (this man page was written from the output of -help)


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:

This is ocaml version ## print Sys.ocaml_version ##

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:

This is ocaml version ##= Sys.ocaml_version ##

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 .##:

##. don't print white space occurring on the left

.## don't print white space up to and including the first newline, following to the


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

Hello ## @include "world.mlx"; skip .## ## let x = 123 ##!

Conversion into a text generation function for dynamic rendering
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:

val render : ?print:(string -> unit) -> 'a -> unit

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:

fun s -> print_string s; flush stdout

Runtime hooks
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.

module Camlmix : sig

val source : string ref

val line : int ref

val char : int ref
Location of the first character of the current block in its source file.
Line and character numbers count from 1. These references are updated by
camlmix at the beginning of each block.

val printer : (string -> unit) ref
function for printing text blocks

val print_with : (string -> unit) -> unit
print_with f causes the next text block to be printed with f instead of the
current printer. Its behavior is undefined if it is called several times in
the same code block.

val print_if : bool -> unit
print_if cond prints the next text block only if condition cond is true. It
uses print_with internally.


Use camlmix online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    VirtualGL redirects 3D commands from a
    Unix/Linux OpenGL application onto a
    server-side GPU and converts the
    rendered 3D images into a video stream
    with which ...
    Download VirtualGL
  • 2
    Library to enable user space
    application programs to communicate with
    USB devices. Audience: Developers, End
    Users/Desktop. Programming Language: C.
    Download libusb
  • 3
    SWIG is a software development tool
    that connects programs written in C and
    C++ with a variety of high-level
    programming languages. SWIG is used with
    Download SWIG
  • 4
    WooCommerce Nextjs React Theme
    WooCommerce Nextjs React Theme
    React WooCommerce theme, built with
    Next JS, Webpack, Babel, Node, and
    Express, using GraphQL and Apollo
    Client. WooCommerce Store in React(
    contains: Products...
    Download WooCommerce Nextjs React Theme
  • 5
    Package repo for ArchLabs This is an
    application that can also be fetched
    It has been hosted in OnWorks in...
    Download archlabs_repo
  • 6
    Zephyr Project
    Zephyr Project
    The Zephyr Project is a new generation
    real-time operating system (RTOS) that
    supports multiple hardware
    architectures. It is based on a
    small-footprint kernel...
    Download Zephyr Project
  • More »

Linux commands