Is [] a type or not?

Oh! I get it. So when I wrote

type foo = []

I was defining a new variant type foo with one constructor [] having no arguments. I have to say I think it’s super confusing to have just a few special cases of tokens that are interpreted as data constructors. At least in the case of

type foo = ()

I get a

Warning 65 [redefining-unit]: This type declaration is defining a new '()' constructor
which shadows the existing one.
Hint: Did you mean 'type foo = unit'?

Wouldn’t it make sense to give similar warnings for the other special cases?

2 Likes