A notion of (inclusive) ranges prescribed to
a.
Ranges are symmetric:
isInRange (lo, hi) x == isInRange (hi, lo) x
Ranges include their endpoints:
isInRange (lo, hi) lo == True
When endpoints coincide, there is nothing else:
isInRange (x, x) y == x == y
Endpoints are endpoints:
isInRange (lo, hi) x ==>
isInRange (lo, x) hi == x == hi
Ranges are transitive relations:
isInRange (lo, hi) lo' && isInRange (lo, hi) hi' && isInRange (lo', hi') x
==> isInRange (lo, hi) x
There is a default implementation of
isInRange via
Generic. Other helper function that can be used for
implementing this function are
isInRangeOrd and
isInRangeEnum.
Note that the
isRange method from
Data.Ix is
not a suitable default implementation of
isInRange.
Unlike
isInRange,
isRange is not required to be
symmetric, and many
isRange implementations are not symmetric
in practice.