diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index dffe8f94..51b6b5b8 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -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 diff --git a/yesod-form/test/main.hs b/yesod-form/test/main.hs index 42581522..eed2a71f 100644 --- a/yesod-form/test/main.hs +++ b/yesod-form/test/main.hs @@ -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) ]