I am having an issue with some Haskell code I just wrote. I am just a beginner so I don't know much about the syntax of Haskell and now this error just popped up and I have no clue how to get rid of it.
Couldn't match expected type ‘[Bool]’ with actual type ‘Bool’
grep :: String -> IO()
grep x = do
fileContent <- readFile "/home/User/Desktop/foo.txt"
let fileRows = lines fileContent
let rowNumbers = -1
if (map (isInfixOf x) fileRows == True)
then do let rowNumbers2 = rowNumbers
let rowNumbers = rowNumbers2+1
putStrLn ("[" ++ show(rowNumbers) ++ "] : " ++ x)
else do let rowNumbers2 = rowNumbers
let rowNumbers = rowNumbers2+1
print "False"
I want to check if fileContent contains the word x. If yes, I want to print the line and the line number, otheriwse I want to keep searching until I reach the end of the file. How can I iterate through fileRows to check if the word is in there?