Safe Haskell | None |
---|---|

Language | Haskell2010 |

A `Range`

a is a tuple representing an interval of a number space. A Range can be thought of as consisting of a low and high value, though low<high isn't strictly enforced, allowing a negative space so to speak.
The library uses the `NumHask`

classes and thus most of the usual arithmetic operators can be used.

- newtype Range a = Range {
- range_ :: (a, a)

- (...) :: Ord a => a -> a -> Range a
- low :: Lens' (Range a) a
- high :: Lens' (Range a) a
- mid :: BoundedField a => Lens' (Range a) a
- width :: BoundedField a => Lens' (Range a) a
- element :: Ord a => a -> Range a -> Bool
- singleton :: a -> Range a
- singular :: Eq a => Range a -> Bool
- intersection :: Ord a => Range a -> Range a -> Range a
- contains :: Ord a => Range a -> Range a -> Bool
- range :: (Foldable f, Ord a, BoundedField a) => f a -> Range a
- project :: Field b => Range b -> Range b -> b -> b
- data LinearPos
- linearSpace :: (Field a, FromInteger a) => LinearPos -> Range a -> Int -> [a]
- linearSpaceSensible :: (Fractional a, Ord a, FromInteger a, QuotientField a, ExpField a) => LinearPos -> Range a -> Int -> [a]
- fromLinearSpace :: [a] -> [Range a]

# Documentation

a newtype wrapped (a, a) tuple

project :: Field b => Range b -> Range b -> b -> b Source #

project a data point from an old range to a new range project o n (view low o) == view low n project o n (view high o) == view high n project a a == id

overns where data points go on the range

linearSpace :: (Field a, FromInteger a) => LinearPos -> Range a -> Int -> [a] Source #

turn a range into a list of n equally-spaced `a`

s

linearSpaceSensible :: (Fractional a, Ord a, FromInteger a, QuotientField a, ExpField a) => LinearPos -> Range a -> Int -> [a] Source #

turn a range into n `a`

s pleasing to human sense and sensibility
the `a`

s may well lie outside the original range as a result

fromLinearSpace :: [a] -> [Range a] Source #

take a list of (ascending) `a`

s and make some (ascending) ranges
based on OuterPos
fromLinearSpace . linearSpace OuterPos == id
linearSpace OuterPos . fromLinearSpace == id