From 8d866e5f2d1199e4c7b095231568e43f50d472b6 Mon Sep 17 00:00:00 2001 From: Piotr Paradzinski Date: Tue, 12 May 2026 11:52:02 +0200 Subject: [PATCH 1/2] replace getPOSIXTime with getMonotonicTimeNSec --- HTF.cabal | 3 +-- Test/Framework/Utils.hs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/HTF.cabal b/HTF.cabal index a29a942..33c989f 100644 --- a/HTF.cabal +++ b/HTF.cabal @@ -131,7 +131,7 @@ Library QuickCheck >= 2.3, aeson >= 0.11, array, - base >= 4.10 && < 5, + base >= 4.11 && < 5, base64-bytestring, bytestring >= 0.9, containers >= 0.5, @@ -146,7 +146,6 @@ Library random >= 1.0, regex-compat >= 0.92, text >= 0.11, - time >= 1.8 && < 1.15, time, vector, xmlgen >= 0.6 diff --git a/Test/Framework/Utils.hs b/Test/Framework/Utils.hs index 9dffb3a..a360fd7 100644 --- a/Test/Framework/Utils.hs +++ b/Test/Framework/Utils.hs @@ -22,7 +22,7 @@ module Test.Framework.Utils where import System.Directory import Data.Char -import Data.Time.Clock.POSIX (getPOSIXTime) +import GHC.Clock (getMonotonicTimeNSec) import System.Random import Data.Array.IO import Control.Monad @@ -150,8 +150,7 @@ measure ma = return (a, fromInteger (diffMicro `div` 1000)) getMicroTime :: IO Integer -getMicroTime = - floor . (* 1000000) <$> getPOSIXTime +getMicroTime = (`div` 1000) . fromIntegral <$> getMonotonicTimeNSec -- | Randomly shuffle a list -- /O(N)/ From ccf3dfcaa5ed58b2188db36a1eb8d6376f913a3b Mon Sep 17 00:00:00 2001 From: Piotr Paradzinski Date: Tue, 12 May 2026 12:32:16 +0200 Subject: [PATCH 2/2] CPP fallback for `base < 4.11`, where `GHC.Clock.getMonotonicTimeNSec` is not available --- HTF.cabal | 2 +- Test/Framework/Utils.hs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/HTF.cabal b/HTF.cabal index 33c989f..fdea512 100644 --- a/HTF.cabal +++ b/HTF.cabal @@ -131,7 +131,7 @@ Library QuickCheck >= 2.3, aeson >= 0.11, array, - base >= 4.11 && < 5, + base >= 4.10 && < 5, base64-bytestring, bytestring >= 0.9, containers >= 0.5, diff --git a/Test/Framework/Utils.hs b/Test/Framework/Utils.hs index a360fd7..e46dccb 100644 --- a/Test/Framework/Utils.hs +++ b/Test/Framework/Utils.hs @@ -22,7 +22,11 @@ module Test.Framework.Utils where import System.Directory import Data.Char +#if MIN_VERSION_base(4,11,0) import GHC.Clock (getMonotonicTimeNSec) +#else +import Data.Time.Clock.POSIX (getPOSIXTime) +#endif import System.Random import Data.Array.IO import Control.Monad @@ -150,7 +154,13 @@ measure ma = return (a, fromInteger (diffMicro `div` 1000)) getMicroTime :: IO Integer -getMicroTime = (`div` 1000) . fromIntegral <$> getMonotonicTimeNSec +#if MIN_VERSION_base(4,11,0) +getMicroTime = + (`div` 1000) . fromIntegral <$> getMonotonicTimeNSec +#else +getMicroTime = + floor . (* 1000000) <$> getPOSIXTime +#endif -- | Randomly shuffle a list -- /O(N)/