Remix.run Logo
andrewflnr 8 hours ago

OCaml (and its relatives I think) use * for type products. It's a lot trickier with sum types though because the variant tags realistically have to show up in the syntax, and that's going to really stretch any syntax that tries to use +... I guess it would sort of work if you made Variant(foo, bar) types of things usable standalone types, but that's either a product without a * or another non-algebraic level between + and *.

taeric 8 hours ago | parent | next [-]

Yeah, I think I agree? It did amuse me how quickly this got annoying from the existence of String and how people use it. :D

That is, I think this is what you are saying? That it wouldn't be hard to show that an Optional<String> is the same as a variable that is (String + None) or some such. But having Either<String, String> kills this, since there is no way to distinguish the left and right String types, there. Now, if you forced it to be Either<ErrorString, ResponseString>, that can work. And that nicely explains why you have to tag the types to be distinguishable from each other.

rixed 6 hours ago | parent | prev [-]

It's not +, but it's |, like OR which is the + of logical operators.