packages feed

extra 1.4.10 → 1.4.11

raw patch · 6 files changed

+29/−20 lines, 6 filesdep +clockdep ~QuickCheckPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: clock

Dependency ranges changed: QuickCheck

API changes (from Hackage documentation)

- Data.Typeable.Extra: Refl :: (:~:) k b b
- Extra: Refl :: (:~:) k b b
- System.Directory.Extra: withCurrentDirectory :: FilePath -> IO a -> IO a
+ Data.Tuple.Extra: infixr 3 &&&
+ Data.Typeable.Extra: [Refl] :: (:~:) k a a
+ Extra: [Refl] :: (:~:) k a a
+ Extra: infixr 3 &&&
- Data.Typeable.Extra: Proxy :: Proxy
+ Data.Typeable.Extra: Proxy :: Proxy k
- Data.Typeable.Extra: data (:~:) (a :: k) (b :: k) :: k -> k -> *
+ Data.Typeable.Extra: data (:~:) k (a :: k) (b :: k) :: forall k. k -> k -> *
- Data.Typeable.Extra: data Proxy (t :: k) :: k -> *
+ Data.Typeable.Extra: data Proxy k (t :: k) :: forall k. k -> *
- Extra: Proxy :: Proxy
+ Extra: Proxy :: Proxy k
- Extra: data (:~:) (a :: k) (b :: k) :: k -> k -> *
+ Extra: data (:~:) k (a :: k) (b :: k) :: forall k. k -> k -> *
- Extra: data Proxy (t :: k) :: k -> *
+ Extra: data Proxy k (t :: k) :: forall k. k -> *

Files

CHANGES.txt view
@@ -1,5 +1,10 @@ Changelog for Extra +1.4.11+    Require QuickCheck 2.9+    #23, deprecate offsetTimeIncrease and subtract+    #22, improve offsetTime to give reliable measurements+    Depend on the clock library 1.4.10     Add Data.Typeable.Extra containing typeRep, Proxy, (:~:) 1.4.9
README.md view
@@ -30,3 +30,5 @@ * base 4.6 == GHC 7.6 * base 4.5 == GHC 7.4 * base 4.4 == GHC 7.2++A more complete list can be found [here](https://wiki.haskell.org/Base_package#Versions).
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.10 build-type:         Simple name:               extra-version:            1.4.10+version:            1.4.11 license:            BSD3 license-file:       LICENSE category:           Development@@ -35,6 +35,7 @@         directory,         filepath,         process,+        clock >= 0.7,         time     if !os(windows)         build-depends: unix@@ -66,8 +67,9 @@         directory,         filepath,         extra,+        clock >= 0.7,         time,-        QuickCheck+        QuickCheck >= 2.9     if !os(windows)         build-depends: unix     hs-source-dirs: test
src/System/Time/Extra.hs view
@@ -15,6 +15,7 @@  import Control.Concurrent import Data.Time.Clock+import System.Clock import Numeric.Extra import Data.IORef import Control.Monad.Extra@@ -72,11 +73,11 @@                             (\_ -> fmap Just f))  +{-# DEPRECATED subtractTime "Function is being retired - use diffUTCTime directly." #-}+ -- | Calculate the difference between two times in seconds. --   Usually the first time will be the end of an event, and the --   second time will be the beginning.------ > \a b -> a > b ==> subtractTime a b > 0 subtractTime :: UTCTime -> UTCTime -> Seconds subtractTime end start = fromRational $ toRational $ end `diffUTCTime` start @@ -98,19 +99,21 @@             where (ms,ss) = round x `divMod` 60  --- | Call once to start, then call repeatedly to get the elapsed time since the first---   call. Values will usually increase, unless the system clock is updated---   (if you need the guarantee, see 'offsetTimeIncrease').+-- | Call once to start, then call repeatedly to get the elapsed time since the first call.+--   The time is guaranteed to be monotonic. This function is robust to system time changes.+--+-- > do f <- offsetTime; xs <- replicateM 10 f; return $ xs == sort xs offsetTime :: IO (IO Seconds) offsetTime = do-    start <- getCurrentTime+    start <- time     return $ do-        end <- getCurrentTime-        return $ end `subtractTime` start+        end <- time+        return $ 1e-9 * fromIntegral (toNanoSecs $ end - start)+    where time = getTime Monotonic --- | Like 'offsetTime', but results will never decrease (though they may stay the same).------ > do f <- offsetTimeIncrease; xs <- replicateM 10 f; return $ xs == sort xs+{-# DEPRECATED offsetTimeIncrease "Use offsetTime instead, which is guaranteed to always increase." #-}++-- | A synonym for 'offsetTime'. offsetTimeIncrease :: IO (IO Seconds) offsetTimeIncrease = do     t <- offsetTime@@ -120,6 +123,8 @@         atomicModifyIORef ref $ \o -> let m = max t o in m `seq` (m, m)  -- | Record how long a computation takes in 'Seconds'.+--+-- > do (a,_) <- duration $ sleep 1; return $ a >= 1 && a <= 1.1 duration :: IO a -> IO (Seconds, a) duration act = do     time <- offsetTime
test/TestGen.hs view
@@ -232,9 +232,9 @@     testGen "timeout 0.1  (print 1) == fmap Just (print 1)" $ timeout 0.1  (print 1) == fmap Just (print 1)     testGen "do (t, _) <- duration $ timeout 0.1 $ sleep 1000; print t; return $ t < 1" $ do (t, _) <- duration $ timeout 0.1 $ sleep 1000; print t; return $ t < 1     testGen "timeout 0.1  (sleep 2 >> print 1) == return Nothing" $ timeout 0.1  (sleep 2 >> print 1) == return Nothing-    testGen "\\a b -> a > b ==> subtractTime a b > 0" $ \a b -> a > b ==> subtractTime a b > 0     testGen "showDuration 3.435   == \"3.44s\"" $ showDuration 3.435   == "3.44s"     testGen "showDuration 623.8   == \"10m24s\"" $ showDuration 623.8   == "10m24s"     testGen "showDuration 62003.8 == \"17h13m\"" $ showDuration 62003.8 == "17h13m"     testGen "showDuration 1e8     == \"27777h47m\"" $ showDuration 1e8     == "27777h47m"-    testGen "do f <- offsetTimeIncrease; xs <- replicateM 10 f; return $ xs == sort xs" $ do f <- offsetTimeIncrease; xs <- replicateM 10 f; return $ xs == sort xs+    testGen "do f <- offsetTime; xs <- replicateM 10 f; return $ xs == sort xs" $ do f <- offsetTime; xs <- replicateM 10 f; return $ xs == sort xs+    testGen "do (a,_) <- duration $ sleep 1; return $ a >= 1 && a <= 1.1" $ do (a,_) <- duration $ sleep 1; return $ a >= 1 && a <= 1.1
test/TestUtil.hs view
@@ -70,11 +70,9 @@  instance Testable () where     property = property . (`seq` True)-    exhaustive _ = True  instance Testable a => Testable (IO a) where     property = property . unsafePerformIO-    exhaustive = exhaustive . unsafePerformIO  instance Eq a => Eq (IO a) where     a == b = unsafePerformIO $ do@@ -104,6 +102,3 @@  instance Arbitrary DiffTime where     arbitrary = fmap realToFrac $ choose (0 :: Double, 86401)--instance Arbitrary Version where-    arbitrary = makeVersion . map abs <$> listOf1 arbitrary