Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines the TimeDomain
class.
Its instances model time,
simulated and realtime.
Several instances such as UTCTime
, Double
and Integer
are supplied here.
Synopsis
- newtype NumTimeDomain a = NumTimeDomain {
- fromNumTimeDomain :: a
- class TimeDifference d where
- difference :: d -> d -> d
- add :: d -> d -> d
- class TimeDifference (Diff time) => TimeDomain time where
- data UTCTime
Documentation
newtype NumTimeDomain a Source #
Any Num
can be wrapped to form a TimeDomain
.
Instances
Num a => Num (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain (+) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (-) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (*) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # negate :: NumTimeDomain a -> NumTimeDomain a # abs :: NumTimeDomain a -> NumTimeDomain a # signum :: NumTimeDomain a -> NumTimeDomain a # fromInteger :: Integer -> NumTimeDomain a # | |
Num a => TimeDifference (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a Source # add :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a Source # | |
Num a => TimeDomain (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) Source # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) Source # addTime :: NumTimeDomain a -> Diff (NumTimeDomain a) -> NumTimeDomain a Source # | |
type Diff (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain |
class TimeDifference d where Source #
A type of durations, or differences betweens time stamps.
Expected laws:
add
is commutative and associative(dt1
difference
dt2)add
dt2 = dt1
difference :: d -> d -> d Source #
Calculate the difference between two durations,
compatibly with diffTime
.
Add two time differences.
Instances
TimeDifference Integer Source # | |
TimeDifference () Source # | |
Defined in Data.TimeDomain | |
TimeDifference Double Source # | |
TimeDifference Float Source # | |
Num a => TimeDifference (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a Source # add :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a Source # |
class TimeDifference (Diff time) => TimeDomain time where Source #
A time domain is an affine space representing a notion of time, such as real time, simulated time, steps, or a completely different notion.
Expected laws:
diffTime :: time -> time -> Diff time Source #
Compute the difference between two timestamps.
Mnemonic: diffTime
behaves like the (-)
operator:
is the duration it takes from diffTime
earlier later = later `diffTime
` earlierearlier
to later
.
addTime :: time -> Diff time -> time Source #
Add a time difference to a timestamp.
Instances
TimeDomain UTCTime Source # | Differences between |
TimeDomain Integer Source # | |
TimeDomain () Source # | |
TimeDomain Double Source # | |
TimeDomain Float Source # | |
Num a => TimeDomain (NumTimeDomain a) Source # | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) Source # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) Source # addTime :: NumTimeDomain a -> Diff (NumTimeDomain a) -> NumTimeDomain a Source # |
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Instances
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime # toConstr :: UTCTime -> Constr # dataTypeOf :: UTCTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
TimeDomain UTCTime Source # | Differences between |
type Diff UTCTime Source # | |
Defined in Data.TimeDomain |