Previous week Up Next week


Here is the latest Caml Weekly News, for the week of December 19 to 26, 2006.

  1. Ocsigen 0.5.1 (Web server in OCaml)
  2. Memcheck: runtime type checking
  3. Functional Reactive GUI for O'Caml
  4. Scripting in ocaml
  5. libsndfile-ocaml alpha
  6. Job Announcement

Ocsigen 0.5.1 (Web server in OCaml)


Vincent Balat announced:
The Ocsigen Web server is now available for download in version 0.5.1. 

See for details, downloading and documentation. 

Ocsigen is a Web server, with a programming framework providing a new way to 
create dynamic Web sites using Objective Caml. Its goal is to offer an 
alternative to Apache/PHP, based on cutting-edge technologies coming from 
research in programming languages. 

It allows to program in a concise and modular way, using OCaml's type system 
in a thoroughgoing way in order to produce valid xhtml. The server handles 
sessions, URLs, and page parameters automatically. Pages are generated by 
OCaml functions (services) and you can dynamically create new services 
dedicated to a user of the Web site (continuation based Web programming). 

The Web server is now full featured to handle static and dynamic pages. It 
supports HTTP, HTTPS, pipelining of requests, multipart forms, virtual hosts, 
etc. It is implemented using cooperative threads, making it very lightweight 
and providing a very convenient and safe style of programming (no need for 

Ocsigen is now fully usable and (hopefully) stable. Some features will be 
added before version 1 (in a few months). Next version (0.6.0) will allow the 
creation of extensions for the Web server (like Apache modules). 

A debian package is available (unstable branch). Contribution would be 
appreciated for a Godi package.

Memcheck: runtime type checking


Hendrik Tews announced:
it is my pleasure to announce 

           Memcheck, a module for runtime type checking in Ocaml 

Memcheck is very similar to SafeUnmarshal[1] but without a few of 
SafeUnmarshal's limitations. In particular, with Memcheck it only 
takes seconds to check a few megabytes instead of hours as with 

For download / more info go to 

License: GPL 


Hendrik Tews 


Functional Reactive GUI for O'Caml


Chris King said:
(Cross-posted from Lambda the Ultimate at the advice of Yaron Minsky...) 
Hi all, 

I've been working for the past few months on a functional reactive GUI 
system for O'Caml called "O'Caml Reactive Toolkit", "functional 
reactive" meaning that functional expressions can be built whose 
values change over time in response to user input without relying on 
imperative constructs (much like dataflow or visual programming 
languages).  For those familiar with extant FR systems, the core FR 
logic is based heavily on Haskell's Yampa, while the FR API is modeled 
after PLT Scheme's FrTime, so there is not much new there. The novelty 
is in the GUI API, which, although layered on lablgtk2, constructs a 
GUI via functions rather than objects and exposes no mutable state: 
response to user input is modeled using functional reactive 
constructs.  As an example, here is a toy temperature conversion 

open Fr 
open FrGui 

let float_view f = text_view (lift (string_of_float @f)) 

let _ = 
    let temp_box, temp = spin_box 20. in 
    let fahrenheit = lift ((@temp -. 32.) *. 1.8) 
    and celsuis = lift (@temp /. 1.8 +. 32.) in 
    let main_window = window 
        ~title: "Temperature converter" 
        (hbox [ 
            hbox [label "Convert "; temp_box; label " to:"]; 
            vbox [ 
                hbox [label "degrees Fahrenheit: "; float_view fahrenheit]; 
                hbox [label "degrees Celsius: "; float_view celsius]]]) in 
    run_dialog (main_window, main_window#close) 

The temperature entered by the user is instantly converted to both 
degrees Fahrenheit and degrees Celsius.  The "lift" construct is a 
camlp4 syntax extension which provides a way to create functional 
reactive expressions: inside it, "@val" refers to a value which 
changes with time (a "behavior"). 

Though O'Caml RT is far from complete I made a prerelease because I 
want to solicit feedback from others who are interested in functional 
reactive programming and in creating a portable GUI API for O'Caml. I 
made a web page[1] providing links to the source code, documentation 
(on both functional reactive programming and FrGui), and (coming soon) 
examples. It's known to compile both to bytecode and native code on 
Mac OS X and Linux (feedback from Windows users would be greatly 
appreciated!), and it should be possible already to write many simple 
GUI applications using it. 

My questions to you are: 

    * Am I duplicating work? I know of functional reactive GUI systems 
such as Fudgets, SuperGlue, and Flapjax for other languages but I know 
of no such system for O'Caml. 
    * What would you want to see in a functional-reactive GUI toolkit? 
i.e. what things which are often awkward to express in procedural 
langauges do you think should be made easy in O'Caml RT? 
    * What are some examples of things which are easy in procedural 
languages but you think would be awkward in a functional-reactive 
    * Is the API clear and understandable? e.g. does the above example 
make sense, even to those not familiar with functional reactive 

Thanks in advance for your feedback! 

Virgile Prevosto answered:
>     * Am I duplicating work? I know of functional reactive GUI systems 
> such as Fudgets, SuperGlue, and Flapjax for other languages but I know 
> of no such system for O'Caml. 

You might be interested by Reactive ML: 
This is a whole language (based on Ocaml), not a library, though.
Gabriel Kerneis asked and Chris King answered:
> It might have been clearer if I had read a quick tutorial or how-to 
> before. But your question targeted newbies, so let me give you a 
> total newbie's answer : I just can't get it ;-) 

You have a very good point :) nothing's intuitive unless it's 
familiar, which I admit the syntax (especially lift) is not.  I intend 
to post some examples as well as a tutorial in the next few weeks, but 
for the time being here is a quick breakdown of the above example 
(with a few math fixes :P): 
> open Fr 
> open FrGui 

