[commit: haddock] master: Fixes #5 (183cad1)

git at git.haskell.org git at git.haskell.org
Wed Sep 18 23:25:42 CEST 2013


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/183cad171113faf7d44a25116de6586cd4f07578

>---------------------------------------------------------------

commit 183cad171113faf7d44a25116de6586cd4f07578
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Thu Sep 5 01:28:15 2013 +0100

    Fixes #5


>---------------------------------------------------------------

183cad171113faf7d44a25116de6586cd4f07578
 src/Haddock.hs |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/Haddock.hs b/src/Haddock.hs
index 398aed4..a7ac5ba 100644
--- a/src/Haddock.hs
+++ b/src/Haddock.hs
@@ -34,6 +34,7 @@ import Haddock.GhcUtils hiding (pretty)
 
 import Control.Monad hiding (forM_)
 import Data.Foldable (forM_)
+import Data.List (isPrefixOf)
 import Control.Exception
 import Data.Maybe
 import Data.IORef
@@ -144,6 +145,10 @@ haddock args = handleTopExceptions $ do
           Just "YES" -> return $ Flag_OptGhc "-dynamic-too" : flags
           _ -> return flags
 
+  unless (Flag_NoWarnings `elem` flags) $ do
+    forM_ (warnings args) $ \warning -> do
+      hPutStrLn stderr warning
+
   withGhc' flags' $ do
 
     dflags <- getDynFlags
@@ -171,6 +176,12 @@ haddock args = handleTopExceptions $ do
       -- Render even though there are no input files (usually contents/index).
       liftIO $ renderStep dflags flags qual packages []
 
+-- | Create warnings about potential misuse of -optghc
+warnings :: [String] -> [String]
+warnings = map format . filter (isPrefixOf "-optghc")
+  where
+    format arg = concat ["Warning: `", arg, "' means `-o ", drop 2 arg, "', did you mean `-", arg, "'?"]
+
 
 withGhc' :: [Flag] -> Ghc a -> IO a
 withGhc' flags action = do




More information about the ghc-commits mailing list