BoundedModule

Operations over values that carry their permitted range.

Summary

NameSignatureSynopsis
Representation
Valuethis.ValueReturns the underlying value, which always lies within the bounds.
Boundsthis.BoundsReturns the interval the value is constrained to.
BoundedValueBoundedValueNo description available.
BoundsValueBoundsValueNo description available.
Operations
clampBounded.clamp bounds valueRestricts a value into the bounds.
createBounded.create bounds valueAdmits a value only when it already lies within the bounds.
refinementBounded.refinement boundsReturns a refinement admitting values within the supplied bounds.
valueBounded.value inputReturns the underlying value.
boundsBounded.bounds inputReturns the interval the value is constrained to.
isAtBoundBounded.isAtBound inputReturns whether the value sits on either bound.
mapBounded.map mapping inputApplies a mapping and re-clamps into the same bounds, so the invariant survives a mapping that would otherwise leave the range.
withBoundsBounded.withBounds newBounds inputMoves a value into different bounds, clamping as needed.

Representation

kind:member

Value

this.Value
Member
Returns the underlying value, which always lies within the bounds.

Returns

'value
kind:member

Bounds

this.Bounds
Member
Returns the interval the value is constrained to.

Returns

Interval<'value>
kind:member

BoundedValue

BoundedValue
Member

Returns

'value
kind:member

BoundsValue

BoundsValue
Member

Returns

Interval<'value>

Operations

kind:member

clamp

Bounded.clamp bounds value
Member
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

NameTypeDescription
boundsInterval<'a>
value'a

Returns

Bounded<'a>
kind:member

create

Bounded.create bounds value
Member
Admits a value only when it already lies within the bounds.

Parameters

NameTypeDescription
boundsInterval<'value>
value'value

Returns

Result<Bounded<'value>, Violation>
kind:member

refinement

Bounded.refinement bounds
Member
Returns a refinement admitting values within the supplied bounds.

Parameters

NameTypeDescription
boundsInterval<'value>

Returns

Refinement<'value, Bounded<'value>>
kind:member

value

Bounded.value input
Member
Returns the underlying value.

Parameters

NameTypeDescription
inputBounded<'value>

Returns

'value
kind:member

bounds

Bounded.bounds input
Member
Returns the interval the value is constrained to.

Parameters

NameTypeDescription
inputBounded<'value>

Returns

Interval<'value>
kind:member

isAtBound

Bounded.isAtBound input
Member
Returns whether the value sits on either bound.

Parameters

NameTypeDescription
inputBounded<'value>

Returns

bool
kind:member

map

Bounded.map mapping input
Member
Applies a mapping and re-clamps into the same bounds, so the invariant survives a mapping that would otherwise leave the range.

Parameters

NameTypeDescription
mapping'value -> 'value
inputBounded<'value>

Returns

Bounded<'value>
kind:member

withBounds

Bounded.withBounds newBounds input
Member
Moves a value into different bounds, clamping as needed.

Parameters

NameTypeDescription
newBoundsInterval<'value>
inputBounded<'value>

Returns

Bounded<'value>