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
    Avogadro is an advanced molecular
    editor designed for cross-platform use
    in computational chemistry, molecular
    modeling, bioinformatics, materials
    science and ...
    Download Avogadro
  • 2
    XMLTV is a set of programs to process
    TV (tvguide) listings and help manage
    your TV viewing, storing listings in an
    XML-based format. There are utilities to
    Download XMLTV
  • 3
    Strikr Free Software project. Artifacts
    released under a 'intent based'
    dual license: AGPLv3 (community) and
    CC-BY-NC-ND 4.0 international
    Download strikr
  • 5
    giflib is a library for reading and
    writing gif images. It is API and ABI
    compatible with libungif which was in
    wide use while the LZW compression
    algorithm was...
    Download GIFLIB
  • 6
    With Hugin you can assemble a mosaic of
    photographs into a complete immersive
    panorama, stitch any series of
    overlapping pictures and much more..
    Audience: Sci...
    Download Hugin
  • 7
    Alt-F provides a free and open source
    alternative firmware for the DLINK
    DNS-320/320L/321/323/325/327L and
    DNR-322L. Alt-F has Samba and NFS;
    supports ext2/3/4...
    Download Alt-F
  • More »

Linux commands