So I have got this piece of code, which returns an error on it's expected type.
Couldn't match expected type ‘[(Char, b0)]’
with actual type ‘(Char, Int)’
In the expression: newList
In a stmt of a list comprehension: (a, b) <- newList
I want to get the location of the character back, so that would be 'b'. I just don't understand why it gives me a type error. Whenever I run the code one by one inside the WinGHCI, I'll get the correct information back. When putting it in a .hs file, it won't.
word = "apple"
isPart :: Char -> a
isPart x = do
newList <- zip word [0..length word]
result <- [b | (a,b) <- newList, a == x]
return result