From cdc4ecbe98471512b6751c4068002218b5b28f33 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 20 Jul 2014 13:51:03 -0700 Subject: readWith: reverted generalization from f201bdcb. We need input to be a string so we can print the offending line on an error. --- src/Text/Pandoc/Parsing.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index f77ce60d8..54c645fc5 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -826,10 +826,10 @@ gridTableFooter = blanklines --- -- | Parse a string with a given parser and state. -readWith :: (Show s, Stream s Identity Char) - => ParserT s st Identity a -- ^ parser - -> st -- ^ initial state - -> s -- ^ input +readWith :: (Stream [Char] Identity Char) + => ParserT [Char] st Identity a -- ^ parser + -> st -- ^ initial state + -> [Char] -- ^ input -> a readWith parser state input = case runParser parser state "source" input of @@ -837,16 +837,16 @@ readWith parser state input = let errPos = errorPos err' errLine = sourceLine errPos errColumn = sourceColumn errPos - theline = (lines (show input) ++ [""]) !! (errLine - 1) + theline = (lines input ++ [""]) !! (errLine - 1) in error $ "\nError at " ++ show err' ++ "\n" ++ theline ++ "\n" ++ replicate (errColumn - 1) ' ' ++ "^" Right result -> result -- | Parse a string with @parser@ (for testing). -testStringWith :: (Show s, Show a, Stream s Identity Char) - => ParserT s ParserState Identity a - -> s +testStringWith :: (Show a, Stream [Char] Identity Char) + => ParserT [Char] ParserState Identity a + -> [Char] -> IO () testStringWith parser str = UTF8.putStrLn $ show $ readWith parser defaultParserState str -- cgit v1.2.3