What I want to do –
I want to parse an error.txt file and find all the lines where dealer_login is in the string.
The code.
import Control.Monad
import Data.List
main = forever $ do
contents <- readFile "./error.txt"
writeFile "dealer_login_errors.txt" (errorLogsFilter contents)
errorLogsFilter :: String -> String
errorLogsFilter input =
let allLines = lines input
shortLines = filter(\line -> isInfixOf "dealer_login" line) allLines
result = unlines shortLines
in result
It is not until I close power shell that the script seems to stop writing and overwriting the file. I don’t think this is normal behavior. I could be wrong.
I would like to make the string “dealer_login” dynamic and base it on user input. If you can help with that too that would be nice.
I referenced Input and Output - Learn You a Haskell for Great Good!