I picked up some OCaml recently. At the start of my challenge (see “Songs of the OCaml Compiler”), I read through most of “Real World OCaml – Functional programming for the masses; 2nd Edition (Oct 2022)” by Anil Madhavapeddy and Yaron Minsky. OCaml’s type system was fresh for me, I’ve never used anything like it. I see its appeal.

I’ll soon put up some notes that’s specific to me, but for now here are my generic notes from the book. It’s mostly a compilation of the code snippets and some of my personal annotations as I read the book.

Disclaimer: this is directly dumped from org-noter, it’s best viewed on computer.

It’s a huge set of notes, so I had to break it up into sets of 5 chapters each. We can jump to individual chapters by clicking the links below.

Quick Navigation

Here’s the table of contents for us to jump to:

ChapterTitle
1Guided Tour
2Variables & Functions
3Lists & Patterns
4Files, Modules & Programs
5Records
6Variants
7Error Handling
8Imperative Programming
9GADTs
10Functors
11First-class Modules
12Objects
13Classes
14Maps and HashTables
15Cli Parsing
16
17
18
19

Resources

  1. Real World OCaml (textbook’s devsite) (online pdf resource here – what a time to be alive to see how this book got open access)

Legend

Here’s some tags that I’ll be using in this set of notes:

TagDescription
SPECIALITYLanguage specific features that have some pros/cons to the language.
WITNESSCool way to do something, usually unrelated to the current topic.
LIMITATIONA limitation of OCaml.
FOILPoint about a language feature made as a foil to how it’s done in other languages (e.g., Elixir, Python).
GOTCHAGotchas, no matter how silly.
RULE OF THUMBRules of thumb or opinions within the OCaml ecosystem.
CAUTIONA cautionary point.
TERMINOLOGYSomething pertaining to the accuracy of terms within the OCaml world.
IDIOMA stylistic rule of thumb in OCaml.
PL-DESIGNSomething interesting about the design of the language.

This is just a quick breadth-first exploration. On hindsight, I should make my notes more high-level instead of specific, could have saved some more time.