X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Frename%2FRnHsDoc.hs;h=9e53f4932016a756a5c686c691d15cea071425f6;hp=16b9bd3e6d967784ae16182ff1cace25f779e47c;hb=b2bd63f99d643f6b3eb30bb72bb9ae26d4183252;hpb=ad94d40948668032189ad22a0ad741ac1f645f50 diff --git a/compiler/rename/RnHsDoc.hs b/compiler/rename/RnHsDoc.hs index 16b9bd3..9e53f49 100644 --- a/compiler/rename/RnHsDoc.hs +++ b/compiler/rename/RnHsDoc.hs @@ -1,107 +1,23 @@ -{-# OPTIONS -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings --- for details -module RnHsDoc ( rnHaddock, rnHsDoc, rnLHsDoc, rnMbLHsDoc ) where +module RnHsDoc ( rnHsDoc, rnLHsDoc, rnMbLHsDoc ) where import TcRnTypes -import TcRnMonad ( RnM ) -import RnEnv ( dataTcOccs, lookupGreRn_maybe ) import HsSyn +import SrcLoc -import RdrName ( RdrName, gre_name ) -import Name ( Name ) -import SrcLoc ( Located(..) ) -import Outputable ( ppr, defaultUserStyle ) - - -rnHaddock :: HaddockModInfo RdrName -> Maybe (HsDoc RdrName) - -> TcGblEnv -> RnM TcGblEnv -rnHaddock module_info maybe_doc tcg_env - = do { rn_module_doc <- rnMbHsDoc maybe_doc ; - - -- Rename the Haddock module info - ; rn_description <- rnMbHsDoc (hmi_description module_info) - ; let { rn_module_info = module_info { hmi_description = rn_description } } - - ; return (tcg_env { tcg_doc = rn_module_doc, - tcg_hmi = rn_module_info }) } - -rnMbHsDoc :: Maybe (HsDoc RdrName) -> RnM (Maybe (HsDoc Name)) -rnMbHsDoc mb_doc = case mb_doc of - Just doc -> do - doc' <- rnHsDoc doc - return (Just doc') - Nothing -> return Nothing +rnMbLHsDoc :: Maybe LHsDocString -> RnM (Maybe LHsDocString) rnMbLHsDoc mb_doc = case mb_doc of Just doc -> do doc' <- rnLHsDoc doc return (Just doc') Nothing -> return Nothing +rnLHsDoc :: LHsDocString -> RnM LHsDocString rnLHsDoc (L pos doc) = do doc' <- rnHsDoc doc return (L pos doc') -ids2string [] = [] -ids2string (x:_) = show $ ppr x defaultUserStyle - -rnHsDoc :: HsDoc RdrName -> RnM (HsDoc Name) -rnHsDoc doc = case doc of - - DocEmpty -> return DocEmpty - - DocAppend a b -> do - a' <- rnHsDoc a - b' <- rnHsDoc b - return (DocAppend a' b') - - DocString str -> return (DocString str) - - DocParagraph doc -> do - doc' <- rnHsDoc doc - return (DocParagraph doc') - - DocIdentifier ids -> do - let choices = concatMap dataTcOccs ids - mb_gres <- mapM lookupGreRn_maybe choices - case [gre_name gre | Just gre <- mb_gres] of - [] -> return (DocString (ids2string ids)) - ids' -> return (DocIdentifier ids') - - DocModule str -> return (DocModule str) - - DocEmphasis doc -> do - doc' <- rnHsDoc doc - return (DocEmphasis doc') - - DocMonospaced doc -> do - doc' <- rnHsDoc doc - return (DocMonospaced doc') - - DocUnorderedList docs -> do - docs' <- mapM rnHsDoc docs - return (DocUnorderedList docs') - - DocOrderedList docs -> do - docs' <- mapM rnHsDoc docs - return (DocOrderedList docs') - - DocDefList list -> do - list' <- mapM (\(a,b) -> do - a' <- rnHsDoc a - b' <- rnHsDoc b - return (a', b')) list - return (DocDefList list') - - DocCodeBlock doc -> do - doc' <- rnHsDoc doc - return (DocCodeBlock doc') - - DocURL str -> return (DocURL str) +rnHsDoc :: HsDocString -> RnM HsDocString +rnHsDoc (HsDocString s) = return (HsDocString s) - DocAName str -> return (DocAName str)