Skip to content

Commit 3ce387b

Browse files
committed
Add support for time-1.15 and time-1.16 in distributed-process-extras (haskell-distributed#498)
1 parent f40e190 commit 3ce387b

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

‎packages/distributed-process-extras/ChangeLog‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Unreleased
1+
2026-10-22 Laurent P. René de Cotret <laurent.decotret@outlook.com> 0.3.10
22

3+
* Added support for `time-1.15` and `time-1.16`.
34
* Added support for `containers-0.8`.
45

56
2025-02-04 Laurent P. René de Cotret <laurent.decotret@outlook.com> 0.3.9

‎packages/distributed-process-extras/distributed-process-extras.cabal‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: distributed-process-extras
3-
version: 0.3.9
3+
version: 0.3.10
44
build-type: Simple
55
license: BSD-3-Clause
66
license-file: LICENCE
@@ -45,7 +45,7 @@ library
4545
unordered-containers >= 0.2.3.0 && < 0.3,
4646
fingertree < 0.2,
4747
stm >= 2.4 && < 2.6,
48-
time >= 1.5
48+
time >= 1.5 && < 1.17
4949
other-extensions: ExistentialQuantification
5050
HS-Source-Dirs: src
5151
exposed-modules:

‎packages/distributed-process-extras/src/Control/Distributed/Process/Extras/Time.hs‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE DeriveDataTypeable #-}
21
{-# LANGUAGE DeriveGeneric #-}
32

43
-----------------------------------------------------------------------------
@@ -58,8 +57,7 @@ import Control.Distributed.Process.Extras.Internal.Types
5857
import Control.Monad (void)
5958
import Data.Binary
6059
import Data.Ratio ((%))
61-
import Data.Time.Clock
62-
import Data.Typeable (Typeable)
60+
import Data.Time.Clock ( NominalDiffTime )
6361

6462
import GHC.Generics
6563

@@ -69,22 +67,22 @@ import GHC.Generics
6967

7068
-- | Defines the time unit for a Timeout value
7169
data TimeUnit = Days | Hours | Minutes | Seconds | Millis | Micros
72-
deriving (Typeable, Generic, Eq, Show)
70+
deriving (Generic, Eq, Show)
7371

7472
instance Binary TimeUnit where
7573
instance NFData TimeUnit where
7674

7775
-- | A time interval.
7876
data TimeInterval = TimeInterval TimeUnit Int
79-
deriving (Typeable, Generic, Eq, Show)
77+
deriving (Generic, Eq, Show)
8078

8179
instance Binary TimeInterval where
8280
instance NFData TimeInterval where
8381

8482
-- | Represents either a delay of 'TimeInterval', an infinite wait or no delay
8583
-- (i.e., non-blocking).
8684
data Delay = Delay TimeInterval | Infinity | NoDelay
87-
deriving (Typeable, Generic, Eq, Show)
85+
deriving (Generic, Eq, Show)
8886

8987
instance Binary Delay where
9088
instance NFData Delay where
@@ -95,10 +93,9 @@ type Timeout = Maybe Int
9593

9694
-- | Send to a process when a timeout expires.
9795
data TimeoutNotification = TimeoutNotification Tag
98-
deriving (Typeable)
9996

10097
instance Binary TimeoutNotification where
101-
get = fmap TimeoutNotification $ get
98+
get = fmap TimeoutNotification get
10299
put (TimeoutNotification n) = put n
103100

104101
-- time interval/unit handling
@@ -198,21 +195,21 @@ timeIntervalToDiffTime ti = microsecondsToNominalDiffTime (fromIntegral $ asTime
198195

199196
-- | given a @NominalDiffTim@@, provide an equivalent @TimeInterval@
200197
diffTimeToTimeInterval :: NominalDiffTime -> TimeInterval
201-
diffTimeToTimeInterval dt = microSeconds $ (fromIntegral (round (dt * 1000000) :: Integer))
198+
diffTimeToTimeInterval dt = microSeconds (fromIntegral (round (dt * 1000000) :: Integer))
202199

203200
-- | given a @Delay@, provide an equivalent @NominalDiffTim@
204201
delayToDiffTime :: Delay -> NominalDiffTime
205202
delayToDiffTime (Delay ti) = timeIntervalToDiffTime ti
206203
delayToDiffTime Infinity = error "trying to convert Delay.Infinity to a NominalDiffTime"
207-
delayToDiffTime (NoDelay) = microsecondsToNominalDiffTime 0
204+
delayToDiffTime NoDelay = microsecondsToNominalDiffTime 0
208205

209206
-- | given a @NominalDiffTim@@, provide an equivalent @Delay@
210207
diffTimeToDelay :: NominalDiffTime -> Delay
211208
diffTimeToDelay dt = Delay $ diffTimeToTimeInterval dt
212209

213210
-- | Create a 'NominalDiffTime' from a number of microseconds.
214211
microsecondsToNominalDiffTime :: Integer -> NominalDiffTime
215-
microsecondsToNominalDiffTime x = fromRational (x % (fromIntegral microSecondsPerSecond))
212+
microsecondsToNominalDiffTime x = fromRational (x % fromIntegral microSecondsPerSecond)
216213

217214
-- tenYearsAsMicroSeconds :: Integer
218215
-- tenYearsAsMicroSeconds = 10 * 365 * 24 * 60 * 60 * 1000000
@@ -223,10 +220,10 @@ instance Num TimeInterval where
223220
t1 - t2 = microSeconds $ asTimeout t1 - asTimeout t2
224221
_ * _ = error "trying to multiply two TimeIntervals"
225222
abs t = microSeconds $ abs (asTimeout t)
226-
signum t = if (asTimeout t) == 0
227-
then 0
228-
else if (asTimeout t) < 0 then -1
229-
else 1
223+
signum t
224+
| asTimeout t == 0 = 0
225+
| asTimeout t < 0 = -1
226+
| otherwise = 1
230227
fromInteger _ = error "trying to call fromInteger for a TimeInterval. Cannot guess units"
231228

232229
-- | Allow @(+)@ and @(-)@ operations on @Delay@s
@@ -249,7 +246,7 @@ instance Num Delay where
249246
abs Infinity = Infinity
250247
abs (Delay t) = Delay (abs t)
251248

252-
signum (NoDelay) = 0
249+
signum NoDelay = 0
253250
signum Infinity = 1
254251
signum (Delay t) = Delay (signum t)
255252

‎packages/distributed-process/distributed-process.cabal‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Library
6262
exceptions >= 0.10,
6363
containers >= 0.6 && < 0.9,
6464
deepseq >= 1.4 && < 1.7,
65-
time >= 1.9
65+
time >= 1.9 && <1.17
6666
Exposed-modules: Control.Distributed.Process
6767
Control.Distributed.Process.Closure
6868
Control.Distributed.Process.Debug

0 commit comments

Comments
 (0)