# \[Book\] Curious OCaml: Functional Programming in OCaml

**URL:** <https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705>\
**Category:** Learning\
**Tags:** book, announce\
**Created:** [January 18, 2026, 8:02pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705 "2026-01-18T20:02:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [January 18, 2026, 8:02pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/1 "2026-01-18T20:02:58Z")

</div>

Hi!

I’m happy to announce a translation of my Functional Programming (in OCaml) lectures into a textbook format, modernized to cover algebraic effects, is complete!

Claude Opus 4.5 did the bulk of the work; GPT-5.2 wrote chapter 10 and tackled the toughest challenges.

HTML version: [Curious OCaml](https://lukstafi.github.io/curious-ocaml/new_book.html)

PDF version: [curious-ocaml/pdfs/new\_book.pdf at main · lukstafi/curious-ocaml · GitHub](https://github.com/lukstafi/curious-ocaml/blob/main/pdfs/new_book.pdf)

Website and Markdown original as README: [GitHub - lukstafi/curious-ocaml: A curious book about OCaml: logic (types), algebra (values), computation (rewrite semantics), functions (lambda calculus), constraints, monads, algebraic effects, expression.](https://github.com/lukstafi/curious-ocaml/tree/main)

Enjoy!

Edited to add: a shoutout to Ahrefs for their support!

---

<div class="post-metadata">

**Author:** ![SebHash](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sebhash/32/4882_2.png) [@SebHash](https://discuss.ocaml.org/u/SebHash)\
**Post date:** [January 18, 2026, 8:44pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/2 "2026-01-18T20:44:50Z")

</div>

Many thanks for sharing this with such a great generosity!

I went through the TOC and beginning of each chatpter and can say I am  
quite excited about discovering the content and pretty sure I’ll learn  
something form each chapter.

One thing I did look for and did not really find is explanations about  
GADTs. I literally grepped for GADT in the repo and did find a few  
occurrences, but just to explain how effects work.

Do you intend to add something about GADTs at some point?

I hope you do, TBH! 😉

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [January 18, 2026, 9:28pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/3 "2026-01-18T21:28:14Z")

</div>

Thank you for the kind words! GADTs hadn’t fallen into the scope of the lectures (therefore book). Said scope was to dig into the aspects by which I was idiosyncratically exposed to FP. I had an outlet for thinking about GADTs via my PhD project, and the lectures at the time were procrastination / burnout prevention wrt. that… So it’s something that’s possible, but haven’t occurred to me before.

Best Regards.

---

<div class="post-metadata">

**Author:** ![SebHash](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sebhash/32/4882_2.png) [@SebHash](https://discuss.ocaml.org/u/SebHash)\
**Post date:** [January 19, 2026, 7:38am UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/4 "2026-01-19T07:38:24Z")

</div>

Thanks a lot for your explanation and for sharing context.

I wish you all the best!

---

<div class="post-metadata">

**Author:** ![roerick](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@roerick](https://discuss.ocaml.org/u/roerick)\
**Post date:** [January 19, 2026, 11:21pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/5 "2026-01-19T23:21:42Z")

</div>

I’m really enjoying this. Lots of bits that I don’t quite get, and some that I do. I don’t think that’s a translation issue, just my bad math/logic. Lots here to study. Added it to my phone home screen. Thank you.

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [January 20, 2026, 7:53pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/6 "2026-01-20T19:53:23Z")

</div>

> [@SebHash](#):
>
> Do you intend to add something about GADTs at some point?
> 
> I hope you do, TBH! 😉

GADTs are now covered in chapter 9 (on algebraic effects) – in the first and the last section. Thanks for the motivation!

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [February 26, 2026, 11:21am UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/7 "2026-02-26T11:21:15Z")

</div>

I tasked Claude Opus 4.6 with writing Chapter 12 of Curious OCaml covering Category Theory, and I’m happy with the result. I wanted to include a Category Theory chapter from the start – not to share anything specific but to learn it as I lacked familiarity. I did nudge Claude to mention a few things that might not get covered otherwise: Galois connections as a theory of concepts, and reification / reflection.

The chapter has only very toy examples, not like the more valuable worked out examples of the other chapters. But I think that’s fine – the purpose of Chapter 12 is to make Category Theory less scary, more relatable.

Also, the PDF rendering should now be somewhat improved. The new version is available at the original links.

Thanks to Ahrefs for their support.

---

<div class="post-metadata">

**Author:** ![dmentre](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@dmentre](https://discuss.ocaml.org/u/dmentre)\
**Post date:** [February 27, 2026, 7:58am UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/8 "2026-02-27T07:58:33Z")

</div>

Just curious, when you say “tasked Claude or GPT” to do the work, what is your workflow? What comes from you and what comes from the LLMs?

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [February 27, 2026, 11:58am UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/9 "2026-02-27T11:58:31Z")

</div>

Chapters 1-8 and 11 went through three passes. I asked Claude Code to translate my old slides directly from the TeXmacs sources to not lose any information into a textbook. (I might have tried both Claude Code and Codex, don’t remember, picked Claude anyway). The result of the first pass was dry so I asked Claude to add more filler to make the text more textbook-like. The third pass was asking GPT to do an editorial review, but IIRC it only added the “in this chapter, you’ll learn” sections.

Chapters 9 and 12 are written for scratch for the textbook version, and chapter 10 is heavily rewritten from the lectures version. For Chapters 9 and 10, I asked both Claude Code and GPT Codex to (re)write them, via a few-sentences prompt. Claude’s result was better for Ch 9, GPT’s for Ch 10. Then I did a few iterations pointing out things I didn’t like. For Chapter 12, I first chatted with Claude in the web UI, with my first prompt being: “See the book under this link, would a chapter combining Category Theory and GADTs be a good idea?” We chatted for a while with my prompts being short and its responses longer. I can share this conversation if you want. At the end I asked Claude to write a plan for the chapter and then asked Claude Code to implement that plan.

Getting to “first edition” chapters 1 to 11 took around 4 working days, plus a bit under half a working day for images with Gemini. Getting chapter 12 took maybe half or 2/3 of a working day. I realize there’s discrepancy between the time and the process I describe above, I would need to dig into records to see where the time went…

Actually, feel free to do your own research by looking at commit messages: [Commits · lukstafi/curious-ocaml · GitHub](https://github.com/lukstafi/curious-ocaml/commits/main/?before=0074bf055872f816bd46f80c8c5bc4888c3e32be+105)

---

<div class="post-metadata">

**Author:** ![710Randy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/710randy/32/5746_2.png) [@710Randy](https://discuss.ocaml.org/u/710Randy)\
**Post date:** [March 16, 2026, 9:58pm UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/10 "2026-03-16T21:58:54Z")

</div>

So are there any plans to explain the [mathematical](https://ncatlab.org/nlab/show/polynomial+functor#definition) theory of [GADT’s](https://dl.acm.org/doi/10.1145/3632866) as you did with polynomials and ADT’s? It really does seem like trying to study it will lead to burnout! Maybe explaining use of the toolchain would be more down to earth. It’s a been a lucid insightful read so far.

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [March 17, 2026, 7:11am UTC](https://discuss.ocaml.org/t/book-curious-ocaml-functional-programming-in-ocaml/17705/11 "2026-03-17T07:11:41Z")

</div>

> [@710Randy](#):
>
> So are there any plans to explain the [mathematical](https://ncatlab.org/nlab/show/polynomial+functor#definition) theory of [GADT’s](https://dl.acm.org/doi/10.1145/3632866) as you did with polynomials and ADT’s?

You are teaching me here. It’s a nice find! I will ask Claude if we can incorporate your link to give chapter 12 more depth, but myself I have limited expertise.

Thanks for the kind words.
