License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Creation and utilities for the unit interval
Synopsis
- data UnitInterval a
- getValue :: UnitInterval a -> a
- mkInterval :: (Ord a, Num a) => a -> UnitInterval a
- safeIndex :: RealFrac a => UnitInterval a -> NonEmpty b -> b
Documentation
data UnitInterval a Source #
getValue :: UnitInterval a -> a Source #
mkInterval :: (Ord a, Num a) => a -> UnitInterval a Source #
Guarantees that the stored value falls within the closed interval
[0, 1]
. It is up to clients to ensure that the promotion
to this type is lossless.
:: RealFrac a | |
=> UnitInterval a | alpha |
-> NonEmpty b | |
-> b |
Since (!!)
is partial, here is "proof" that it is safe:
If "alpha" is its maximum value of 1
, then the maximum value
of the computed index shall be one less than the length of the
list (i.e., a valid index).
See also: indexWrapNonEmpty
.