closed-intervals-0.2.1.0: Closed intervals of totally ordered types
Copyright(c) Lackmann Phymetric
LicenseGPL-3
Maintainerolaf.klinke@phymetric.de
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Interval.Time

Description

This module defines datatypes for closed intervals with end points on the UTCTime axis.

Synopsis

Time intervals of statically known length

data MinuteInterval (n :: Nat) Source #

Closed time intervals of statically known length in minutes. Although such intervals are completely determined by the end time of type ZonedTime that was used for construction, we cache lb and ub als lazy fields of type UTCTime to speed up Interval queries.

Since: 0.2.1

Instances

Instances details
Interval UTCTime (MinuteInterval n) Source # 
Instance details

Defined in Data.Interval.Time

Show (MinuteInterval 10) Source # 
Instance details

Defined in Data.Interval.Time

Show (MinuteInterval 15) Source # 
Instance details

Defined in Data.Interval.Time

Eq (MinuteInterval n) Source #

Time intervals of equal length are considered equal if they describe the same interval on the UTCTime axis, regardless of time zone.

Instance details

Defined in Data.Interval.Time

Ord (MinuteInterval n) Source #

Intervals of fixed length are ordered by their end time. Hence you can put them into a Set or use as keys in a Map.

Instance details

Defined in Data.Interval.Time

fromEndTime :: KnownNat n => Proxy n -> ZonedTime -> MinuteInterval n Source #

Smart constructor.

ub      (fromEndTime p z) == zonedTimeToUTC z
ubZoned (fromEndTime p z) == z

ubZoned :: MinuteInterval n -> ZonedTime Source #

Retrieve the upper bound that was used in construction, see fromEndTime.

Time intervals of length 10 minutes

type Min10 = MinuteInterval 10 Source #

Time intervals of length 10 minutes. In logging applications, aggregate values (e.g. averages, sums, ...) are often taken over a period of 10 minutes and associated with the time when the aggregation was computed.

To create your custom aggregate data type, pair this time interval with the aggregate value, like follows.

data SumOver10Minutes s = Aggregate {
 aggregateValue :: s,
 aggregatedOver :: Min10
 }

instance Interval UTCTime (SumOver10Minutes s) where 
 lb = lb.aggregatedOver
 ub = ub.aggregatedOver

compositeAggregate :: (Interval UTCTime i, Monoid s, Foldable f, IntersectionQuery f UTCTime t) =>
 i -> t (SumOver10Minutes s) -> s
compositeAggregate i = foldMap aggregateValue . getProperIntersects i

Since: 0.2.1

until10 :: ZonedTime -> Min10 Source #

smart constructor

Time intervals of length 15 minutes

type Min15 = MinuteInterval 15 Source #

Time intervals comprising quarter of an hour.

Since: 0.2.1

until15 :: ZonedTime -> Min15 Source #

smart constructor