{-# LANGUAGE Trustworthy #-}
module Data.Time.Clock.Internal.NominalDiffTime
( NominalDiffTime
, secondsToNominalDiffTime
, nominalDiffTimeToSeconds
, nominalDay
) where
import Control.DeepSeq
import Data.Data
import Data.Fixed
import Text.ParserCombinators.ReadP
import Text.ParserCombinators.ReadPrec
import GHC.Read
newtype NominalDiffTime =
MkNominalDiffTime Pico
deriving (NominalDiffTime -> NominalDiffTime -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NominalDiffTime -> NominalDiffTime -> Bool
$c/= :: NominalDiffTime -> NominalDiffTime -> Bool
== :: NominalDiffTime -> NominalDiffTime -> Bool
$c== :: NominalDiffTime -> NominalDiffTime -> Bool
Eq, Eq NominalDiffTime
NominalDiffTime -> NominalDiffTime -> Bool
NominalDiffTime -> NominalDiffTime -> Ordering
NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
$cmin :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
max :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
$cmax :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
>= :: NominalDiffTime -> NominalDiffTime -> Bool
$c>= :: NominalDiffTime -> NominalDiffTime -> Bool
> :: NominalDiffTime -> NominalDiffTime -> Bool
$c> :: NominalDiffTime -> NominalDiffTime -> Bool
<= :: NominalDiffTime -> NominalDiffTime -> Bool
$c<= :: NominalDiffTime -> NominalDiffTime -> Bool
< :: NominalDiffTime -> NominalDiffTime -> Bool
$c< :: NominalDiffTime -> NominalDiffTime -> Bool
compare :: NominalDiffTime -> NominalDiffTime -> Ordering
$ccompare :: NominalDiffTime -> NominalDiffTime -> Ordering
Ord, Typeable NominalDiffTime
NominalDiffTime -> DataType
NominalDiffTime -> Constr
(forall b. Data b => b -> b) -> NominalDiffTime -> NominalDiffTime
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> NominalDiffTime -> u
forall u. (forall d. Data d => d -> u) -> NominalDiffTime -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NominalDiffTime
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NominalDiffTime -> c NominalDiffTime
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NominalDiffTime)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NominalDiffTime)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NominalDiffTime -> m NominalDiffTime
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> NominalDiffTime -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> NominalDiffTime -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NominalDiffTime -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NominalDiffTime -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r
gmapT :: (forall b. Data b => b -> b) -> NominalDiffTime -> NominalDiffTime
$cgmapT :: (forall b. Data b => b -> b) -> NominalDiffTime -> NominalDiffTime
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NominalDiffTime)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NominalDiffTime)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NominalDiffTime)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NominalDiffTime)
dataTypeOf :: NominalDiffTime -> DataType
$cdataTypeOf :: NominalDiffTime -> DataType
toConstr :: NominalDiffTime -> Constr
$ctoConstr :: NominalDiffTime -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NominalDiffTime
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NominalDiffTime
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NominalDiffTime -> c NominalDiffTime
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NominalDiffTime -> c NominalDiffTime
Data, Typeable)
secondsToNominalDiffTime :: Pico -> NominalDiffTime
secondsToNominalDiffTime :: Pico -> NominalDiffTime
secondsToNominalDiffTime = Pico -> NominalDiffTime
MkNominalDiffTime
nominalDiffTimeToSeconds :: NominalDiffTime -> Pico
nominalDiffTimeToSeconds :: NominalDiffTime -> Pico
nominalDiffTimeToSeconds (MkNominalDiffTime Pico
t) = Pico
t
instance NFData NominalDiffTime where
rnf :: NominalDiffTime -> ()
rnf (MkNominalDiffTime Pico
t) = forall a. NFData a => a -> ()
rnf Pico
t
instance Enum NominalDiffTime where
succ :: NominalDiffTime -> NominalDiffTime
succ (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> a
succ Pico
a)
pred :: NominalDiffTime -> NominalDiffTime
pred (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> a
pred Pico
a)
toEnum :: Int -> NominalDiffTime
toEnum = Pico -> NominalDiffTime
MkNominalDiffTime forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum
fromEnum :: NominalDiffTime -> Int
fromEnum (MkNominalDiffTime Pico
a) = forall a. Enum a => a -> Int
fromEnum Pico
a
enumFrom :: NominalDiffTime -> [NominalDiffTime]
enumFrom (MkNominalDiffTime Pico
a) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> [a]
enumFrom Pico
a)
enumFromThen :: NominalDiffTime -> NominalDiffTime -> [NominalDiffTime]
enumFromThen (MkNominalDiffTime Pico
a) (MkNominalDiffTime Pico
b) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> a -> [a]
enumFromThen Pico
a Pico
b)
enumFromTo :: NominalDiffTime -> NominalDiffTime -> [NominalDiffTime]
enumFromTo (MkNominalDiffTime Pico
a) (MkNominalDiffTime Pico
b) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> a -> [a]
enumFromTo Pico
a Pico
b)
enumFromThenTo :: NominalDiffTime
-> NominalDiffTime -> NominalDiffTime -> [NominalDiffTime]
enumFromThenTo (MkNominalDiffTime Pico
a) (MkNominalDiffTime Pico
b) (MkNominalDiffTime Pico
c) =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo Pico
a Pico
b Pico
c)
instance Show NominalDiffTime where
show :: NominalDiffTime -> String
show (MkNominalDiffTime Pico
t) = (forall {k} (a :: k). HasResolution a => Bool -> Fixed a -> String
showFixed Bool
True Pico
t) forall a. [a] -> [a] -> [a]
++ String
"s"
instance Read NominalDiffTime where
readPrec :: ReadPrec NominalDiffTime
readPrec = do
Pico
t <- forall a. Read a => ReadPrec a
readPrec
Char
_ <- forall a. ReadP a -> ReadPrec a
lift forall a b. (a -> b) -> a -> b
$ Char -> ReadP Char
char Char
's'
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Pico -> NominalDiffTime
MkNominalDiffTime Pico
t
instance Num NominalDiffTime where
(MkNominalDiffTime Pico
a) + :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
+ (MkNominalDiffTime Pico
b) = Pico -> NominalDiffTime
MkNominalDiffTime (Pico
a forall a. Num a => a -> a -> a
+ Pico
b)
(MkNominalDiffTime Pico
a) - :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
- (MkNominalDiffTime Pico
b) = Pico -> NominalDiffTime
MkNominalDiffTime (Pico
a forall a. Num a => a -> a -> a
- Pico
b)
(MkNominalDiffTime Pico
a) * :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
* (MkNominalDiffTime Pico
b) = Pico -> NominalDiffTime
MkNominalDiffTime (Pico
a forall a. Num a => a -> a -> a
* Pico
b)
negate :: NominalDiffTime -> NominalDiffTime
negate (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Num a => a -> a
negate Pico
a)
abs :: NominalDiffTime -> NominalDiffTime
abs (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Num a => a -> a
abs Pico
a)
signum :: NominalDiffTime -> NominalDiffTime
signum (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Num a => a -> a
signum Pico
a)
fromInteger :: Integer -> NominalDiffTime
fromInteger Integer
i = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Num a => Integer -> a
fromInteger Integer
i)
instance Real NominalDiffTime where
toRational :: NominalDiffTime -> Rational
toRational (MkNominalDiffTime Pico
a) = forall a. Real a => a -> Rational
toRational Pico
a
instance Fractional NominalDiffTime where
(MkNominalDiffTime Pico
a) / :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime
/ (MkNominalDiffTime Pico
b) = Pico -> NominalDiffTime
MkNominalDiffTime (Pico
a forall a. Fractional a => a -> a -> a
/ Pico
b)
recip :: NominalDiffTime -> NominalDiffTime
recip (MkNominalDiffTime Pico
a) = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Fractional a => a -> a
recip Pico
a)
fromRational :: Rational -> NominalDiffTime
fromRational Rational
r = Pico -> NominalDiffTime
MkNominalDiffTime (forall a. Fractional a => Rational -> a
fromRational Rational
r)
instance RealFrac NominalDiffTime where
properFraction :: forall b. Integral b => NominalDiffTime -> (b, NominalDiffTime)
properFraction (MkNominalDiffTime Pico
a) = (b
i, Pico -> NominalDiffTime
MkNominalDiffTime Pico
f)
where
(b
i, Pico
f) = forall a b. (RealFrac a, Integral b) => a -> (b, a)
properFraction Pico
a
truncate :: forall b. Integral b => NominalDiffTime -> b
truncate (MkNominalDiffTime Pico
a) = forall a b. (RealFrac a, Integral b) => a -> b
truncate Pico
a
round :: forall b. Integral b => NominalDiffTime -> b
round (MkNominalDiffTime Pico
a) = forall a b. (RealFrac a, Integral b) => a -> b
round Pico
a
ceiling :: forall b. Integral b => NominalDiffTime -> b
ceiling (MkNominalDiffTime Pico
a) = forall a b. (RealFrac a, Integral b) => a -> b
ceiling Pico
a
floor :: forall b. Integral b => NominalDiffTime -> b
floor (MkNominalDiffTime Pico
a) = forall a b. (RealFrac a, Integral b) => a -> b
floor Pico
a
{-# RULES
"realToFrac/DiffTime->NominalDiffTime" realToFrac =
\ dt -> MkNominalDiffTime (realToFrac dt)
"realToFrac/NominalDiffTime->DiffTime" realToFrac =
\ (MkNominalDiffTime ps) -> realToFrac ps
"realToFrac/NominalDiffTime->Pico" realToFrac =
\ (MkNominalDiffTime ps) -> ps
"realToFrac/Pico->NominalDiffTime" realToFrac = MkNominalDiffTime
#-}
nominalDay :: NominalDiffTime
nominalDay :: NominalDiffTime
nominalDay = NominalDiffTime
86400