[Haskell-cafe] Is () a 0-length tuple?

Ross Mellgren rmm-haskell at z.odi.ac
Fri Nov 6 17:13:59 EST 2009


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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list