Make number parsing case-independent

This commit is contained in:
Tissevert 2020-08-26 11:40:09 +02:00
parent f56f5f9569
commit 28cfbde7ec
1 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ module Data.RomanNum (
, validate
) where
import Data.Char (toUpper)
import Data.Map (Map, (!))
import qualified Data.Map as Map (fromList)
import Text.Read (readMaybe)
@ -55,7 +56,7 @@ validate :: String -> Bool
validate = either (\_ -> False) (\_ -> True) . parse
readDigit :: Char -> Either String Int
readDigit c = maybe errMsg (Right . (values !)) $ readMaybe [c]
readDigit c = maybe errMsg (Right . (values !)) $ readMaybe [toUpper c]
where
errMsg = Left $ "Not a roman digit: «" ++ c:"»"