- The quickstart page to get you up and running as fast as possible.
- Play around with OCaml online using sketch.sh.
- Quick Start an OCaml project with Dune
- The Beginner’s Guide to OCaml Beginner’s guides
- Learn X in Y minutes where X=OCaml.
- Functional Programming with OCaml
- Ocaml file types and filename extensions
- OCaml subtleties are good to watch out for.
Several guidelines for best practices have been established by the community. See Best Practices.
Setting Up Your Editor
OCaml can be edited conveniently with many different editors. See Editor Support.
Modules and Functors
- OCaml polymorphism examples
- OCaml - polymorphic print and type erasure
- Weak Type Variables - when impurity breaks polymorphism
The Format Module
The Stdlib has the Format module for pretty printing. It’s a little tricky to get a hang of.
PPX (PreProcessor eXtensions)
- Xavier Leroy’s Monadic Programming Lecture Slides (pdf) and code
- Cornell’s CS 3110 Lecture about monads, with code and recitation
- A small monads tutorial from the Monads library
- Discussion on what you can do with Monads and what are Monad Transformers
- Monadic Error Handling
- More Typeclasses in OCaml
- First steps with Category Theory and OCaml (focusing more on Monoids and Applicatives)
Writing Efficient Code
- Python to OCaml: retrospective
- Xen – OCaml Coding Considerations
- A blog about game development in OCaml
- (Functional) Alternatives to inheritance
- Higher-Rank Polymorphism in OCaml
- mikmatch – OCaml pattern-matching extended with regexps
- Inlined records in constructors
- Algebraic Data Types
- A safe but strange way of modifying OCaml compiler
- Fiddling with the OCaml Type System
- Quick and Dirty Guide to Monadic Parsers and Angstrom
A list of projects that can be used as examples or for inspiration.
- 99 problems: classic 99 problems, with solutions.
- Rosetta Code
- OCaml at Exercism – Exercism is your place to engage in thoughtful conversations about code. Explore simplicity, idiomatic language features, and expressive readable code. Solutions.
- Real World OCaml by Y. Minsky, A. Madhavapeddy and J. Hickey - Functional programming for the masses. The latest, and arguably the most readable book on OCaml. Note that the book uses only Jane Street libraries, but the material can be applied to other libraries.
- RWO-lwt : translating the Async code examples from Real World OCaml to lwt.
- More OCaml: Algorithms, Methods, and Diversions – 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.
- How to Think Like a (Functional) Programmer by Allen Downey and Nicholas Monje – How to Think Like a Computer Scientist 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.
- OCaml from the Very Beginning by J. Whitington - OCaml from the Very Beginning will appeal both to new programmers, and experienced programmers eager to explore functional languages such as OCaml.
- Pearls of Functional Algorithm Design by Richard Bird - It summaries 30 hard algorithm problems in function programming world. Although it is for Haskell, the algorithm problems are very interesting and trying to solve them in OCaml also helps the thinking of functional programming. Partial solutions in OCaml are [https://github.com/MassD/pearls here].
- Unix System Programming in OCaml by X. Leroy and D. Rémy – Introduction to Unix system programming, with an emphasis on communications between processes.
- Using, Understanding, and Unraveling OCaml – This book describes both the OCaml language and the theoretical grounds behind its powerful type system.
- Purely Functional Data Structures : A classic book focusing on various data structures in the functional programming world. Can be very useful for understanding functional data structures, though OCaml obviously supports imperative data structures as well.
- OCaml for Scientists - by Jon Harrop.
- Types and Programming Languages by Benjamin C. Pierce - A friendly but serious book on types, type checking, etc. Much of what’s covered is relevant to OCaml. Several chapters present OCaml implementations of the concepts covered in preceding chapters, and the examples in the book have been typechecked using OCaml programs that are available at the author’s site. (As of mid-2018, the Kindle version can be difficult to read on small devices because the pages are images of the hardcover’s pages. The iBook version is a standard e-book with resizable fonts, though.)
- Advanced Topics in Types and Programming Languages is an anthology edited by Benjamine C. Pierce. It includes some articles that are relevant to OCaml.
- Introduction to Functional Programming in OCaml .
- Cornell University – Data Structures and Functional Programming .
- Princeton University - Functional programming in OCaml .
- University of Illinois - Course that uses OCaml to teach functional programming and programming language design