[Haskell-beginners] Re: Why is there no notion of a one-tuple (e.g., a '([])' as opposed to a '[]') in Haskell?

Benjamin L.Russell DekuDekuplex at Yahoo.com
Thu Sep 25 06:14:45 EDT 2008


On Wed, 24 Sep 2008 21:27:37 -0400, ajb at spamcop.net wrote:

>G'day all.
>
>Quoting "Benjamin L.Russell" <DekuDekuplex at Yahoo.com>:
>
>>> Haskell doesn't have a notion of a one-element tuple.
>>
>> Why not?
>
>As noted by others, there's no syntactic space for them.
>
>Perhaps more crucially, it's hard to see where such a thing would
>be useful.  The 2-tuple (i.e. pair) is a categorical product, and can
>be used to carry around two things where you would normally only
>have space for one.  The 0-tuple (i.e. void) is a categorical terminal
>object, and can be used to fill in space in a parametric data structure
>where no annotation is actually needed.
>
>One reason why they're provided in the Prelude is so that standard
>functions can do operations on them.  It's hard to see where a standard
>function would use a generic 1-tuple.
>
>Generally speaking, if you need a type-checked 1-tuple, you almost
>certainly don't want a generic one.

So, basically generic one-element tuples don't exist because they're
not needed, and there is no elegant way to represent them
syntactically.

That makes sense.

Nevertheless, I can't help feeling that Haskell could perhaps been
made even more elegant if some alternative tuple notation not
conflicting with parentheses had been used; e.g., '{}' (braces)
(please forgive me if braces are already used for some other purpose
of which I am not aware).  Then, for example, we could have the
following:

{} (a unit, or void), 
{{}} (a one-tuple), 
{{{}}} (a one-tuple consisting of a one-tuple), 
{{{{}}}} (a one-tuple consisting of a one-tuple consisting of a
one-tuple), 
...

We could then come up with an n-depth-ordering on tuples, as opposed
to an ordering on n-tuples.  While perhaps not immediately useful,
this ordering would have an interesting structure, and perhaps lead to
some kind of mathematics of n-depth-orderings, which could be even
more interesting, and which could be expressed in Haskell.

-- Benjamin L. Russell



More information about the Beginners mailing list