Fr is the library containing funcitons to create functional reactive 
expressions; FrGui contains definitions of all the GUI widgets. 
> let float_view f = text_view (lift (string_of_float @f)) 

This one-liner defines the float_view widget in terms of the text_view 
widget.  Ignoring the definition (which should make more sense later), 
it's simply a function which creates a widget which displays the 
time-varying floating-point value f. 
> let _ = 
>   let temp_box, temp = spin_box 20. in 

spin_box is a function which creates a widget (temp_box) which allows 
the user to input a floating-point value (in this case, the 
temperature we want to convert).  Here 20 is given as its initial 
value.  The current value of temp_box is stored in temp.  This value 
can change with time and is called a "behavior" (and has the type 
float behavior). 
>    let fahrenheit = lift (@temp *. 1.8 +. 32.) 

Because temp is not a float but a float behavior, we must use a 
special construct to access it.  lift (expr) allows us to access 
values contained in behaviors and to create new ones.  Inside of expr 
(which is otherwise a normal O'Caml expression), we can use the form 
@expr to reference a behavior (think of this like dereferencing a 
pointer in C). Here, fahrenheit is a behavior which is always equal to 
the value of (temp *. 1.8 +. 32.).  Whenever temp changes, so does 
>    and celsuis = lift ((@temp -. 32.) /. 1.8) in 

Here, we similarly define celsius as a float behavior which is 
dependent on the current value of temp. 
>    let main_window = window 
>        ~title: "Temperature converter" 
>        (hbox [ 
>            hbox [label "Convert "; temp_box; label " to:"]; 
>            vbox [ 
>                hbox [label "degrees Fahrenheit: "; float_view fahrenheit]; 
>                hbox [label "degrees Celsius: "; float_view celsius]]]) in 

Here we define the main window.  hbox, vbox, and label are all 
functions which create widgets.  hbox and vbox pack lists of widgets 
horizontally and vertically, and label creates a text label.  temp_box 
is the widget instance we defined above, which allows the user to 
enter the value of temp.  We also create two instances of the 
float_view widget, to display the values of fahrenheit and celsius. 
>    run_dialog (main_window, main_window#close) 

This incantation displays main_window and enters the GUI's main loop 
until the window's close button is clicked. 
The end result is a window with a spin box into which the user can 
input a temperature.  That temperature is instantly converted into 
both Fahrenheit and Celsius and displayed in two other text boxes (the 
float_views) in the window. 

Hopefully this description helped more than it confused... if it did 
more of the latter then I'll try to post a proper tutorial on the 
O'Caml RT website as soon as possible, since one is in order anyway. 
Thanks for you input :)
Louis Mandel said:
A source distribution of ReactiveML will be available soon. 
You may also have a look to Lucid Synchrone which is closer 
to the functional reactive programming model.

Scripting in ocaml


A huge thread spanning scripting, strict typing, and runtime information was started when Denis Bueno asked (most of the messages may be read at the archive link):
I've been writing bash scripts to perform various build- and 
development-related tasks, and I don't enjoy it. I won't bore you with 
detailed reasons why. The upshot is that I'd like to script in OCaml. 
I have considered writing a few camlp4 extensions to make it easier to 
write scripts: 

  1) create a syntax which grabs environment variables: 

    e.g. $FOO would grab the value of the environment variable FOO 

  2) some sort of more convenient process interaction, e.g., for piping. 

