
Hi, I just noticed that the json library maps () to a JSON empty array: []. This makes sense if () is a 0-length tuple, the (2,"hi") tuple for example maps to [2,"hi"] But is it so in Haskell? In what sense () is a 0-length tuple? Thanks, titto

It is kind of a 0-length tuple, if you squint, though it's usually called "unit". Each tuple type is entirely distinct from each other, so there's nothing that indicates that something is a tuple except for the spelling -- (a,b,c). For example, unlike python, there is no way to determine the length of a tuple at runtime (e.g. length ()) nor iterate at runtime (as the types are heterogeneous). -Ross On Nov 6, 2009, at 5:08 PM, Pasqualino Titto Assini wrote:
Hi,
I just noticed that the json library maps () to a JSON empty array: [].
This makes sense if () is a 0-length tuple, the (2,"hi") tuple for example maps to [2,"hi"]
But is it so in Haskell?
In what sense () is a 0-length tuple?
Thanks,
titto _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

In what sense () is a 0-length tuple?
In what sense isn't it? Data.Tuple is much to narrow to be of any use here. () is in at least most, if not all, of the type classes that tuples are in. The syntax is strikingly similar. If you ask me, it walks/quacks/smells like a duck, so it's a duck. Regards, John
participants (3)
-
John Dorsey
-
Pasqualino "Titto" Assini
-
Ross Mellgren