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

View file

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