Type of empty list
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?