Books On OCaml (16)


OCaml Programming: Correct + Efficient + Beautiful

Michael R. Clarkson

A textbook on functional programming and data structures in OCaml, with an emphasis on semantics and software engineering.

This book is used at Cornell for a third-semester programming course. Most students have had one semester of introductory programming in Python, followed by one semester of object-oriented programming in Java. Frequent comparisons are therefore made to those two languages. Readers who have studied similar languages should have no difficulty following along. The book does not assume any prior knowledge of functional programming, but it does assume that readers have prior experience programming in some mainstream imperative language. Knowledge of discrete mathematics at the level of a standard first-semester CS course is also assumed.

There are over 200 YouTube videos embedded in this book. They can be watched independently of reading the book.


Real World OCaml

Anil Madhavapeddy, Yaron Minsky

Learn how to solve day-to-day problems in data processing, numerical computation, system scripting, and database-driven web applications with the OCaml multi-paradigm programming language. This hands-on book shows you how to take advantage of OCaml’s functional, imperative, and object-oriented programming styles with recipes for many real-world tasks.

You’ll start with OCaml basics, including how to set up a development environment, and move toward more advanced topics such as the module system, foreign-function interface, macro language, and the OCaml tools. Quickly learn how to put OCaml to work for writing succinct and readable code.

The code examples in this books uses Jane Street core library.


OCaml Scientific Computing

Liang Wang, Jianxin Zhao, Richard Mortier

This book is about the harmonious synthesis of functional programming and numerical computation. It shows how the expressiveness of OCaml allows for fast and safe development of data science applications. Step by step, the authors build up to use cases drawn from many areas of Data Science, Machine Learning, and AI, and then delve into how to deploy at scale, using parallel, distributed, and accelerated frameworks to gain all the advantages of cloud computing environments.

This book aims at anyone with a basic knowledge of functional programming and a desire to explore the world of scientific computing, whether to generally explore the field in the round, to build applications for particular topics, or to deep-dive into how numerical systems are constructed. It does not assume strict ordering in reading – readers can simply jump to the topic that interests them most.


Introduction to Functional Programming and the Structure of Programming Languages using OCaml

Gert Smolka

This text teaches functional programming and the structure of programming languages to beginning students. It is written for the Programming 1 course for computer science students at Saarland University. We assume that incoming students are familiar with mathematical thinking, but we do not assume programming experience. The course is designed to take about one third of the first semester's study time.

As it comes to functional programming, we cover higher-order recursive functions, polymorphic typing, and constructor types for lists, trees, and abstract syntax. We emphasise the role of correctness statements and practice inductive correctness proofs. We also cover asymptotic running time considering binary search (logarithmic), insertion sort (quadratic), merge sort (linearithmic), and other algorithms.

As it comes to the structure of programming languages, we study the different layers of syntax and semantics at the example of the idealised functional programming language Mini-OCaml. We describe the syntactic layers with grammar and the semantic layers with inference rules. Based on these formal descriptions, we program recursive descent parsers, type checkers and evaluators.



G. Chen

Initiation à la programmation fonctionnelle en OCaml

Mohammed-Said Habet

La programmation fonctionnelle est un style de programmation qui consiste à considérer les programmes informatiques comme des fonctions au sens mathématique du terme. Ce style est proposé dans de nombreux langages de programmation anciens et récents comme OCaml.

Le but de ce livre est d’initier le lecteur au style fonctionnel de programmation en utilisant le langage OCaml. Cet ouvrage s’adresse donc principalement aux débutants en informatique. Il peut également être l’occasion pour les initiés de découvrir le langage de programmation OCaml.

Le lecteur trouvera une présentation progressive des concepts de programmation fonctionnelle dans le langage OCaml, illustrée par des exemples, de nombreux exercices corrigés et d’autres laissés à l’initiative du lecteur.


More OCaml: Algorithms, Methods, & Diversions

John Whitington

