I want to do the following in ghci
, but apparently it does not allow me to do so:
charName :: Char -> String
charName 'a' = "Albert"
charName 'b' = "Broseph"
charName 'c' = "Cecil"
I could have done:
let charName 'a' = "Albert"
let charName 'b' = "Broseph"
let charName 'c' = "Cecil"
But still, because of no charName :: Char -> String
, it would fail the following:
charName 'a'
"*** Exception: <interactive>:38:5-26: Non-exhaustive patterns in function charName
How can I solve this issue?