I am trying to write every list from a nested list to the same file. However I want every list to start on a newline.
I've made this and it works, but it's very inefficient and looks bad:
appendFile "scraped.txt" (show (take 1 l))
appendFile "scraped.txt" ("\n")
let l3 = (drop 1 l)
appendFile "scraped.txt" (show (take 1 l3))
appendFile "scraped.txt" ("\n")
let l4 = (drop 1 l3)
appendFile "scraped.txt" (show (take 1 l4))
appendFile "scraped.txt" ("\n")
let l5 = (drop 1 l4)
appendFile "scraped.txt" (show (take 1 l5))
appendFile "scraped.txt" ("\n")
let l6 = (drop 1 l5)
appendFile "scraped.txt" (show (take 1 l6))
appendFile "scraped.txt" ("\n")
I tried something like the following, but I can't seem to correctly use the mapping function:
listValues :: [[String]] -> [String]
listValues :: (map . map)
appendValues :: [[String]] -> IO ()
appendValues = appendFile "scraped.txt" listValues
The txt file now looks like this, which is ok, I just want to know how I can improve my code and learn how to use the mapping function.
Title,Subtitle,Date,Author
[["Een gezonde samenleving? \226\128\156Het belang van sporten wordt onderschat\226\128\157","Teamsport","16 maart 2022","HAN redactie"]]
[["Zo vader, zo dochter","Carsten en Kirsten","10 maart 2022","HAN redactie"]]
[["Milieuvriendelijk vervoer met waterstof","Kennisclip","09 maart 2022","HAN redactie"]]
[["\"Ik heb zin in wat nog komen gaat\"","Master Mind","08 maart 2022","HAN redactie"]]
[["Oorlog in Oekra\195\175ne","Statement van het CvB","07 maart 2022","HAN redactie"]]