diff options
author | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2014-05-06 13:39:23 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2014-05-06 13:50:31 +0200 |
commit | e8756e5bfcd128817b7942cb439ee3287dd0637a (patch) | |
tree | 3f40b20693c69a09573a86d8ebd675a438623f45 /src/Haddock/Interface/ParseModuleHeader.hs | |
parent | 70ce2cbf11ea6c861b5597527f768039d0571bf2 (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/ParseModuleHeader.hs')
-rw-r--r-- | src/Haddock/Interface/ParseModuleHeader.hs | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/Haddock/Interface/ParseModuleHeader.hs b/src/Haddock/Interface/ParseModuleHeader.hs index 0be2511f..6848dc63 100644 --- a/src/Haddock/Interface/ParseModuleHeader.hs +++ b/src/Haddock/Interface/ParseModuleHeader.hs @@ -11,14 +11,13 @@ ----------------------------------------------------------------------------- module Haddock.Interface.ParseModuleHeader (parseModuleHeader) where -import Haddock.Types +import Control.Applicative ((<$>)) +import Control.Monad (mplus) +import Data.Char +import DynFlags import Haddock.Parser - +import Haddock.Types import RdrName -import DynFlags - -import Data.Char -import Control.Monad (mplus) -- ----------------------------------------------------------------------------- -- Parsing module headers @@ -26,7 +25,7 @@ import Control.Monad (mplus) -- NB. The headers must be given in the order Module, Description, -- Copyright, License, Maintainer, Stability, Portability, except that -- any or all may be omitted. -parseModuleHeader :: DynFlags -> String -> Either String (HaddockModInfo RdrName, Doc RdrName) +parseModuleHeader :: DynFlags -> String -> (HaddockModInfo RdrName, Doc RdrName) parseModuleHeader dflags str0 = let getKey :: String -> String -> (Maybe String,String) @@ -43,28 +42,17 @@ parseModuleHeader dflags str0 = (stabilityOpt,str7) = getKey "Stability" str6 (portabilityOpt,str8) = getKey "Portability" str7 - description1 :: Either String (Maybe (Doc RdrName)) - description1 = case descriptionOpt of - Nothing -> Right Nothing - Just description -> case parseStringMaybe dflags description of - Nothing -> Left ("Cannot parse Description: " ++ description) - Just doc -> Right (Just doc) - in - case description1 of - Left mess -> Left mess - Right docOpt -> case parseParasMaybe dflags str8 of - Nothing -> Left "Cannot parse header documentation paragraphs" - Just doc -> Right (HaddockModInfo { - hmi_description = docOpt, - hmi_copyright = copyrightOpt, - hmi_license = licenseOpt `mplus` licenceOpt, - hmi_maintainer = maintainerOpt, - hmi_stability = stabilityOpt, - hmi_portability = portabilityOpt, - hmi_safety = Nothing, - hmi_language = Nothing, -- set in LexParseRn - hmi_extensions = [] -- also set in LexParseRn - }, doc) + in (HaddockModInfo { + hmi_description = parseString dflags <$> descriptionOpt, + hmi_copyright = copyrightOpt, + hmi_license = licenseOpt `mplus` licenceOpt, + hmi_maintainer = maintainerOpt, + hmi_stability = stabilityOpt, + hmi_portability = portabilityOpt, + hmi_safety = Nothing, + hmi_language = Nothing, -- set in LexParseRn + hmi_extensions = [] -- also set in LexParseRn + }, parseParas dflags str8) -- | This function is how we read keys. -- |