aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface/LexParseRn.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-08-18 14:27:53 -0700
committerDavid Terei <davidterei@gmail.com>2011-10-12 14:06:58 -0700
commit0c16f3b04aadd0cc22fedbf123bae6369d1c445e (patch)
tree2c3b8045789334e9ac12b55a9f5de1d1c8dd8f7d /src/Haddock/Interface/LexParseRn.hs
parent2eb873b5191eee0ffb5094068ab8f0d580453299 (diff)
Add safe haskell indication to haddock output
Diffstat (limited to 'src/Haddock/Interface/LexParseRn.hs')
-rw-r--r--src/Haddock/Interface/LexParseRn.hs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/Haddock/Interface/LexParseRn.hs b/src/Haddock/Interface/LexParseRn.hs
index a92c9c46..d013ca27 100644
--- a/src/Haddock/Interface/LexParseRn.hs
+++ b/src/Haddock/Interface/LexParseRn.hs
@@ -25,6 +25,7 @@ import Haddock.Doc
import Data.Maybe
import FastString
import GHC
+import Outputable ( showPpr )
import RdrName
data HaddockCommentType = NormalHaddockComment | DocSectionComment
@@ -59,14 +60,18 @@ lexParseRnMbHaddockComment dflags hty gre (Just d) = lexParseRnHaddockComment df
-- yes, you always get a HaddockModInfo though it might be empty
lexParseRnHaddockModHeader :: DynFlags -> GlobalRdrEnv -> GhcDocHdr -> ErrMsgM (HaddockModInfo Name, Maybe (Doc Name))
lexParseRnHaddockModHeader dflags gre mbStr = do
- let failure = (emptyHaddockModInfo, Nothing)
- case mbStr of
- Nothing -> return failure
- Just (L _ (HsDocString fs)) -> do
- let str = unpackFS fs
- case parseModuleHeader dflags str of
- Left mess -> do
- tell ["haddock module header parse failed: " ++ mess]
- return failure
- Right (info, doc) ->
- return (rnHaddockModInfo gre info, Just (rnDoc gre doc))
+ (hmod, docn) <- case mbStr of
+ Nothing -> return failure
+ Just (L _ (HsDocString fs)) -> do
+ let str = unpackFS fs
+ case parseModuleHeader dflags str of
+ Left mess -> do
+ tell ["haddock module header parse failed: " ++ mess]
+ return failure
+ Right (info, doc) ->
+ return (rnHaddockModInfo gre info, Just (rnDoc gre doc))
+ return (hmod { hmi_safety = safety }, docn)
+
+ where
+ safety = Just $ showPpr $ safeHaskell dflags
+ failure = (emptyHaddockModInfo, Nothing)