Simplify the implementation of writeUTF8File and use it in one more place.
Remove unused imports left over after a previous change.
This commit is contained in:
hallgren
2012-10-23 11:48:23 +00:00
parent c084e1b040
commit 7565ba8b87
3 changed files with 9 additions and 15 deletions

View File

@@ -117,11 +117,7 @@ grammarName opts pgf = fromMaybe (showCId (absname pgf)) (flag optName opts)
writeOutput :: Options -> FilePath-> String -> IOE ()
writeOutput opts file str =
do let path = case flag optOutputDir opts of
Nothing -> file
Just dir -> dir </> file
putPointE Normal opts ("Writing " ++ path ++ "...") $ ioeIO $
bracket
(openFile path WriteMode)
(hClose)
(\h -> hSetEncoding h utf8 >> hPutStr h str)
putPointE Normal opts ("Writing " ++ path ++ "...") $ ioeIO $
writeUTF8File path str
where
path = maybe id (</>) (flag optOutputDir opts) file