Safe Haskell | None |
---|---|
Language | Haskell2010 |
All of the folding functions in this module are strict in the accumulator.
- data Index n
- data Length n
- data Vector n a
- data PrimVector n a
- ascendM :: forall m n a. (Monoid a, Monad m) => (Index n -> m a) -> Length n -> m a
- descendM :: forall m n a. (Monoid a, Monad m) => (Index n -> m a) -> Length n -> m a
- ascend :: forall n a. (a -> Index n -> a) -> a -> Length n -> a
- descend :: forall n a. (a -> Index n -> a) -> a -> Length n -> a
- with :: Int -> (forall n. Index n -> a) -> a
- reflect :: Length n -> Index n -> Index n
- offset :: Length n -> Int -> Index n -> Index n
- zero :: Index n -> Index n
- unindex :: Index n -> Int
- unlength :: Length n -> Int
Documentation
An integer that can be used to index into an array of length n
.
A value-level representation of length n
.
data PrimVector n a Source #
ascendM :: forall m n a. (Monoid a, Monad m) => (Index n -> m a) -> Length n -> m a Source #
A strict left monadic fold over the ascending indices from zero up to a given length.
descendM :: forall m n a. (Monoid a, Monad m) => (Index n -> m a) -> Length n -> m a Source #
A strict monadic left fold over the descending indices from a given length down to zero.
ascend :: forall n a. (a -> Index n -> a) -> a -> Length n -> a Source #
A strict left fold over the ascending indices from zero up to a given length.
descend :: forall n a. (a -> Index n -> a) -> a -> Length n -> a Source #
A strict left fold over the descending indices from a given length down to zero.
with :: Int -> (forall n. Index n -> a) -> a Source #
Pass an integer length to a function that can accept any length. If the integer is below zero, this truncates it to zero.
reflect :: Length n -> Index n -> Index n Source #
Reflect an index about the middle of the length. For a length of 5 this has the following effect:
0 ==> 4 1 ==> 3 2 ==> 2 3 ==> 1 4 ==> 0
offset :: Length n -> Int -> Index n -> Index n Source #
Add an offset to an index and reduce in modulo the length to ensure that the resulting index is in bounds.
zero :: Index n -> Index n Source #
The existence of any index is evidence that there an index into the zero position is valid.