In "More OCaml," John Whitington takes a meandering tour of functional programming with OCaml, introducing various language features and describing some classic algorithms. The book ends with a large worked example dealing with the production of PDF files. There are questions for each chapter together with worked answers and hints.

"More OCaml" will appeal both to existing OCaml programmers who wish to brush up their skills and to experienced programmers eager to explore functional languages such as OCaml. It is hoped that each reader will find something new or see an old thing in a new light. For the more casual reader, or those who are used to a different functional language, a summary of basic OCaml is provided at the front of the book.


Apprendre à programmer avec OCaml

Jean-Christophe Filliâtre, Sylvain Conchon

Computer programming is hard to learn. Being a skillful programmer requires imagination, anticipation, knowledge in algorithmics, the mastery of a programming language, and above all, experience, as difficulties are often hidden in details. This book synthesises our experience as teachers and programmers.

The programming style is essential. Given a programming language, the same algorithm can be written in multiple ways, and some of them can be both elegant and efficient. This is what the programmer must seek at all costs and the reason why we choose a programming language for this book rather than pseudo-code. Our choice is OCaml.

This book is organised into three parts. The first one introduces OCaml and targets beginners, whether they're programming beginners or simply new to OCaml. Through small programs, the reader is introduced to fundamental concepts of programming and of OCaml. The second and third parts are dedicated to fundamental concepts of algorithmics and should allow the reader to write programs in a structured and efficient way. Algorithmic concepts are directly presented in the syntax of OCaml and any code snippet from the book is available online.


OCaml From the Very Beginning

John Whitington

In OCaml from the Very Beginning, John Whitington takes a no-prerequisites approach to teaching a modern general-purpose programming language. Each small, self-contained chapter introduces a new topic, building until the reader can write quite substantial programs. There are plenty of questions and, crucially, worked answers and hints.

OCaml from the Very Beginning will appeal both to new programmers, and experienced programmers eager to explore functional languages such as OCaml. It is suitable both for formal use within an undergraduate or graduate curriculum, and for the interested amateur.


Think OCaml: How to Think Like a Functional Programmer

Nicholas Monje, Allen Downey

This book is a work in progress. It is an introductory programming textbook based on the OCaml language. It is a modified version of Think Python, by Allen Downey. It is intended for newcomers to programming and also those who know some programming but want to learn programming in the function-oriented paradigm, or those who simply want to learn OCaml.


プログラミング in OCaml ~関数型プログラミングの基礎からGUI構築まで~

A. Igarashi (五十嵐 淳)

入門OCaml ~プログラミング基礎と実践理解~


Programmation de droite à gauche et vice-versa

Pascal Manoury

Apprentissage de la programmation avec OCaml

Catherine Dubois, Valérie Ménissier Morain

Programming is a discipline by which the strengths of computers can be harnessed: large amounts of reliable memory, the ability to execute repetitive tasks relentlessly, and a high computation speed. In order to write correct programs that fulfill their specified needs, it is necessary to understand the precise semantics of the programming language. This book is targeted towards beginner programmers and provides teaching material for all programmers wishing to learn the functional programming style. The programming features introduced in this book are available in all dialects of the ML language, notably Caml-Light, OCaml and Standard ML. The concepts presented therein and illustrated in OCaml easily transpose to other programming languages.


Introduzione alla programmazione funzionale

Carla Limongelli, Marta Cialdea

Développement d'applications avec Objective Caml

Emmanuel Chailloux, Pascal Manoury, Bruno Pagano

A comprehensive (742 pages) book on OCaml, covering not only the core language, but also modules, objects and classes, threads and systems programming, and interoperability with C.

"Objective CAML est un langage de programmation : un de plus dira-t-on ! Ils sont en effet déjà nombreux et pourtant il en apparaît constamment de nouveaux. Au delà de leurs disparités, la conception et la genèse de chacun d'eux procèdent d'une motivation partagée : la volonté d'abstraire"

If you want to add a new book, check out the Contributing Guide on GitHub.