Fix for missing Read instance on Fixed

This commit is contained in:
Michael Snoyman 2012-07-14 21:54:52 +03:00
parent d6f8ec8883
commit b4d1b2087c
2 changed files with 5 additions and 5 deletions

View File

@ -278,7 +278,7 @@ timeParser = do
if i < 0 || i >= 24
then fail $ show $ MsgInvalidHour $ pack xy
else return i
minsec :: (Num a, Read a, Ord a) => (Text -> FormMessage) -> Parser a
minsec :: Num a => (Text -> FormMessage) -> Parser a
minsec msg = do
x <- digit
y <- digit <|> fail (show $ msg $ pack [x])
@ -286,7 +286,7 @@ timeParser = do
let i = read xy
if i < 0 || i >= 60
then fail $ show $ msg $ pack xy
else return i
else return $ fromIntegral (i :: Int)
emailField :: RenderMessage master FormMessage => Field sub master Text
emailField = Field

View File

@ -31,11 +31,11 @@ main = hspec $
, ("12:00am", Right $ TimeOfDay 0 0 0)
, ("12:59:59am", Right $ TimeOfDay 0 59 59)
, ("12:59:60am", Left $ MsgInvalidSecond "60")
, ("12:60:59am", Left $ MsgInvalidMinute "60)
, ("12:60:59am", Left $ MsgInvalidMinute "60")
, ("12:00pm", Right $ TimeOfDay 12 0 0)
, ("12:59:59pm", Right $ TimeOfDay 12 59 59)
, ("12:59:60pm", Right $ MsgInvalidSecond "60")
, ("12:60:59pm", Right $ MsgInvalidMinute "60")
, ("12:59:60pm", Left $ MsgInvalidSecond "60")
, ("12:60:59pm", Left $ MsgInvalidMinute "60")
, ("12:7pm", Left $ MsgInvalidMinute "7")
, ("23:47", Right $ TimeOfDay 23 47 0)
]