[Haskell-cafe] Re: [] vs [()]

Mauricio briqueabraque at yahoo.com
Fri Oct 10 07:10:25 EDT 2008


> What is the difference between empty list [] and list with one unit 
> element [()]?
> 


Or, yet:

():[()] --is legal
10:[()] --is not

One list can contain elements of a
single type. Since the type of () is
() (element constructors  and types
are allowed to have the same name),
a list of type [()] can only contain
elements of type (), i.e., ()s. Try
this is ghci:

:t [()]
:t [(),(),(),()]

Best,
Maurício



More information about the Haskell-Cafe mailing list