# Types

A `Pos`

is a position in between two elements in a list. For example, position `0`

marks the beginning of the list, and position `length list`

marks the end of the list. There are `n + 1`

valid positions for a list of length `n`

.

Something that knows its range as sublist in a larger list. Minimal complete definition: either `range`

or both `begin`

and `end`

.

Yields the element's range.

Yields the element's begin position.

Yields the element's end position.

# Utility functions

distRange :: Range -> Range -> IntSource

`distRange (b1, e1) (b2, e2)`

is defined as `|b1 - b2| + |e1 - e2|`

.

inRange :: Pos -> Range -> BoolSource

Whether a position falls within a range, including the range's edges.

includes :: Range -> Range -> BoolSource

Yields whether the second argument completely falls within the first argument.

unionRange :: Range -> Range -> RangeSource

validRange :: Range -> BoolSource

A range is valid if its positions are nonnegative and begin < end.