As some of you may know, the type inference errors in Haskell can be cryptic at times. I was trying to write a function that mapped alphabetic characters to their uppercase version, and I came up with this:
toUpper :: Char -> Char
toUpper char = maybe " " (\a -> a) isValue
where charMap = zip ['a' .. 'z'] ['A' .. 'Z']
isValue = lookup char charMap
But it complains about the following:
wordsearch.hs:2:35: Couldn't match expected type `[Char]' against inferred type `Char' Expected type: Maybe [Char] Inferred type: Maybe Char In the third argument of `maybe', namely `isValue' In the expression: maybe " " (\ a -> a) isValue
The error is doesn't make sense to me as i'm a newbie, can anyone help?