Avoid non-exhaustive pattern match.

This commit is contained in:
John MacFarlane
2018-08-10 15:56:43 -07:00
parent 6003c596d7
commit 65aea82a04
+5 -11
View File
@@ -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