diff options
author | idontgetoutmuch <dominic@steinitz.org> | 2015-12-20 21:01:47 +0000 |
---|---|---|
committer | idontgetoutmuch <dominic@steinitz.org> | 2015-12-20 21:01:47 +0000 |
commit | 2bdfda1fb2e0de696ca8c6f7a152b2f85a541be9 (patch) | |
tree | cc29895f7d69f051cfec172bb0f8c2ef03552789 /driver/Main.hs | |
parent | 5a57a24c44e06e964c4ea2276c842c722c4e93d9 (diff) | |
parent | fa03f80d76f1511a811a0209ea7a6a8b6c58704f (diff) |
Merge pull request #1 from haskell/ghc-head
Ghc head
Diffstat (limited to 'driver/Main.hs')
-rw-r--r-- | driver/Main.hs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/driver/Main.hs b/driver/Main.hs index 42b99860..ccbb8b7d 100644 --- a/driver/Main.hs +++ b/driver/Main.hs @@ -1,7 +1,29 @@ +{-# LANGUAGE ScopedTypeVariables #-} module Main where -import Documentation.Haddock (haddock) -import System.Environment (getArgs) +import Control.Exception +import Documentation.Haddock (haddock) +import System.Environment (getArgs) +import System.Exit (exitFailure) +import System.IO main :: IO () -main = getArgs >>= haddock +main = getArgs >>= expandResponse >>= haddock + + +-- | Arguments which look like '@foo' will be replaced with the +-- contents of file @foo@. The contents will be passed through 'words' +-- and blanks filtered out first. +-- +-- We quit if the file is not found or reading somehow fails. +expandResponse :: [String] -> IO [String] +expandResponse = fmap concat . mapM expand + where + expand :: String -> IO [String] + expand ('@':f) = readFileExc f >>= return . filter (not . null) . lines + expand x = return [x] + + readFileExc f = + readFile f `catch` \(e :: IOException) -> do + hPutStrLn stderr $ "Error while expanding response file: " ++ show e + exitFailure |