mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Avoid non-exhaustive pattern match.
This commit is contained in:
@@ -514,22 +514,16 @@ charsInBalanced open close parser = try $ do
|
||||
|
||||
-- Auxiliary functions for romanNumeral:
|
||||
|
||||
lowercaseRomanDigits :: [Char]
|
||||
lowercaseRomanDigits = ['i','v','x','l','c','d','m']
|
||||
|
||||
uppercaseRomanDigits :: [Char]
|
||||
uppercaseRomanDigits = map toUpper lowercaseRomanDigits
|
||||
|
||||
-- | Parses a roman numeral (uppercase or lowercase), returns number.
|
||||
romanNumeral :: Stream s m Char => Bool -- ^ Uppercase if true
|
||||
-> ParserT s st m Int
|
||||
romanNumeral upperCase = do
|
||||
let romanDigits = if upperCase
|
||||
then uppercaseRomanDigits
|
||||
else lowercaseRomanDigits
|
||||
lookAhead $ oneOf romanDigits
|
||||
let [one, five, ten, fifty, hundred, fivehundred, thousand] =
|
||||
map char romanDigits
|
||||
map char $
|
||||
if upperCase
|
||||
then ['I','V','X','L','C','D','M']
|
||||
else ['i','v','x','l','c','d','m']
|
||||
lookAhead $ choice [one, five, ten, fifty, hundred, fivehundred, thousand]
|
||||
thousands <- ((1000 *) . length) <$> many thousand
|
||||
ninehundreds <- option 0 $ try $ hundred >> thousand >> return 900
|
||||
fivehundreds <- option 0 $ 500 <$ fivehundred
|
||||
|
||||
Reference in New Issue
Block a user