I am still a beginner in Haskell, so after reading some writefile
tutorials online, I see most of the writefile
examples online are used inside the main
function (main = IO ())
I am wondering whether it's possible to write a function that writes the results into a file using writefile
when it is computed? In some programs (especially games), users might want to stop at a particular points of the game by saving the contents into a .txt file.
For example something like this: (this function does not work, just wondering how to make it work)
concat :: FilePath -> [[a]] -> [a]
concat txt [] = []`
concat txt (xs : xss) = do
y <- xs ++ concat xss
writeFile txt (unlines y)
Thanks:)