Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Interval a r
- fromRange :: Range (r :+ a) -> Interval a r
- toRange :: Interval a r -> Range (r :+ a)
- _Range :: Lens' (Interval a r) (Range (r :+ a))
- pattern OpenInterval :: (r :+ a) -> (r :+ a) -> Interval a r
- pattern ClosedInterval :: (r :+ a) -> (r :+ a) -> Interval a r
- pattern Interval :: EndPoint (r :+ a) -> EndPoint (r :+ a) -> Interval a r
- class HasStart t where
- type StartCore t
- type StartExtra t
- start :: Lens' t (StartCore t :+ StartExtra t)
- class HasEnd t where
- inInterval :: Ord r => r -> Interval a r -> Bool
- shiftLeft' :: Num r => r -> Interval a r -> Interval a r
- asProperInterval :: Ord r => Interval p r -> Interval p r
- flipInterval :: Interval a r -> Interval a r
- module Data.Range
1 dimensional Intervals
An Interval is essentially a Range
but with possible payload
We can think of an interval being defined as:
>>>
data Interval a r = Interval (EndPoint (r :+ a)) (EndPoint (r :+ a))
Instances
querying the start and end of intervals
class HasStart t where Source #
Instances
HasStart (Interval a r) Source # | |
HasStart (HalfLine d r) Source # | |
HasStart (LineSegment d p r) Source # | |
Defined in Data.Geometry.LineSegment type StartCore (LineSegment d p r) :: Type Source # type StartExtra (LineSegment d p r) :: Type Source # start :: Lens' (LineSegment d p r) (StartCore (LineSegment d p r) :+ StartExtra (LineSegment d p r)) Source # |
Instances
HasEnd (Interval a r) Source # | |
HasEnd (LineSegment d p r) Source # | |
Defined in Data.Geometry.LineSegment type EndCore (LineSegment d p r) :: Type Source # type EndExtra (LineSegment d p r) :: Type Source # end :: Lens' (LineSegment d p r) (EndCore (LineSegment d p r) :+ EndExtra (LineSegment d p r)) Source # |
Working with intervals
inInterval :: Ord r => r -> Interval a r -> Bool Source #
Test if a value lies in an interval. Note that the difference between inInterval and inRange is that the extra value is *not* used in the comparison with inInterval, whereas it is in inRange.
shiftLeft' :: Num r => r -> Interval a r -> Interval a r Source #
Shifts the interval to the left by delta
asProperInterval :: Ord r => Interval p r -> Interval p r Source #
Makes sure the start and endpoint are oriented such that the starting value is smaller than the ending value.
flipInterval :: Interval a r -> Interval a r Source #
Flips the start and endpoint of the interval.
module Data.Range