I have the following code (using lookup from the Haskell Prelude):
al :: [(Char, Int)]
al = [("A", 1),
("B", 2),
("C", 3),
...
]
strToInt :: [Char] -> Int
strToInt []
= 0
strToInt (c:cs)
= lookup c al + strToInt cs
The problem is I am trying to perform addition on Maybe Int
and Int
which the compiler will not allow. How can I resolve this issue?