Make number parsing case-independent
This commit is contained in:
parent
f56f5f9569
commit
28cfbde7ec
1 changed files with 2 additions and 1 deletions
|
@ -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:"»"
|
||||
|
||||
|
|
Loading…
Reference in a new issue