I have a main function that does a lot of I / O. However, at some point I want to check the variable, how not (null shouldBeNull) to exit the entire program without continuing with linux 1 exit code and display an error message.
I tried playing with error "..." , for example, putting it in if :
if (not (null shouldBeNull)) error "something bad happened" else putStrLn "ok"
but I get parse error (possibly incorrect indentation) : (.
Here's the modified snippet.
main :: IO ExitCode main = do --Get the file name using program argument args <- getArgs file <- readFile (args !! 0) putStrLn("\n") -- ... (some other io) -- [DO A CHECK HERE], exit according to check.. -- ... (even more io) echotry <- system "echo success" rmtry <- system "rm -f test.txt" system "echo done."
As you can see, I want to check where I added the comment [DO A CHECK HERE] above ...
Thanks for your help!
source share