Changed parseWithWarnings to the more general returnWarnings parser transformer

This commit is contained in:
Matthew Pickering 2015-01-30 12:31:12 +00:00
parent e8677bae78
commit 9d77206827
2 changed files with 6 additions and 7 deletions

View file

@ -65,7 +65,7 @@ module Text.Pandoc.Parsing ( anyLine,
widthsFromIndices,
gridTableWith,
readWith,
readWithWarnings,
returnWarnings,
readWithM,
testStringWith,
guardEnabled,
@ -885,11 +885,10 @@ readWith :: Parser [Char] st a
-> a
readWith p t inp = runIdentity $ readWithM p t inp
readWithWarnings :: Parser [Char] ParserState a
-> ParserState
-> String
-> (a, [String])
readWithWarnings p = readWith $ do
returnWarnings :: (Stream s m c)
=> ParserT s ParserState m a
-> ParserT s ParserState m (a, [String])
returnWarnings p = do
doc <- p
warnings <- stateWarnings <$> getState
return (doc, warnings)

View file

@ -58,7 +58,7 @@ readRST :: ReaderOptions -- ^ Reader options
readRST opts s = (readWith parseRST) def{ stateOptions = opts } (s ++ "\n\n")
readRSTWithWarnings :: ReaderOptions -> String -> (Pandoc, [String])
readRSTWithWarnings opts s = (readWithWarnings parseRST) def{ stateOptions = opts } (s ++ "\n\n")
readRSTWithWarnings opts s = (readWith (returnWarnings parseRST)) def{ stateOptions = opts } (s ++ "\n\n")
type RSTParser = Parser [Char] ParserState