OCaml System

From the OCaml Labs wiki
Jump to: navigation, search

At OCaml Labs we are working on maintaining and extending the core OCaml compiler toolchain and runtime. This consists of a variety of day-to-day tasks such as submitting bug fixes, and also longer-term improvements to the type system and runtime libraries.

We are actively engaging with the wider OCaml community to ensure that any improvements and modifications we propose are thoroughly discussed, well-formulated and maintainable.

Current and Ongoing Projects[edit]


Paper: Modular Macros

Macros provide an OCaml language extension for type-safe compile-time code generation.


GitHub | Paper: Multicore OCaml

The goal of Multicore OCaml is to add shared memory parallelism to OCaml. Our implementation uses algebraic effects to compose concurrency and supports parallelism through domains and incremental GC. Rather than adding a specific multicore scheduler into the runtime system, we're providing the minimum required toolset in the form of pluggable schedulers.

OCaml AFL[edit]

GitHub | Blog

AFL is a security-oriented fuzzer that uses compiler instrumentation to discover crashes in software programs. ocamlopt-afl allows us to fuzz OCaml programs.

Modular Implicits[edit]

GitHub | Demo

Taking inspiration from Scala's implicits and Modular Type Classes, we propose a system for ad-hoc polymorphism in OCaml based on using modules as type-directed implicit parameters. You can try out an interactive REPL of a prototype implementation online.



The PPX system has been introduced for authors of syntactic tools.

Previous and Completed Projects[edit]

Emission of DWARF debugging information[edit]


This project aims to equip the native-code OCaml compiler and the GNU debugger with the necessary infrastructure to improve debugging of OCaml programs. The compiler will be enhanced to emit the standard DWARF debugging information format in order to describe the naming and placement of data together with relevant type information. At the same time the debugger will gain functionality to understand the OCaml-specific parts of this information including the ability to demangle OCaml names. It is planned to implement much of the DWARF output stage in the compiler and the debugger-side support in libraries such that they might be re-used in other projects.

Namespaces and Module Aliases[edit]

Blog | Mailing List Conversation

While the namespaces feature continues to be refined, support for type-level module aliases was added to the OCaml 4.02 compiler. This is a trivial extension of the ML module system that helps to avoid unnecessary code dependencies, and provides an alternative to strengthening for type equalities.

Higher Kinded Polymorphism[edit]


The higher library show how to express higher-kinded polymorphism in OCaml without functors, using an abstract type app to represent type application, and opaque brands to denote abstractable type constructors. The flexibility of our approach can be seen by using it to translate a variety of standard higher-kinded programs into functor-free OCaml code. Read more about this in the FLOPS 2014 paper.

Exception Matches[edit]

Blog | Bug Report

OCaml's try construct is good at dealing with exceptions, but not so good at handling the case where no exception is raised. This feature (now part of OCaml 4.02.0) implements a simple extension to try that adds support for handling the "success" case. The patch extends match with clauses that specify the "failure continuation".

Open Types[edit]

GitHub | Details | Bug Report

This project extends the existing open type exn mechanism to allow the programmer to create their own open types. This has previously been proposed for functional languages a number of times, for instance as part of a solution to the expression problem (Open Data Types and Open Functions). This feature was merged upstream into OCaml 4.02 and is now available as standard. To try it with OPAM if you have an older system compiler, just do opam switch 4.02.1.

OCaml Java[edit]


OCaml Java is a compiler from OCaml source code to Java bytecode, that can run on any modern Java runtime. This is an interesting way to explore the multicore runtime performance of OCaml with a highly concurrent collector, as is present in the latest JVMs.

Syntax Extensions[edit]

Working Group | Blog 1 | Blog 2

A working group was formed (wg-camlp4) regarding the future of syntax extensions in OCaml. The aim of the working group is to formulate a solid transition plan to create a 'basic OCaml ecosystem' that does not require camlp4.

This has since led to ppx_tools system being developed and released. See notes and details on how to use PPX.

Record Disambiguation[edit]

Bug Report

Type-based record disambiguation.

Leo helped with the record-disambiguation branch of OCaml by Jacques Garrigue. This branch uses type-information to disambiguate between record labels and variant constructors with the same names. For discussions of the semantics of this feature see Gabriel's or Alain's blog posts. Leo rewrote the record-disambiguation branch to use an alternative semantics and improved the error messages. The branch has since been merged into OCaml trunk.

This feature was worked on between Sep 2012 - Feb 2013.