Early preview of the Algorithmic with OCaml book

even historically there seems to be a controversy:
see https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/history.pdf, quoting:

Haskell took from Miranda the notion of defining algebraic types as
a ‘sum of products’. In the above, a tree is either a leaf or a branch (a
sum with two alternatives), a leaf contains a value (a trivial product
with only one field), and a branch contains a left and right subtree
(a product with two fields). In contrast, Hope and Standard ML
separated sums (algebraic types) and products (tuple types); in the
equivalent definition of a tree, a branch would take one argument
which was itself a tuple of two trees.

1 Like

Not only across the OCaml environment, but also across the environment of several other PL languages - the web pretty much. I think even the rust language documentation makes reference to ADTs at one point or another.

I think that in the Ocaml manual there are no reference to “plain” ADT. There are discussions about “regular or not regular” ADT in the polymorphism chapter, and discussions about “generalized” ADT. Nothing that precisely defines ADT

1 Like

Then what do you call a union of unions? Is this algebraic?

To me, the only sound/logical definition would be to define ADT to be “any combination of sums and products of basic types”. (Assuming we know which are the basic types). Then the word “algebraic” would make some sense. But in “any” you need to include “1” and “0”. Then you realize that any basic type is an edge case of an ADT.

2 Likes

good point! :exploding_head: another source of confusion

1 Like