Personal tools

Type of empty list

From HaskellWiki

Revision as of 13:55, 5 January 2012 by Lemming (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

1 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?


2 Answer