New to Haskell and wrestling with a problem. I know why my code doesn't work, but I cannot figure out the solution.
The intention is for the user to provide a file name either via argument or, if none provided, prompt the user to enter the data. A message with the file name is printed to the screen and the file is processed.
import System.Environment
main = do
args <- getArgs
let file = if null args
then do putStr "File: " ; getLine
else head args
putStr "processing"
putStrLn file
writeFile file "some very nice text"
The code is wrong, of course, but demonstrates the logic I've been wrestling with. Neither Happy Learn Haskell nor Learn you Haskell could put me over the hump. The closest thread I could find was this one. Many thanks for assistance.