Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data EndPoint a
- isOpen :: EndPoint a -> Bool
- isClosed :: EndPoint a -> Bool
- unEndPoint :: Lens (EndPoint a) (EndPoint b) a b
- data Range a = Range {}
- prettyShow :: Show a => Range a -> String
- lower :: forall a. Lens' (Range a) (EndPoint a)
- upper :: forall a. Lens' (Range a) (EndPoint a)
- pattern OpenRange :: forall a. a -> a -> Range a
- pattern ClosedRange :: forall a. a -> a -> Range a
- pattern Range' :: forall a. a -> a -> Range a
- inRange :: Ord a => a -> Range a -> Bool
- width :: Num r => Range r -> r
- clipLower :: Ord a => EndPoint a -> Range a -> Maybe (Range a)
- clipUpper :: Ord a => EndPoint a -> Range a -> Maybe (Range a)
- midPoint :: Fractional r => Range r -> r
- isValid :: Ord a => Range a -> Bool
- covers :: Ord a => Range a -> Range a -> Bool
- shiftLeft :: Num r => r -> Range r -> Range r
- shiftRight :: Num r => r -> Range r -> Range r
Documentation
Functor EndPoint Source # | |
Foldable EndPoint Source # | |
Traversable EndPoint Source # | |
Eq a => Eq (EndPoint a) Source # | |
Ord a => Ord (EndPoint a) Source # | |
Read a => Read (EndPoint a) Source # | |
Show a => Show (EndPoint a) Source # | |
Generic (EndPoint a) Source # | |
NFData a => NFData (EndPoint a) Source # | |
type Rep (EndPoint a) Source # | |
Functor Range Source # | |
Foldable Range Source # | |
Traversable Range Source # | |
Eq a => Eq (Range a) Source # | |
Show a => Show (Range a) Source # | |
Generic (Range a) Source # | |
NFData a => NFData (Range a) Source # | |
IntervalLike (Range r) Source # | |
Ord a => IsIntersectableWith (Range a) (Range a) Source # | |
type Rep (Range a) Source # | |
type NumType (Range a) Source # | |
type IntersectionOf (Range a) (Range a) Source # | |
pattern ClosedRange :: forall a. a -> a -> Range a Source #
pattern Range' :: forall a. a -> a -> Range a Source #
A range from l to u, ignoring/forgetting the type of the enpoints
inRange :: Ord a => a -> Range a -> Bool Source #
Test if a value lies in a range.
>>>
1 `inRange` (OpenRange 0 2)
True>>>
1 `inRange` (OpenRange 0 1)
False>>>
1 `inRange` (ClosedRange 0 1)
True>>>
1 `inRange` (ClosedRange 1 1)
True>>>
10 `inRange` (OpenRange 1 10)
False>>>
10 `inRange` (ClosedRange 0 1)
False
width :: Num r => Range r -> r Source #
Get the width of the interval
>>>
width $ ClosedRange 1 10
9>>>
width $ OpenRange 5 10
5
clipLower :: Ord a => EndPoint a -> Range a -> Maybe (Range a) Source #
Clip the interval from below. I.e. intersect with the interval {l,infty), where { is either open, (, orr closed, [.
clipUpper :: Ord a => EndPoint a -> Range a -> Maybe (Range a) Source #
Clip the interval from above. I.e. intersect with (-infty, u}, where } is either open, ), or closed, ],
midPoint :: Fractional r => Range r -> r Source #
isValid :: Ord a => Range a -> Bool Source #
Check if the range is valid and nonEmpty, i.e. if the lower endpoint is indeed smaller than the right endpoint. Note that we treat empty open-ranges as invalid as well.
covers :: Ord a => Range a -> Range a -> Bool Source #
Wether or not the first range completely covers the second one