IIRC, it’s a decision made long, long ago. SML/NJ allowed the sort of conflation of constructors and functions that you describe, but CAML-Light forbade it. It also instituted the rule that Capitalized names were constructors and uncapitalized names were variables. I don’t remember anymore why, but those are baked pretty deep into the history of OCaml. We’re talking 1990, so … 32 years.
Pretty much predates everything except SML/NJ (Haskell came out around the same time, but was nowhere near usable – IIRC bootstrapping took 3 days at the time).
So I played with your examples again @octachron, the difference is quite subtle. I’ll remember not to think of them as functions altogether as you advised
That’s great feedback thanks! I was wondering why things were different in Ocaml.
I suppose it’s got something to do with clarity. I remember being very confused when I first learned about opaque types in Elm.
type Dog = Dog
vs the somewhat clearer Ocaml construct : you can’t confuse the type name with the variant.
type dog = Dog
Thanks Nicolas, this looks like an interesting read.
[I’ve done this before, but]
Can I just put out a gigantic recommendation that anybody who has any interest in programming languages and their design and implementation, should read this Xavier’s Master’s thesis (the ZINC paper) ? It’s amazing, and everyone should read it. I learned so much, reading that paper.