IntervalModule
PackageReified.Refinements
Operations over inclusive ranges of ordered values.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| singleton | Interval.singleton value | Builds the interval containing exactly one value. |
| between | Interval.between first second | Builds the smallest interval containing both values, ordering them as needed. |
| create | Interval.create lower upper | Builds an interval from a pair the caller asserts is already ordered, failing when it is not. |
| lower | Interval.lower interval | Returns the inclusive lower bound. |
| upper | Interval.upper interval | Returns the inclusive upper bound. |
| toPair | Interval.toPair interval | Returns the bounds as a pair. |
| isSingleton | Interval.isSingleton interval | Returns whether the interval contains exactly one value. |
| contains | Interval.contains value interval | Returns whether the value lies within the inclusive bounds. |
| containsInterval | Interval.containsInterval inner outer | Returns whether every value of the inner interval lies within the outer one. |
| overlaps | Interval.overlaps first second | Returns whether the two intervals share at least one value. |
| intersect | Interval.intersect first second | Returns the shared portion of two intervals, or None when they are disjoint. |
| union | Interval.union first second | Returns the combined interval when the two overlap, or None when a gap between them would have to be invented. |
| span | Interval.span first second | Returns the smallest interval containing both inputs, gap included. |
| extendTo | Interval.extendTo value interval | Returns the smallest interval containing the input and the value. |
| ofNonEmptyList | Interval.ofNonEmptyList values | Returns the smallest interval containing every supplied value. |
| clamp | Interval.clamp value interval | Restricts a value to the interval's bounds. |
| mapMonotonic | Interval.mapMonotonic mapping interval | Applies a mapping to both bounds. |
| toConstraint | Interval.toConstraint interval | Returns the portable constraint that admits exactly this interval's values. |
| duration | Interval.duration interval | Returns how long an interval of instants lasts. |
| widthInt | Interval.widthInt interval | Returns the distance between the bounds. |
| widthDecimal | Interval.widthDecimal interval | Returns the distance between the bounds. |
| refinement | Interval.refinement interval | Returns a refinement admitting values that lie within the interval. |
Builds the interval containing exactly one value. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'a |
Returns
Interval<'a>
Builds the smallest interval containing both values, ordering them as needed.
Total — this is the constructor to reach for first.
Parameters
| Name | Type | Description |
|---|---|---|
| first | 'a | |
| second | 'a |
Returns
Interval<'a>
Builds an interval from a pair the caller asserts is already ordered, failing when
it is not. Use this at a boundary, where an inverted pair is a caller error worth
reporting rather than silently repairing; use
between when either order is
acceptable input.
Parameters
| Name | Type | Description |
|---|---|---|
| lower | 'value | |
| upper | 'value |
Returns
Result<Interval<'value>, Violation>
Returns the inclusive lower bound.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<'value> |
Returns
'value
Returns the inclusive upper bound.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<'value> |
Returns
'value
Returns the bounds as a pair.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<'value> |
Returns
'value * 'value
Returns whether the interval contains exactly one value.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<'value> |
Returns
bool
Returns whether the value lies within the inclusive bounds.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'value | |
| interval | Interval<'value> |
Returns
bool
Returns whether every value of the inner interval lies within the outer one.
Parameters
| Name | Type | Description |
|---|---|---|
| inner | Interval<'value> | |
| outer | Interval<'value> |
Returns
bool
Returns whether the two intervals share at least one value.
Parameters
| Name | Type | Description |
|---|---|---|
| first | Interval<'value> | |
| second | Interval<'value> |
Returns
bool
Returns the shared portion of two intervals, or
None when they are disjoint.
The option is the honest representation of an empty result.
Parameters
| Name | Type | Description |
|---|---|---|
| first | Interval<'value> | |
| second | Interval<'value> |
Returns
Interval<'value> option
Returns the combined interval when the two overlap, or
None when a gap
between them would have to be invented. Use span to close the gap instead.
Parameters
| Name | Type | Description |
|---|---|---|
| first | Interval<'value> | |
| second | Interval<'value> |
Returns
Interval<'value> option
Returns the smallest interval containing both inputs, gap included. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| first | Interval<'value> | |
| second | Interval<'value> |
Returns
Interval<'value>
Returns the smallest interval containing the input and the value. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'value | |
| interval | Interval<'value> |
Returns
Interval<'value>
Returns the smallest interval containing every supplied value. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| values | NonEmptyList<'value> |
Returns
Interval<'value>
Restricts a value to the interval's bounds. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'value | |
| interval | Interval<'value> |
Returns
'value
Applies a mapping to both bounds. The result is re-ordered, so a mapping that
reverses the ordering still yields a well-formed interval.
Parameters
| Name | Type | Description |
|---|---|---|
| mapping | 'value -> 'a | |
| interval | Interval<'value> |
Returns
Interval<'a>
Returns the portable constraint that admits exactly this interval's values.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<'value> |
Returns
Constraint<'value>
Returns how long an interval of instants lasts. Total and non-negative.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<DateTimeOffset> |
Returns
TimeSpan
Returns the distance between the bounds. Total, and widened to 64 bits because the
width of
Int32.MinValue .. Int32.MaxValue does not fit an int.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<int> |
Returns
int64
Returns the distance between the bounds. Never negative.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<decimal> |
Returns
decimal