aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface/LexParseRn.hs
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-05-06 13:39:23 +0200
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-05-06 13:50:31 +0200
commite8756e5bfcd128817b7942cb439ee3287dd0637a (patch)
tree3f40b20693c69a09573a86d8ebd675a438623f45 /src/Haddock/Interface/LexParseRn.hs
parent70ce2cbf11ea6c861b5597527f768039d0571bf2 (diff)
Remove no longer necessary parser error handling.
We can now drop some Maybe tests and even lets us strip an error handling monad away in a few places.
Diffstat (limited to 'src/Haddock/Interface/LexParseRn.hs')
-rw-r--r--src/Haddock/Interface/LexParseRn.hs53
1 files changed, 20 insertions, 33 deletions
diff --git a/src/Haddock/Interface/LexParseRn.hs b/src/Haddock/Interface/LexParseRn.hs
index d9d4ae58..54c7351d 100644
--- a/src/Haddock/Interface/LexParseRn.hs
+++ b/src/Haddock/Interface/LexParseRn.hs
@@ -21,8 +21,7 @@ module Haddock.Interface.LexParseRn
import Control.Applicative
import Data.IntSet (toList)
import Data.List
-import Data.Maybe
-import Data.Monoid ((<>))
+import Data.Monoid (mconcat)
import DynFlags (ExtensionFlag(..), languageExtensions)
import FastString
import GHC
@@ -33,34 +32,27 @@ import Name
import Outputable (showPpr)
import RdrName
-processDocStrings :: DynFlags -> GlobalRdrEnv -> [HsDocString] -> ErrMsgM (Maybe (Doc Name))
-processDocStrings dflags gre strs = do
- docs <- catMaybes <$> mapM (processDocStringParas dflags gre) strs
- let doc = foldl' (<>) DocEmpty docs
- case doc of
- DocEmpty -> return Nothing
- _ -> return (Just doc)
+processDocStrings :: DynFlags -> GlobalRdrEnv -> [HsDocString] -> Maybe (Doc Name)
+processDocStrings dflags gre strs =
+ case mconcat $ map (processDocStringParas dflags gre) strs of
+ DocEmpty -> Nothing
+ x -> Just x
-processDocStringParas :: DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Maybe (Doc Name))
-processDocStringParas = process parseParasMaybe
+processDocStringParas :: DynFlags -> GlobalRdrEnv -> HsDocString -> Doc Name
+processDocStringParas = process parseParas
-processDocString :: DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Maybe (Doc Name))
-processDocString = process parseStringMaybe
-process :: (DynFlags -> String -> Maybe (Doc RdrName))
+processDocString :: DynFlags -> GlobalRdrEnv -> HsDocString -> Doc Name
+processDocString = process parseString
+
+process :: (DynFlags -> String -> Doc RdrName)
-> DynFlags
-> GlobalRdrEnv
-> HsDocString
- -> ErrMsgM (Maybe (Doc Name))
-process parse dflags gre (HsDocString fs) = do
- let str = unpackFS fs
- case parse dflags str of
- Nothing -> do
- tell [ "doc comment parse failed: " ++ str ]
- return Nothing
- Just doc -> do
- return (Just (rename dflags gre doc))
+ -> Doc Name
+process parse dflags gre (HsDocString fs) =
+ rename dflags gre $ parse dflags (unpackFS fs)
processModuleHeader :: DynFlags -> GlobalRdrEnv -> SafeHaskellMode -> Maybe LHsDocString
@@ -68,19 +60,14 @@ processModuleHeader :: DynFlags -> GlobalRdrEnv -> SafeHaskellMode -> Maybe LHsD
processModuleHeader dflags gre safety mayStr = do
(hmi, doc) <-
case mayStr of
-
Nothing -> return failure
Just (L _ (HsDocString fs)) -> do
let str = unpackFS fs
- case parseModuleHeader dflags str of
- Left msg -> do
- tell ["haddock module header parse failed: " ++ msg]
- return failure
- Right (hmi, doc) -> do
- let !descr = rename dflags gre <$> hmi_description hmi
- hmi' = hmi { hmi_description = descr }
- doc' = rename dflags gre doc
- return (hmi', Just doc')
+ (hmi, doc) = parseModuleHeader dflags str
+ !descr = rename dflags gre <$> hmi_description hmi
+ hmi' = hmi { hmi_description = descr }
+ doc' = rename dflags gre doc
+ return (hmi', Just doc')
let flags :: [ExtensionFlag]
-- We remove the flags implied by the language setting and we display the language instead