BoundedModule
PackageReified.Refinements
Operations over values that carry their permitted range.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| clamp | Bounded.clamp bounds value | Restricts a value into the bounds. |
| create | Bounded.create bounds value | Admits a value only when it already lies within the bounds. |
| refinement | Bounded.refinement bounds | Returns a refinement admitting values within the supplied bounds. |
| value | Bounded.value input | Returns the underlying value. |
| bounds | Bounded.bounds input | Returns the interval the value is constrained to. |
| isAtBound | Bounded.isAtBound input | Returns whether the value sits on either bound. |
| map | Bounded.map mapping input | Applies a mapping and re-clamps into the same bounds, so the invariant survives a mapping that would otherwise leave the range. |
| withBounds | Bounded.withBounds newBounds input | Moves a value into different bounds, clamping as needed. |
Restricts a value into the bounds. Total — this is the constructor to reach for
first, because an out-of-range input has an obvious correct answer.
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | Interval<'a> | |
| value | 'a |
Returns
Bounded<'a>
Admits a value only when it already lies within the bounds.
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | Interval<'value> | |
| value | 'value |
Returns
Result<Bounded<'value>, Violation>
Returns a refinement admitting values within the supplied bounds.
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | Interval<'value> |
Returns
Refinement<'value, Bounded<'value>>
Returns the underlying value.
Parameters
| Name | Type | Description |
|---|---|---|
| input | Bounded<'value> |
Returns
'value
Returns the interval the value is constrained to.
Parameters
| Name | Type | Description |
|---|---|---|
| input | Bounded<'value> |
Returns
Interval<'value>
Returns whether the value sits on either bound.
Parameters
| Name | Type | Description |
|---|---|---|
| input | Bounded<'value> |
Returns
bool
Applies a mapping and re-clamps into the same bounds, so the invariant survives
a mapping that would otherwise leave the range.
Parameters
| Name | Type | Description |
|---|---|---|
| mapping | 'value -> 'value | |
| input | Bounded<'value> |
Returns
Bounded<'value>