[Haskell-beginners] 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
Wed Sep 24 08:08:49 EDT 2008


I'm having difficulty in understanding the following behavior:

In GHCi:

Prelude> :type []
[] :: [a]

but:

Prelude> :type ([])
([]) :: [a]

I.e., the types of both the empty-list '[]' and the one-tuple
containing the empty-list '[]' are '[a]' (a list of a generic type
variable).

According to "Chapter 2. Types and Functions" (see
http://book.realworldhaskell.org/read/types-and-functions.html) of
Real World Haskell (beta) (see
http://book.realworldhaskell.org/beta/), 

>Haskell doesn't have a notion of a one-element tuple.

Why not?  It seems that a tuple is similar to a list, except that the
elements need not be all of the same type, and that a tuple, unlike a
list, cannot be extended.  Yet:

Prelude> :type []
[] :: [a]

and 

Prelude> :type [[]]
[[]] :: [[a]]

so the types of the empty-list '[]' and the one-element list
containing the empty-list '[[]]' are different.

Forgive me if I am missing something, but something about this
asymmetry bothers me....

-- Benjamin L. Russell



More information about the Beginners mailing list