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

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