OCaml for the impatient - Adam Bard and his magical blog. This is the most up to date setup using Opam, jbuilder, Merlin, VSCode etc.,. August 2017.
See also: opam
typerex = Excellent IDE.
ocamlbrowser in a shell to see a
tk based documentaiton browser.
Fortunately, you can install it using
ocamleditor… unfortunately you are dealing with various
idiosyncrasis of gtk on mac… ugh.. To keep it short,
installation by opam might fail with
pkg-config errors. The fix is:
… before running
opam install ocamleditor. Solution
Note: looks butt-ugly on mac, as expected.
opam allows you create “sandboxes” and install packages in them. See the
-A --alias-of option.
See Setting up an OCaml environment for Programming. Use
Apr 2016. See ogen – a tool for creating new OCaml projects with OPAM, Oasis, and Merlin.
Compiling an ocaml file:
That has no dependecies
ocamlopt foo.ml -o foo
that has a dependency (say csv)
ocamlfind ocamlopt -o test -linkpkg -package csv test.ml
ocamlfindis a program that finds all the ocaml packages that are installed on your system (or opam instance, for that matter).
ocamlfind -hto see list of commands available.
ocamlfind printconfshows the path configs etc.,
ocamlfind listwill list all the packages installed.
ocamldep *.ml, which will dumps dependency lines.
Different file types
Ocaml has good study materials – textbooks, lecture notes. There is also the advantage of being able to roll-over to F# for “enterprise” stuff.
- Cornell’s 3110 – Data Structures and Functional Programming course (2013); 2016 2018; 2020
- Cornell’s Functional programming in OCaml, CSCI 49201.
- Harvard’s CS51 – Introduction to Computer Science II: Abstraction and Design
- Functional Programming – Cornell, 2016 by Michael Clarkson
- Computer Laboratory – Course pages 2016–17: Types
- Computer Laboratory – Course pages 2016–17: Advanced Functional Programming
- CS 3110 Tournament History (CS.Cornell)
- 2017 fall
- Functional Programming in OCaml – Fall 2018 Edition Cornell’s cs3110, compiled into a gitbook.
- Functional Data Structures by PLRagde at Waterloo
- Functional Programming in OCaml - Spring 2019 Edition
- Introduction to OCaml
- OCaml for the skeptical
- Using, Understanding, and Unraveling The OCaml Language by Didier Remy .
- An overview of OCaml .
- OCaml and Emily In a Walnut – Custom Designed For C++ and Java Programmers
- Early OCaml workflow pains
- ocamllabs/ocaml-effects-tutorial: Concurrent Programming with Effect Handlers (CUFP‘17)
- A Tutorial to OCaml -ppx Language Extensions | Victor Alexandru Darvariu
- dmbaturin’s blog - ocaml and specifically - introduction to OCaml
- Developing applications with OCaml – online book by INRIA.
- Unix System Programming in OCaml
- How to Think like Computer Scientist (OCaml)
- Fun of Programming – a work in progress.
- Real World OCaml – expected in Fall 2012(!)
-How OCaml Type Checker works. In general Olegs http://okmij.org/ftp/ is a treasure trove of CS material.
- Memory Layout in Ocaml – comment by
- Why OCaml . Also has many links to OCaml pages. - OCaml programming with
- Another Why OCaml
- OCaml briefly – a brief tour of OCaml.
- What is the appeal of OCaml today? Why use it over something like Haskell or Java (reddit); 2018-07-11.
- Danny Willems - Blog - You have ideas, I have skills.
- let author = “Rudi Grinberg” — Rudi Grinberg documentation
- Shayne Fletcher
- dmbaturin’s blog - ocaml tagged articles – has a series on “Introduction to OCaml”. Also notable - If you think ReasonML compiles to JS, you are wrong
- TryOCaml - This site is a demo for the programming environment used during the first session of the OCaml MOOC.
- Ocaml Reddit
- OCaml for the Skeptical: OCaml in a Nutshell
- Polymorphism, subtyping and type inference in MLsub; online editor of the inference enginer
- PhD Thesis: Tierless Web programming in ML | Drup’s thingies
- OCaml for the masses in ACMQueue.
- Effective ML talk at Harvard and “Caml Trading” talk at CMU.
- More Effective ML
- OCaml Skeleton a jumpstart environment for to get code up-and-running. An example application with unit tests is a nice sandbox for language discovery.
- Try Ocaml a web based OCaml REPL.
- OCaml style guide
- another OCaml style guide from UPenn, which is based on,
- SML style guide
OCaml as a replacement language
- Replacing Python with OCaml. Thread and thread2
- Felix is offered an alternate to OCaml
- OCaml vs Haskell discussion on Quora. YMMV.
- OCamlers’ critique of Haskell
Writing languages using OCaml
- Developing Applications with Ocaml - Chapter 6 implements a BASIC interpreter.
- The programming language zoo by Andrej Bauer has multiple examples of simple languages built using OCaml.
- Toy APL implementation by Kragen Sitaker.
- CS 421/521: Compilers and Interpreters
- Lua-ML pure OCaml implementation of Lua 2.5 by Normal Ramsey.
- ML to C++ compiler
Tools, ecosystem and libraries
- Setting Up an OCaml Development Environment in Debian - The Always Learning Marty ; Aug 2018
- OCaml Lint detects common errors in OCaml code.
- IOCaml, OCaml kernel for iPython.
- Domical = OCaml + Iodide - Iodide; Sep 2018.
- Regular expressions in OCaml
- Opam-Android –An OCaml 4.02 toolchain for Android and several useful libraries
- OCaml Scientific Computing — Owl Numerical Library
- js-skeleton – sample
OCaml project tools
Some opinions on the merits of using these tools:
- recco: use
oasismay be better now.
ocamlbuildcomes with the distribution.
myocamlbuild.mlfile automatically for you.
oasisgives you access to
oasis-db, a CPAN like system.
- to manage libraries, use
opamreally doesn’t care about build systems.
- MLState is using
- recco: use
Explicit Typing of a polymorphic variant
type download_result = [ `aborted_by_user | `network_failure of string | `success of filepath ]
- What is good about OCaml’s module system?
- What good is First class Modules?
- “Using an error monad in a language like ocaml is superior to exceptions in almost every way.” via
Sample code / Read Source
- github.com/chrismamo1/zipper – a CLI tool in the imperative style.
- collaborative text editor using Eliom
- vbmithr (Vincent Bernardoff) / Repositories
- bcpierce00/unison: Unison file synchronizer
- Presentation by Dolan, White and Madhavapeddy 2014.
- Multicore OCaml - What’s coming in 2021 - Speaker Deck; Anil and KCSRK
Object oriened OCaml
- The O in OCaml – a reddit discussion, with strong answers from ‘gasche’.
- Experiences with OCaml objects - Thomas Leonard’s blog
Hindley-Milner type system
- Show HN: Hindley-Milner Type Inference Algorithm in OCaml | Hacker News see links within.
Web programming with OCaml
- How to deploy OCaml on Heroku ; Aug 2016.
- OCaml vs haskell vs go
- Thread by @wilfredh: I’m a lisper who has spend a little over six months getting up to speed in OCaml, and it’s been really interesting…
- How does OCaml compare with haskell?; HN thread.
esumii/min-caml: a complete optimizing native-code compiler for a reasonably usable subset of OCaml, in 2000 lines of OCaml. Paper.
PSA: Tired of inscrutable type errors from OCaml? If you use jbuilder/dune, just add this to your jbuild build stanza:
(flags (:standard -short-paths))and your type errors and inferred types from Merlin will magically improve!