on master help sign in
tighter Arbitary instance for TimeOfDay
commitbc8ad63da29ac14ecfc2eb17f3773087d0faa6e2 authorBen Weitzman <benweitzman@gmail.com> dateWed 2 Dec 2015, 11:52 (11 years ago) parent67214dd
1 file changed+4−4
tests/Instances.hs+4−4
tests/Instances.hs+4−4
@@ -30,10 +30,10 @@ instance (Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Map.Map k v) where
3030
3131instance Arbitrary TimeOfDay where
3232 arbitrary = do
33− Positive h <- arbitrary
34− Positive m <- arbitrary
35− Positive s <- arbitrary
36− return $ fromMaybe (TimeOfDay 0 0 0 ) (makeTimeOfDayValid h m s)
33+ h <- choose (0, 23)
34+ m <- choose (0, 59)
35+ s <- fromRational . toRational <$> choose (0, 59 :: Double)
36+ return $ TimeOfDay h m s
3737
3838instance Arbitrary LocalTime where
3939 arbitrary = LocalTime <$> arbitrary <*> arbitrary