OCaml for the impatient . The web's quickest and dirtiest OCaml getting started guide
This is the most up to date setup using Opam, jbuilder, Merlin, VSCode etc.,(. August 2017). (ed note, 2023-10-10: Since then the OCaml system has made huge strides in developer productivity.)
xvw.lol - Why I chose OCaml as my primary language, an opinion piece by a programmer that uses OCaml professionally at tarides. Is a good intro the ecosystem in 2025; via
Language
Concurrency
Learning OCaml
Courseware
Tutorials
Best practices
- Our current OCaml best practices. -- part 1 and part 2 by Issuu Engineering; Dec 2018.
Books
Textbooks
Articles
Blogs
Resources
Papers
Package managers
OCaml Languages
Reason: a syntax for OCaml, so native development or melange development to compile to JS
ReScript: a syntax similar to Reason, but the entire toolchain. Closer to JavaScript, can't compile to native.
Talks
Yaron Minsky:
Miscellaneous
OCaml as a replacement language
Writing languages using OCaml
Tools, ecosystem and libraries
Js_of_Ocaml
- js-skeleton -- sample
project showing how to build a Javascript web-app using
js_of_ocaml, TyXML and React
- H.261 Video Decoding in OCaml. -- This notebook will demonstrate a simple H.261 Video Decoder written in OCaml and compiled to javascript with js_of_ocaml.
OCaml project tools
Build tools:
Some opinions on the merits of using these tools:
Code bits
Explicit Typing of a polymorphic variant
type download_result =
[ `aborted_by_user
| `network_failure of string
| `success of filepath ]
via
Information
QQ
- 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
Multicore OCaml
Object oriened OCaml
Hindley-Milner type system
Semantics
Web programming with OCaml
PPX
Comparison
min-caml
esumii/min-caml: a complete optimizing native-code compiler for a reasonably usable subset of OCaml, in 2000 lines of OCaml. Paper.
Running log
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!
NixOS
Data Science and AI
OCaml Garbage Collection
My notes
emacs + utop + merlin + typerex = Excellent IDE.
2014-11-25: Run ocamlbrowser in a shell to see a tk based documentaiton browser.
OCamlEditor
Fortunately, you can install it using opam install ocamleditor... unfortunately you are dealing with various idiosyncrasies of GTK on mac... ugh.. To keep it short, lablgtk
installation by opam might fail with pkg-config errors. The fix is:
https://github.com/Homebrew/homebrew/issues/14123#issuecomment-37896791
... before running opam install ocamleditor. Solution
via
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 ocamlfind, ocamlbuild and make.
Apr 2016. See ogen -- a tool for creating new OCaml projects with OPAM, Oasis, and Merlin.
Compiling an ocaml file:
ocamlfind
ocamlfind is a program that finds all the ocaml packages that
are installed on your system (or opam instance, for that matter).
ocamlfind -h to see list of commands available.
ocamlfind printconf shows the path configs etc.,
ocamlfind list will list all the packages installed.
ocamldep
typical usage: 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.