Hacker News new | ask | show | jobs
by tianyicui 5494 days ago
> Now the proposal -- `Let's have a tuple: Either<error_code, return_value> '

The Either data type is not a tuple.

1 comments

"In mathematics and computer science, a tuple is an ordered list of elements. [...] The term originated as an abstraction of the sequence: single, double, triple, quadruple, quintuple, sextuple, septuple, octuple, ..., n‑tuple, ..., where the prefixes are taken from the Latin names of the numerals. The unique 0‑tuple is called the null tuple. A 1‑tuple is called a singleton, a 2‑tuple is called a pair and a 3‑tuple is a triple or triplet."

http://en.wikipedia.org/wiki/Tuple

"Either" isn't ordered list of elements. It's result of a choice, a tagged sum of sets.

So Either is not a tuple by any mean.

To elaborate:

> "Either" isn't ordered list of elements.

Although the Either<T,U> type looks like a pair definition, an Either<T,U> return value contains only one element of type T or U.