(1) seems pretty straightforward, though I haven't found the time to 
implement it yet. (2) is not as clear to me, but I'll think about it 
and probably look at scsh. 

I googled a bit but couldn't find anything related to this. Has 
anything done, or started doing, anything like this? 		
Till Varoquaux suggested:
You might want to have a look at cash: 
It aims at being an ocaml equivalent of scsh. I don't know if it is 
still maintained. 
chamo (one of cameleon's [] component) 
is also ocaml scriptable. They included an enhanced toplevel. You 
could reuse part of there work .

libsndfile-ocaml alpha


Erik de Castro Lopo announced:
I'd like to announce the first pre-alpha release of libsndfile-ocaml 
which is available here: 

The ocamldoc generated docs are here: 

At this stage, basic reading from and writing to a file works. 
Once I have received some feedback on what I have so far, I 
intend to complete wrapping of the rest of the libsndfile API 
on an as-needed basis. 

Feedback please :-).

Job Announcement


Yaron Minsky announced:
I'm pleased to announce that Jane Street Capital is yet again looking 
to hire some top-notch functional programmers.  Of particular note is 
that Jane Street Europe Ltd. now has an office in London, and we are 
particularly interested in hiring someone for that office with strong 
systems administration skills in addition to experience with 
functional programming languages. 
You can find out more about Jane Street here: 

I should also warn people that I will have spotty email access for the 
next couple of weeks, so it will take me some extra time to get back 
to people. 

Here's the full job announcement. 


Jane Street Capital is a proprietary trading firm that operates around 
the clock and around the world. We bring a deep understanding of 
trading, a scientific approach, and innovative technology to bear on 
the problem of trading profitably on the world's highly-competitive 
financial markets. We run a small, nimble operation where technology 
and trading are tightly integrated. 

At Jane Street, there is room to get deeply involved in a number of 
areas at the same time. We are actively looking for people interested 
in software development, system administration, and quantitative 
research--potentially all on the same day. 

We have offices in the New York, London and Tokyo.  Most of our hiring 
is for the New York office, but we are looking for applicants in our 
foreign offices as well.  In some circumstances we have hired foreign 
applicants for the US office through the H1-B and the F1 visa 
programs. In such cases, we support and fund the visa application 

We are looking for talented candidates across the range.  We are also 
particularly interested in finding someone with skills and interest in 
systems administration for Jane Street Europe Ltd.'s London office. 

The ideal candidate has: 

    * A commitment to the practical. One of the big attractions of our 
      work is the opportunity to apply serious ideas to real-world 
    * Experience with functional programming languages (OCaml, SML, 
      Scheme, Haskell, Lisp, F#, Erlang, etc) is important. Applicants 
      should also have experience with UNIX and a deep understanding 
      of computers and technology. 
    * A strong mathematical background. This is a must for candidates 
      interested in research, and includes a good understanding of 
      probability and statistics, calculus, algorithms, etc. We draw 
      on ideas from everywhere we can, so we value interest and 
      experience in a range of scientific fields. 
    * Good second-order knowledge. In trading, understanding the 
      boundary between what you do and don't know is as (or more) 
      important than how much you know. 

The environment at Jane Street is open, informal, intellectual, and 
fun. You can wear a t-shirt and jeans to the office, the kitchen is 
stocked, and discussions are always lively. We encourage a focus on 
learning, both through formal seminars and classes, as well as through 
day-to-day conversations with colleagues.  Other perks include 
competitive salaries, rapid advancement for people who do well, 
excellent benefits, free lunch, and a gym on-site. 

We are currently looking for full-time positions as well as summer 
interns (internship positions are only avaliable in the US office, and 
for people who already have the right to work in the USa). If you are 
interested, send an application to Yaron Minsky 
( including a resume, cover letter, and 
optionally some sample code you've written. 

If you'd like to know a little bit more about how we came to use OCaml 
as our primary development language, take a look at these slides from 
a talk we gave at CUFP 2006:

Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1

If you know of a better way, please let me know.

Old cwn

If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe online.

Alan Schmitt