1- {-# LANGUAGE DeriveDataTypeable #-}
21{-# LANGUAGE DeriveGeneric #-}
32
43-----------------------------------------------------------------------------
@@ -58,8 +57,7 @@ import Control.Distributed.Process.Extras.Internal.Types
5857import Control.Monad (void )
5958import Data.Binary
6059import Data.Ratio ((%) )
61- import Data.Time.Clock
62- import Data.Typeable (Typeable )
60+ import Data.Time.Clock ( NominalDiffTime )
6361
6462import GHC.Generics
6563
@@ -69,22 +67,22 @@ import GHC.Generics
6967
7068-- | Defines the time unit for a Timeout value
7169data TimeUnit = Days | Hours | Minutes | Seconds | Millis | Micros
72- deriving (Typeable , Generic , Eq , Show )
70+ deriving (Generic , Eq , Show )
7371
7472instance Binary TimeUnit where
7573instance NFData TimeUnit where
7674
7775-- | A time interval.
7876data TimeInterval = TimeInterval TimeUnit Int
79- deriving (Typeable , Generic , Eq , Show )
77+ deriving (Generic , Eq , Show )
8078
8179instance Binary TimeInterval where
8280instance NFData TimeInterval where
8381
8482-- | Represents either a delay of 'TimeInterval', an infinite wait or no delay
8583-- (i.e., non-blocking).
8684data Delay = Delay TimeInterval | Infinity | NoDelay
87- deriving (Typeable , Generic , Eq , Show )
85+ deriving (Generic , Eq , Show )
8886
8987instance Binary Delay where
9088instance NFData Delay where
@@ -95,10 +93,9 @@ type Timeout = Maybe Int
9593
9694-- | Send to a process when a timeout expires.
9795data TimeoutNotification = TimeoutNotification Tag
98- deriving (Typeable )
9996
10097instance 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@
200197diffTimeToTimeInterval :: 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@
204201delayToDiffTime :: Delay -> NominalDiffTime
205202delayToDiffTime (Delay ti) = timeIntervalToDiffTime ti
206203delayToDiffTime 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@
210207diffTimeToDelay :: NominalDiffTime -> Delay
211208diffTimeToDelay dt = Delay $ diffTimeToTimeInterval dt
212209
213210-- | Create a 'NominalDiffTime' from a number of microseconds.
214211microsecondsToNominalDiffTime :: 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
0 commit comments