The following function will not load:
charName :: a -> String
charName 'a' = "Alpha"
charName 'b' = "Bravo"
charName 'c' = "Charlie"
charName 'd' = "Delta"
charName 'e' = "Echo"
charName 'f' = "Foxtrot"
charName 'g' = "Golf"
charName 'h' = "Hotel"
charName 'i' = "India"
charName 'j' = "Juliet"
charName 'k' = "Kilo"
charName 'l' = "Lima"
charName 'm' = "mike"
charName 'n' = "November"
charName 'o' = "Oscar"
charName 'p' = "Papa"
charName 'q' = "Quebec"
charName 'r' = "Romeo"
charName 's' = "Sierra"
charName 't' = "Tango"
charName 'u' = "Uniform"
charName 'v' = "Victor"
charName 'w' = "Whiskey"
charName 'x' = "X-ray"
charName 'y' = "Yankee"
charName 'z' = "Zulu"
charName 0 = "Zero"
charName 1 = "One"
charName 2 = "Two"
charName 3 = "Three"
charName 4 = "Four"
charName 5 = "Five"
charName 6 = "Six"
charName 7 = "Seven"
charName 8 = "Eight"
charName 9 = "Nine"
charName x = ""
It gives me the following error:
[1 of 1] Compiling Main ( baby.hs, interpreted )
baby.hs:41:9: Couldn't match expected type
a' against inferred type
Char'a' is a rigid type variable bound by the type signature for
charName' at baby.hs:40:12 In the pattern: 'a' In the definition of `charName': charName 'a' = "Alpha"baby.hs:67:9: No instance for (Num Char) arising from the literal
0' at baby.hs:67:9 Possible fix: add an instance declaration for (Num Char) In the pattern: 0 In the definition of
charName': charName 0 = "Zero" Failed, modules loaded: none.
Not sure how I can get this to work. Does anybody have any ideas?