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

Language | Haskell98 |

`AUTHOR`

- Dr. Alistair Ward
`DESCRIPTION`

- Describes a bounded set of, typically integral, quantities.
- Operations have been defined, on the list of
*consecutive*quantities delimited by these endpoints. - The point is that if the list is composed from
*consecutive*quantities, the intermediate values can be inferred, rather than physically represented.

`CAVEATS`

- The API was driven top-down by its caller's requirements, rather than a bottom-up attempt to provide a complete interface. consequently there may be omissions from the view point of future callers.
- Thought similar to the mathematical concept of an
*interval*, the latter technically relates to*real*numbers; http://en.wikipedia.org/wiki/Interval_%28mathematics%29. - No account has been made for
*semi-closed*or*open*intervals.

- type Interval endPoint = (endPoint, endPoint)
- closedUnitInterval :: Num n => Interval n
- mkBounded :: Bounded endPoint => Interval endPoint
- elem' :: Ord endPoint => endPoint -> Interval endPoint -> Bool
- normalise :: Ord endPoint => Interval endPoint -> Interval endPoint
- product' :: (Integral i, Show i) => Ratio i -> i -> Interval i -> i
- shift :: Num endPoint => endPoint -> Interval endPoint -> Interval endPoint
- splitAt' :: (Enum endPoint, Num endPoint, Ord endPoint, Show endPoint) => endPoint -> Interval endPoint -> (Interval endPoint, Interval endPoint)
- toList :: Enum endPoint => Interval endPoint -> [endPoint]
- getMinBound :: Interval endPoint -> endPoint
- getMaxBound :: Interval endPoint -> endPoint
- precisely :: endPoint -> Interval endPoint
- isReversed :: Ord endPoint => Interval endPoint -> Bool

# Types

## Type-synonyms

type Interval endPoint = (endPoint, endPoint) Source

Defines a closed (inclusive) interval of consecutive values.

# Constants

closedUnitInterval :: Num n => Interval n Source

Construct the *unsigned closed unit-interval*; http://en.wikipedia.org/wiki/Unit_interval.

# Functions

elem' :: Ord endPoint => endPoint -> Interval endPoint -> Bool Source

True if the specified value is within the inclusive bounds of the *interval*.

normalise :: Ord endPoint => Interval endPoint -> Interval endPoint Source

Swap the *end-points* where they were originally reversed, but otherwise do nothing.

:: (Integral i, Show i) | |

=> Ratio i | The ratio at which to bisect the |

-> i | For efficiency, the |

-> Interval i | |

-> i | The resulting product. |

- Multiplies the consecutive sequence of integers within
`Interval`

. - Since the result can be large,
`divideAndConquer`

is used to form operands of a similar order of magnitude, thus improving the efficiency of the big-number multiplication.

:: Num endPoint | |

=> endPoint | The magnitude of the require shift. |

-> Interval endPoint | The interval to be shifted. |

-> Interval endPoint |

Shift of both *end-points* of the *interval* by the specified amount.

splitAt' :: (Enum endPoint, Num endPoint, Ord endPoint, Show endPoint) => endPoint -> Interval endPoint -> (Interval endPoint, Interval endPoint) Source

Bisect the *interval* at the specified *end-point*; which should be between the two existing *end-points*.

toList :: Enum endPoint => Interval endPoint -> [endPoint] Source

- Converts
`Interval`

to a list by enumerating the values. - CAVEAT: produces rather odd results for
`Fractional`

types, but no stranger than considering such types Enumerable in the first place.

## Accessors

getMinBound :: Interval endPoint -> endPoint Source

Accessor.

getMaxBound :: Interval endPoint -> endPoint Source

Accessor.

## Constructors

## Predicates

isReversed :: Ord endPoint => Interval endPoint -> Bool Source

True if `getMinBound`

exceeds `getMaxBound`

extent.