havm 168: Close all opened file handles before leaving.

https://svn.lrde.epita.fr/svn/havm/trunk Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Close all opened file handles before leaving. * src/Main.hs (closeHandle): New function. (evalM): Use it to close all opened file handles. Main.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) Index: src/Main.hs --- src/Main.hs (revision 167) +++ src/Main.hs (working copy) @@ -101,7 +101,14 @@ storeHandle ph else return () +-- Close a (maybe) file handle. +closeHandle :: Maybe Handle -> Mnd () +closeHandle mh = + case mh of + Just h -> lift $ hClose h + Nothing -> return () +-- Evaluate the program. evalM :: Map String OptVal -> [Stm Ann] -> Mnd () evalM fm stms = do optset "low" $ findWithDefault (BVal False) "low" fm @@ -121,10 +128,9 @@ trace ["evaling"] evalExp $ Call NoAnn (Name NoAnn "main") [] profileM - mph <- getProfileHandle - case mph of - Just ph -> lift $ hClose ph - Nothing -> return () + getProfileHandle >>= closeHandle + getDisplayHandle >>= closeHandle + getTraceHandle >>= closeHandle main :: IO () main =
participants (1)
-
Roland Levillain