git.iko.soy/typeable/pandoc
on master help sign in
Use Prelude.fail to avoid ambiguity with fail from GHC.Base.
commitc86691fb84ec830086bc9b5e54b1ec8e41d160c8 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 28 Sep 2019, 11:56 (7 years ago) parent981b5de
17 files changed+38−38
src/Text/Pandoc/Extensions.hs+1−1 src/Text/Pandoc/Parsing.hs+6−6 src/Text/Pandoc/Readers/HTML.hs+2−2 src/Text/Pandoc/Readers/LaTeX.hs+2−2 src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−5 src/Text/Pandoc/Readers/Man.hs+2−2 src/Text/Pandoc/Readers/Markdown.hs+2−2 src/Text/Pandoc/Readers/Muse.hs+2−2 src/Text/Pandoc/Readers/RST.hs+1−1 src/Text/Pandoc/Readers/Roff.hs+3−3 src/Text/Pandoc/Readers/Textile.hs+1−1 src/Text/Pandoc/Translations.hs+3−3 src/Text/Pandoc/Writers/Docx.hs+1−1 src/Text/Pandoc/Writers/HTML.hs+1−1 src/Text/Pandoc/Writers/Muse.hs+3−3 src/Text/Pandoc/Writers/OOXML.hs+2−2 src/Text/Pandoc/Writers/Powerpoint/Output.hs+1−1
src/Text/Pandoc/Extensions.hs+1−1
@@ -397,7 +397,7 @@ parseFormatSpec = parse formatSpec ""
397397 Just n -> return n
398398 Nothing
399399 | name == "lhs" -> return Ext_literate_haskell
400− | otherwise -> fail $ "Unknown extension: " ++ name
400+ | otherwise -> Prelude.fail $ "Unknown extension: " ++ name
401401 return $ case polarity of
402402 '-' -> disableExtension ext
403403 _ -> enableExtension ext
src/Text/Pandoc/Parsing.hs+6−6
@@ -343,16 +343,16 @@ notFollowedBy' p = try $ join $ do a <- try p
343343-- (This version due to Andrew Pimlott on the Haskell mailing list.)
344344
345345oneOfStrings' :: Stream s m Char => (Char -> Char -> Bool) -> [String] -> ParserT s st m String
346−oneOfStrings' _ [] = fail "no strings"
346+oneOfStrings' _ [] = Prelude.fail "no strings"
347347oneOfStrings' matches strs = try $ do
348348 c <- anyChar
349349 let strs' = [xs | (x:xs) <- strs, x `matches` c]
350350 case strs' of
351− [] -> fail "not found"
351+ [] -> Prelude.fail "not found"
352352 _ -> (c:) <$> oneOfStrings' matches strs'
353353 <|> if "" `elem` strs'
354354 then return [c]
355− else fail "not found"
355+ else Prelude.fail "not found"
356356
357357-- | Parses one of a list of strings. If the list contains
358358-- two strings one of which is a prefix of the other, the longer
@@ -525,7 +525,7 @@ romanNumeral upperCase = do
525525 hundreds + nineties + fifties + forties + tens + nines +
526526 fives + fours + ones
527527 if total == 0
528− then fail "not a roman numeral"
528+ then Prelude.fail "not a roman numeral"
529529 else return total
530530
531531-- Parsers for email addresses and URIs
@@ -698,7 +698,7 @@ characterReference = try $ do
698698 _ -> ent ++ ";"
699699 case lookupEntity ent' of
700700 Just (c : _) -> return c
701− _ -> fail "entity not found"
701+ _ -> Prelude.fail "entity not found"
702702
703703-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
704704upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
@@ -1312,7 +1312,7 @@ failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t)
13121312 -> ParserT s st m ()
13131313failIfInQuoteContext context = do
13141314 context' <- getQuoteContext
1315− when (context' == context) $ fail "already inside quotes"
1315+ when (context' == context) $ Prelude.fail "already inside quotes"
13161316
13171317charOrRef :: Stream s m Char => String -> ParserT s st m Char
13181318charOrRef cs =
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -445,7 +445,7 @@ headerLevel tagtype =
445445-- return (level - 1))
446446-- <|>
447447 return level
448− Nothing -> fail "Could not retrieve header level"
448+ Nothing -> Prelude.fail "Could not retrieve header level"
449449
450450eTitlePage :: PandocMonad m => TagParser m ()
451451eTitlePage = try $ do
@@ -1238,7 +1238,7 @@ htmlTag f = try $ do
12381238 if stripComments
12391239 then return (next, "")
12401240 else return (next, "<!--" <> s <> "-->")
1241− | otherwise -> fail "bogus comment mode, HTML5 parse error"
1241+ | otherwise -> Prelude.fail "bogus comment mode, HTML5 parse error"
12421242 TagOpen tagname attr -> do
12431243 guard $ isPI tagname || all (isName . fst) attr
12441244 handleTag tagname
src/Text/Pandoc/Readers/LaTeX.hs+2−2
@@ -1239,7 +1239,7 @@ romanNumeralArg = spaces *> (parser <|> inBraces)
12391239 Tok _ Word s <- satisfyTok isWordTok
12401240 let (digits, rest) = T.span isDigit s
12411241 unless (T.null rest) $
1242− fail "Non-digits in argument to \\Rn or \\RN"
1242+ Prelude.fail "Non-digits in argument to \\Rn or \\RN"
12431243 safeRead $ T.unpack digits
12441244
12451245newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
@@ -2268,7 +2268,7 @@ parseAligns = try $ do
22682268 case safeRead ds of
22692269 Just n ->
22702270 getInput >>= setInput . (mconcat (replicate n spec) ++)
2271− Nothing -> fail $ "Could not parse " ++ ds ++ " as number"
2271+ Nothing -> Prelude.fail $ "Could not parse " ++ ds ++ " as number"
22722272 bgroup
22732273 spaces
22742274 maybeBar
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−5
@@ -244,7 +244,7 @@ applyMacros s = (guardDisabled Ext_latex_macros >> return s) <|>
244244 , sMacros = extractMacros pstate }
245245 res <- runParserT retokenize lstate "math" (tokenize "math" (T.pack s))
246246 case res of
247− Left e -> fail (show e)
247+ Left e -> Prelude.fail (show e)
248248 Right s' -> return s'
249249
250250tokenize :: SourceName -> Text -> [Tok]
@@ -452,7 +452,7 @@ doMacros' n inp = do
452452 lstate <- getState
453453 res <- lift $ runParserT getargs' lstate "args" ts
454454 case res of
455− Left _ -> fail $ "Could not parse arguments for " ++
455+ Left _ -> Prelude.fail $ "Could not parse arguments for " ++
456456 T.unpack name
457457 Right (args, rest) -> do
458458 -- first boolean param is true if we're tokenizing
@@ -576,11 +576,11 @@ primEscape = do
576576 Just (c, _)
577577 | c >= '\64' && c <= '\127' -> return (chr (ord c - 64))
578578 | otherwise -> return (chr (ord c + 64))
579− Nothing -> fail "Empty content of Esc1"
579+ Nothing -> Prelude.fail "Empty content of Esc1"
580580 Esc2 -> case safeRead ('0':'x':T.unpack (T.drop 2 t)) of
581581 Just x -> return (chr x)
582− Nothing -> fail $ "Could not read: " ++ T.unpack t
583− _ -> fail "Expected an Esc1 or Esc2 token" -- should not happen
582+ Nothing -> Prelude.fail $ "Could not read: " ++ T.unpack t
583+ _ -> Prelude.fail "Expected an Esc1 or Esc2 token" -- should not happen
584584
585585bgroup :: PandocMonad m => LP m Tok
586586bgroup = try $ do
src/Text/Pandoc/Readers/Man.hs+2−2
@@ -131,7 +131,7 @@ parseTable = do
131131 Left _ -> do
132132 res' <- lift $ readWithMTokens blockstcell st ts'
133133 case res' of
134− Left _ -> fail "Could not parse table cell"
134+ Left _ -> Prelude.fail "Could not parse table cell"
135135 Right x -> do
136136 modifyState $ \s -> s{ tableCellsPlain = False }
137137 return x
@@ -492,4 +492,4 @@ skipUnknownMacro = do
492492 ControlLine mkind _ pos -> do
493493 report $ SkippedContent ('.':mkind) pos
494494 return mempty
495− _ -> fail "the impossible happened"
495+ _ -> Prelude.fail "the impossible happened"
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -261,7 +261,7 @@ yamlBsToMeta bstr = do
261261nodeToKey :: Monad m => YAML.Node YE.Pos -> m Text
262262nodeToKey (YAML.Scalar _ (YAML.SStr t)) = return t
263263nodeToKey (YAML.Scalar _ (YAML.SUnknown _ t)) = return t
264−nodeToKey _ = fail "Non-string key in YAML mapping"
264+nodeToKey _ = Prelude.fail "Non-string key in YAML mapping"
265265
266266toMetaValue :: PandocMonad m
267267 => Text -> MarkdownParser m (F MetaValue)
@@ -767,7 +767,7 @@ lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<'
767767lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m String
768768lhsCodeBlockBirdWith c = try $ do
769769 pos <- getPosition
770− when (sourceColumn pos /= 1) $ fail "Not in first column"
770+ when (sourceColumn pos /= 1) $ Prelude.fail "Not in first column"
771771 lns <- many1 $ birdTrackLine c
772772 -- if (as is normal) there is always a space after >, drop it
773773 let lns' = if all (\ln -> null ln || take 1 ln == " ") lns
src/Text/Pandoc/Readers/Muse.hs+2−2
@@ -496,7 +496,7 @@ amuseNoteBlockUntil end = try $ do
496496 ref <- noteMarker
497497 pos <- getPosition
498498 void spaceChar <|> lookAhead eol
499− (content, e) <- allowPara $ listItemContentsUntil (sourceColumn pos) (fail "x") end
499+ (content, e) <- allowPara $ listItemContentsUntil (sourceColumn pos) (Prelude.fail "x") end
500500 addNote ref pos content
501501 return (mempty, e)
502502
@@ -558,7 +558,7 @@ museOrderedListMarker style =
558558 LowerRoman -> lowerRoman
559559 UpperAlpha -> upperAlpha
560560 LowerAlpha -> lowerAlpha
561− _ -> fail "Unhandled case"
561+ _ -> Prelude.fail "Unhandled case"
562562
563563orderedListItemsUntil :: PandocMonad m
564564 => Int
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -312,7 +312,7 @@ doubleHeader' = try $ do
312312 txt <- trimInlines . mconcat <$> many1 (notFollowedBy blankline >> inline)
313313 pos <- getPosition
314314 let len = sourceColumn pos - 1
315− when (len > lenTop) $ fail "title longer than border"
315+ when (len > lenTop) $ Prelude.fail "title longer than border"
316316 blankline -- spaces and newline
317317 count lenTop (char c) -- the bottom line
318318 blanklines
src/Text/Pandoc/Readers/Roff.hs+3−3
@@ -180,7 +180,7 @@ resolveGlyph delimChar glyph = do
180180 '[' -> escUnknown ("\\[" ++ glyph ++ "]")
181181 '(' -> escUnknown ("\\(" ++ glyph)
182182 '\'' -> escUnknown ("\\C'" ++ glyph ++ "'")
183− _ -> fail "resolveGlyph: unknown glyph delimiter"
183+ _ -> Prelude.fail "resolveGlyph: unknown glyph delimiter"
184184
185185readUnicodeChar :: String -> Maybe Char
186186readUnicodeChar ('u':cs@(_:_:_:_:_)) =
@@ -562,7 +562,7 @@ resolveMacro macroName args pos = do
562562lexStringDef :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens
563563lexStringDef args = do -- string definition
564564 case args of
565− [] -> fail "No argument to .ds"
565+ [] -> Prelude.fail "No argument to .ds"
566566 (x:ys) -> do
567567 let ts = singleTok $ TextLine (intercalate [RoffStr " " ] ys)
568568 let stringName = linePartsToString x
@@ -578,7 +578,7 @@ lexMacroDef args = do -- macro definition
578578 (x : y : _) -> return (linePartsToString x, linePartsToString y)
579579 -- optional second arg
580580 (x:_) -> return (linePartsToString x, ".")
581− [] -> fail "No argument to .de"
581+ [] -> Prelude.fail "No argument to .de"
582582 let stop = try $ do
583583 char '.' <|> char '\''
584584 skipMany spacetab
src/Text/Pandoc/Readers/Textile.hs+1−1
@@ -484,7 +484,7 @@ note = try $ do
484484 ref <- char '[' *> many1 digit <* char ']'
485485 notes <- stateNotes <$> getState
486486 case lookup ref notes of
487− Nothing -> fail "note not found"
487+ Nothing -> Prelude.fail "note not found"
488488 Just raw -> B.note <$> parseFromString' parseBlocks raw
489489
490490-- | Special chars
src/Text/Pandoc/Translations.hs+3−3
@@ -71,7 +71,7 @@ newtype Translations = Translations (M.Map Term String)
7171instance FromJSON Term where
7272 parseJSON (String t) = case safeRead (T.unpack t) of
7373 Just t' -> pure t'
74− Nothing -> fail $ "Invalid Term name " ++
74+ Nothing -> Prelude.fail $ "Invalid Term name " ++
7575 show t
7676 parseJSON invalid = Aeson.typeMismatch "Term" invalid
7777
@@ -79,7 +79,7 @@ instance YAML.FromYAML Term where
7979 parseYAML (YAML.Scalar _ (YAML.SStr t)) =
8080 case safeRead (T.unpack t) of
8181 Just t' -> pure t'
82− Nothing -> fail $ "Invalid Term name " ++
82+ Nothing -> Prelude.fail $ "Invalid Term name " ++
8383 show t
8484 parseYAML invalid = YAML.typeMismatch "Term" invalid
8585
@@ -89,7 +89,7 @@ instance FromJSON Translations where
8989 return $ Translations (M.fromList xs)
9090 where addItem (k,v) =
9191 case safeRead (T.unpack k) of
92− Nothing -> fail $ "Invalid Term name " ++ show k
92+ Nothing -> Prelude.fail $ "Invalid Term name " ++ show k
9393 Just t ->
9494 case v of
9595 (String s) -> return (t, T.unpack $ T.strip s)
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -580,7 +580,7 @@ writeDocx opts doc@(Pandoc meta _) = do
580580 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
581581
582582 let entryFromArchive arch path =
583− maybe (fail $ path ++ " missing in reference docx")
583+ maybe (Prelude.fail $ path ++ " missing in reference docx")
584584 return
585585 (findEntryByPath path arch `mplus` findEntryByPath path distArchive)
586586 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
src/Text/Pandoc/Writers/HTML.hs+1−1
@@ -429,7 +429,7 @@ parseMailto s =
429429 let (name', rest) = span (/='@') addr
430430 let domain = drop 1 rest
431431 return (name', domain)
432− _ -> fail "not a mailto: URL"
432+ _ -> Prelude.fail "not a mailto: URL"
433433
434434-- | Obfuscate a "mailto:" link.
435435obfuscateLink :: PandocMonad m
src/Text/Pandoc/Writers/Muse.hs+3−3
@@ -607,7 +607,7 @@ inlineToMuse (Subscript lst) = do
607607 modify $ \st -> st { stUseTags = False }
608608 return $ "<sub>" <> contents <> "</sub>"
609609inlineToMuse SmallCaps {} =
610− fail "SmallCaps should be expanded before normalization"
610+ Prelude.fail "SmallCaps should be expanded before normalization"
611611inlineToMuse (Quoted SingleQuote lst) = do
612612 contents <- inlineListToMuse lst
613613 modify $ \st -> st { stUseTags = False }
@@ -617,7 +617,7 @@ inlineToMuse (Quoted DoubleQuote lst) = do
617617 modify $ \st -> st { stUseTags = False }
618618 return $ "“" <> contents <> "”"
619619inlineToMuse Cite {} =
620− fail "Citations should be expanded before normalization"
620+ Prelude.fail "Citations should be expanded before normalization"
621621inlineToMuse (Code _ str) = do
622622 useTags <- gets stUseTags
623623 modify $ \st -> st { stUseTags = False }
@@ -625,7 +625,7 @@ inlineToMuse (Code _ str) = do
625625 then "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
626626 else "=" <> text str <> "="
627627inlineToMuse Math{} =
628− fail "Math should be expanded before normalization"
628+ Prelude.fail "Math should be expanded before normalization"
629629inlineToMuse (RawInline (Format f) str) = do
630630 modify $ \st -> st { stUseTags = False }
631631 return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"
src/Text/Pandoc/Writers/OOXML.hs+2−2
@@ -54,9 +54,9 @@ parseXml :: (PandocMonad m) => Archive -> Archive -> String -> m Element
5454parseXml refArchive distArchive relpath =
5555 case findEntryByPath relpath refArchive `mplus`
5656 findEntryByPath relpath distArchive of
57− Nothing -> fail $ relpath ++ " missing in reference file"
57+ Nothing -> Prelude.fail $ relpath ++ " missing in reference file"
5858 Just e -> case parseXMLDoc . UTF8.toStringLazy . fromEntry $ e of
59− Nothing -> fail $ relpath ++ " corrupt in reference file"
59+ Nothing -> Prelude.fail $ relpath ++ " corrupt in reference file"
6060 Just d -> return d
6161
6262-- Copied from Util
src/Text/Pandoc/Writers/Powerpoint/Output.hs+1−1
@@ -173,7 +173,7 @@ copyFileToArchive arch fp = do
173173 refArchive <- asks envRefArchive
174174 distArchive <- asks envDistArchive
175175 case findEntryByPath fp refArchive `mplus` findEntryByPath fp distArchive of
176− Nothing -> fail $ fp ++ " missing in reference file"
176+ Nothing -> Prelude.fail $ fp ++ " missing in reference file"
177177 Just e -> return $ addEntryToArchive e arch
178178
179179alwaysInheritedPatterns :: [Pattern]