Maintainer | Toshio Ito <toshio9.ito@toshiba.co.jp> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Re-exports of Interval
type and additional utility.
Since: 0.3.2.0
Synopsis
- data Interval r
- data Extended r
- (<=..<=) :: Ord r => Extended r -> Extended r -> Interval r
- (<..<=) :: Ord r => Extended r -> Extended r -> Interval r
- (<=..<) :: Ord r => Extended r -> Extended r -> Interval r
- (<..<) :: Ord r => Extended r -> Extended r -> Interval r
- type IntervalEnd a = (Extended a, Bool)
- type ErrorMsg = String
- interval :: Ord r => IntervalEnd r -> IntervalEnd r -> Interval r
- lowerBound' :: Interval r -> IntervalEnd r
- upperBound' :: Interval r -> IntervalEnd r
- parseTimeIntervalEnd :: String -> Either ErrorMsg (IntervalEnd Timestamp)
- parseIntervalEnd :: (String -> Either ErrorMsg a) -> String -> Either ErrorMsg (IntervalEnd a)
- secUpTo :: Int64 -> Timestamp -> Interval Timestamp
- secSince :: Int64 -> IntervalEnd Timestamp -> Interval Timestamp
- secUntil :: Int64 -> IntervalEnd Timestamp -> Interval Timestamp
Re-exports
The intervals (i.e. connected and convex subsets) over real numbers R.
Instances
Eq r => Eq (Interval r) | |
(Ord r, Data r) => Data (Interval r) | |
Defined in Data.Interval.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Interval r -> c (Interval r) # gunfold :: (forall b r0. Data b => c (b -> r0) -> c r0) -> (forall r1. r1 -> c r1) -> Constr -> c (Interval r) # toConstr :: Interval r -> Constr # dataTypeOf :: Interval r -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Interval r)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Interval r)) # gmapT :: (forall b. Data b => b -> b) -> Interval r -> Interval r # gmapQl :: (r0 -> r' -> r0) -> r0 -> (forall d. Data d => d -> r') -> Interval r -> r0 # gmapQr :: (r' -> r0 -> r0) -> r0 -> (forall d. Data d => d -> r') -> Interval r -> r0 # gmapQ :: (forall d. Data d => d -> u) -> Interval r -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Interval r -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Interval r -> m (Interval r) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Interval r -> m (Interval r) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Interval r -> m (Interval r) # | |
Hashable r => Hashable (Interval r) | |
Defined in Data.Interval.Internal | |
NFData r => NFData (Interval r) | |
Defined in Data.Interval.Internal |
Extended r
is an extension of r with positive/negative infinity (±∞).
Instances
Functor Extended | |
Bounded (Extended r) | |
Eq r => Eq (Extended r) | |
(Fractional r, Ord r) => Fractional (Extended r) | Note that |
Data r => Data (Extended r) | |
Defined in Data.ExtendedReal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Extended r -> c (Extended r) # gunfold :: (forall b r0. Data b => c (b -> r0) -> c r0) -> (forall r1. r1 -> c r1) -> Constr -> c (Extended r) # toConstr :: Extended r -> Constr # dataTypeOf :: Extended r -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Extended r)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Extended r)) # gmapT :: (forall b. Data b => b -> b) -> Extended r -> Extended r # gmapQl :: (r0 -> r' -> r0) -> r0 -> (forall d. Data d => d -> r') -> Extended r -> r0 # gmapQr :: (r' -> r0 -> r0) -> r0 -> (forall d. Data d => d -> r') -> Extended r -> r0 # gmapQ :: (forall d. Data d => d -> u) -> Extended r -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Extended r -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Extended r -> m (Extended r) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Extended r -> m (Extended r) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Extended r -> m (Extended r) # | |
(Num r, Ord r) => Num (Extended r) | Note that
|
Defined in Data.ExtendedReal | |
Ord r => Ord (Extended r) | |
Read r => Read (Extended r) | |
Show r => Show (Extended r) | |
Hashable r => Hashable (Extended r) | |
Defined in Data.ExtendedReal | |
NFData r => NFData (Extended r) | |
Defined in Data.ExtendedReal |
closed interval [l
,u
]
left-open right-closed interval (l
,u
]
left-closed right-open interval [l
, u
)
open interval (l
, u
)
Types
type IntervalEnd a = (Extended a, Bool) Source #
Basic operations
:: Ord r | |
=> IntervalEnd r | lower bound |
-> IntervalEnd r | upper bound |
-> Interval r |
Make an Interval
from lower and upper bounds.
lowerBound' :: Interval r -> IntervalEnd r Source #
Get the lower bound.
upperBound' :: Interval r -> IntervalEnd r Source #
Get the upper bound.
Parsers
parseTimeIntervalEnd :: String -> Either ErrorMsg (IntervalEnd Timestamp) Source #
Parse the String
into an end of time interval. It uses
parseIntervalEnd
.
If the String
is prefixed with 'i', the end is inclusive. If
the prefix is 'x', the end is exclusive. Without such prefix,
the end is inclusive by default.
Timestamp is parsed by parseTimestamp
. Positive infinity is
expressed as '+inf' (note that '+' is mandatory), and
negative infinity as '-inf'.
>>>
parseTimeIntervalEnd "2019-10-09T12:03:22"
Right (Finite (Timestamp {epochTime = 1570622602000, timeZone = Nothing}),True)>>>
parseTimeIntervalEnd "i2019-10-09T12:03:22"
Right (Finite (Timestamp {epochTime = 1570622602000, timeZone = Nothing}),True)>>>
parseTimeIntervalEnd "x2019-10-09T12:03:22"
Right (Finite (Timestamp {epochTime = 1570622602000, timeZone = Nothing}),False)>>>
parseTimeIntervalEnd "+inf"
Right (PosInf,True)>>>
parseTimeIntervalEnd "i+inf"
Right (PosInf,True)>>>
parseTimeIntervalEnd "x+inf"
Right (PosInf,False)>>>
parseTimeIntervalEnd "-inf"
Right (NegInf,True)>>>
parseTimeIntervalEnd "i-inf"
Right (NegInf,True)>>>
parseTimeIntervalEnd "x-inf"
Right (NegInf,False)
Since: 0.3.2.0
:: (String -> Either ErrorMsg a) | parser for the type variable |
-> String | input to be parsed |
-> Either ErrorMsg (IntervalEnd a) |
Parse the String
into IntervalEnd
a
, with the
user-supplied parser for a
. See parseTimeIntervalEnd
for
example.
Since: 0.3.2.0
Utility
secUpTo :: Int64 -> Timestamp -> Interval Timestamp Source #
s
returns the time interval of length secUpTo
tss
(in
seconds) and up to ts
. The interval is inclusive for both ends.
Since: 0.2.0.0
:: Int64 | duration in seconds |
-> IntervalEnd Timestamp | the start of the interval |
-> Interval Timestamp |
d
returns the time interval of length secSince
tsd
seconds
from the timestamp ts
. If ts
is inclusive (exclusive), the end
of the interval is exclusive (inclusive), respectively.
>>>
60 `secSince` (Finite $ fromEpochMillisecond 1000, True)
Finite (Timestamp {epochTime = 1000, timeZone = Nothing}) <=..< Finite (Timestamp {epochTime = 61000, timeZone = Nothing})>>>
60 `secSince` (Finite $ fromEpochMillisecond 1000, False)
Finite (Timestamp {epochTime = 1000, timeZone = Nothing}) <..<= Finite (Timestamp {epochTime = 61000, timeZone = Nothing})>>>
60 `secSince` (PosInf, False)
empty>>>
60 `secSince` (NegInf, False)
empty
Since: 0.3.3.0
:: Int64 | duration in seconds |
-> IntervalEnd Timestamp | the end of the interval |
-> Interval Timestamp |
d
returns the time interval of length secUntil
tsd
seconds
up to the timestamp ts
. If ts
is inclusive (exclusive), the
start of the interval is exclusive (inclusive), respectively.
>>>
60 `secUntil` (Finite $ fromEpochMillisecond 150000, True)
Finite (Timestamp {epochTime = 90000, timeZone = Nothing}) <..<= Finite (Timestamp {epochTime = 150000, timeZone = Nothing})>>>
60 `secUntil` (Finite $ fromEpochMillisecond 150000, False)
Finite (Timestamp {epochTime = 90000, timeZone = Nothing}) <=..< Finite (Timestamp {epochTime = 150000, timeZone = Nothing})>>>
60 `secUntil` (PosInf, False)
empty>>>
60 `secUntil` (NegInf, False)
empty
Since: 0.3.3.0