[Haskell-cafe] Re:  vs [()]
DekuDekuplex at Yahoo.com
Fri Oct 10 01:18:23 EDT 2008
On Fri, 10 Oct 2008 00:24:08 -0400, John Dorsey <haskell at colquitt.org>
>> > What is the difference between empty list  and list with one unit
>> > element [()]?
>> Prelude> length 
>> Prelude> length [()]
>Also, they differ in type.
>[()] is a list of unit elements, and happens to contain exactly one
> is a (polymorphic) list of any kind of element, and happens not to
>contain any of them.
Prelude> :type 
 :: [a]
Prelude> :type [()]
[()] :: [()]
In fact, [()] contains an empty tuple, called a "unit" (see "4 Notes
and tips" of "Constructor - HaskellWiki" at
http://www.haskell.org/haskellwiki/Constructor), whereas  is just an
-- Benjamin L. Russell
More information about the Haskell-Cafe