Type of empty list

From HaskellWiki
Revision as of 13:55, 5 January 2012 by Lemming (talk | contribs) (question)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Question

Why is

([]::[Int]) == ([]::[Char])

a type error and not just True (because both lists are empty) or False (because the types mismatch)?

Related question: Why is

map :: (a -> b) -> [a] -> [b]
map f (x:xs) = f x : map f xs
map f xs@[] = xs

a type error and the case definition

map f [] = []

is not?


Answer