git.iko.soy/typeable/pandoc
on master help sign in
Make readWithM accept Text input as well as String (API change)
commite5cc24fb6171f0befe4d1f0a5a7b7d5194cfd72b authorAlexander Krotov <ilabdsf@gmail.com> dateThu 1 Nov 2018, 13:43 (8 years ago) parent95eccb9
1 file changed+6−12
src/Text/Pandoc/Parsing.hs+6−12
src/Text/Pandoc/Parsing.hs+6−12
@@ -1044,19 +1044,13 @@ gridTableFooter = blanklines
10441044---
10451045
10461046-- | Removes the ParsecT layer from the monad transformer stack
1047−readWithM :: (Monad m, Stream s m Char)
1048− => ParserT s st m a -- ^ parser
1049− -> st -- ^ initial state
1050− -> s -- ^ input
1047+readWithM :: (Monad m, Stream s m Char, ToString s)
1048+ => ParserT s st m a -- ^ parser
1049+ -> st -- ^ initial state
1050+ -> s -- ^ input
10511051 -> m (Either PandocError a)
1052−readWithM parser state input = do
1053− res <- runParserT parser state "source" input
1054− case res of
1055− Right x -> return $ Right x
1056− Left e -> do
1057− inp <- either (const "") id
1058− <$> runParserT (many1 anyChar) state "source" input
1059− return $ Left $ PandocParsecError inp e
1052+readWithM parser state input =
1053+ mapLeft (PandocParsecError $ toString input) `liftM` runParserT parser state "source" input
10601054
10611055-- | Parse a string with a given parser and state
10621056readWith :: Parser [Char] st a