Most of the time, when people make extensible programs in typed functional languages,
they make a DSL, not least because it's much easier to make a DSL in a language with algebraic types
and pattern matching than in one without.
Some use cases really require a general-purpose language though. That's …
It's been a while since I published the first part.
In case you were worrying how the rest of migration went, well, I ended up with an operational system quickly, even if because I decided not to change
the rest of it yet.
In OCaml, exceptions are not objects, and there are no exception hierarchies. It may look unusual now,
but in fact exceptions predate the rise of object oriented languages and it's more in line with original
implementations. The advantage is that they are very lightweight.
Higher order functions and parametric polymorphism
So far we have only worked with functions that take value of a single type known beforehand.
However, we have already seen functions whose types were left without explanation, such as
let hello _ = print_endline "hello world" that we used to demonstrate …
This post series started as a response to requests from some friends curious about OCaml.
There are quite a few nice books already, but I realized that if I just recommend them any one of those
books, it still will leave me with quite a few things to explain …
Implementation of sets using nothing but functions would be one of the first tricks in the
“100 Fun Things to Do With Functions and Closures” book if that book existed.
It may not be very practical, but it may help people get into the functional mindset.
We'll use OCaml for …