[Haskell-beginners] Type question

Yitzchak Gale gale at sefer.org
Mon Jan 5 17:52:43 EST 2009

Hi Paul,

You wrote:
> Prelude> [] : []
> [[]]
> it :: [[a]]
> I thought the first argument of ':' must be an element, so is the empty list
> an element of the same type of the contents of the empty list?

There is not just one "empty list". The symbol [] is actually
polymorphic - it can refer to the empty list in [a], for any type a.

In particular, "a" can itself be a list type. So [] : [] is an element
of [[a]], the type of list of lists of a, for any type a.

Hope this helps,

More information about the Beginners mailing list