Portability | non-portable |
---|---|

Stability | experimental |

Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au> |

- The pure and mutable array types
- Constructing vectors
- Operations based on length information
- Accessing individual elements
- Subvectors
- Subvector construction without bounds checks
- Permutations
- Mapping
- Zipping and unzipping
- Filtering
- Searching
- Folding
- Specialised folds
- Unfolding
- Scans
- Enumeration
- Conversion to/from lists
- Monadic operations
- Destructive operations

A library for boxed vectors (that is, polymorphic arrays capable of holding any Haskell value). The vectors come in two flavors:

- mutable
- immutable

and support a rich interface of both list-like operations, and bulk array operations.

For unboxed arrays, use the `Data.Vector.Unboxed`

interface.

- data Vector a
- data MVector s a
- empty :: Vector a
- singleton :: a -> Vector a
- cons :: a -> Vector a -> Vector a
- snoc :: Vector a -> a -> Vector a
- (++) :: Vector a -> Vector a -> Vector a
- replicate :: Int -> a -> Vector a
- generate :: Int -> (Int -> a) -> Vector a
- force :: Vector a -> Vector a
- length :: Vector a -> Int
- null :: Vector a -> Bool
- (!) :: Vector a -> Int -> a
- head :: Vector a -> a
- last :: Vector a -> a
- indexM :: Monad m => Vector a -> Int -> m a
- headM :: Monad m => Vector a -> m a
- lastM :: Monad m => Vector a -> m a
- unsafeIndex :: Vector a -> Int -> a
- unsafeHead :: Vector a -> a
- unsafeLast :: Vector a -> a
- unsafeIndexM :: Monad m => Vector a -> Int -> m a
- unsafeHeadM :: Monad m => Vector a -> m a
- unsafeLastM :: Monad m => Vector a -> m a
- init :: Vector a -> Vector a
- tail :: Vector a -> Vector a
- take :: Int -> Vector a -> Vector a
- drop :: Int -> Vector a -> Vector a
- slice :: Int -> Int -> Vector a -> Vector a
- unsafeSlice :: Int -> Int -> Vector a -> Vector a
- unsafeInit :: Vector a -> Vector a
- unsafeTail :: Vector a -> Vector a
- unsafeTake :: Int -> Vector a -> Vector a
- unsafeDrop :: Int -> Vector a -> Vector a
- accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a
- accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a
- accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a
- (//) :: Vector a -> [(Int, a)] -> Vector a
- update :: Vector a -> Vector (Int, a) -> Vector a
- update_ :: Vector a -> Vector Int -> Vector a -> Vector a
- backpermute :: Vector a -> Vector Int -> Vector a
- reverse :: Vector a -> Vector a
- unsafeAccum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a
- unsafeAccumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a
- unsafeAccumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a
- unsafeUpd :: Vector a -> [(Int, a)] -> Vector a
- unsafeUpdate :: Vector a -> Vector (Int, a) -> Vector a
- unsafeUpdate_ :: Vector a -> Vector Int -> Vector a -> Vector a
- unsafeBackpermute :: Vector a -> Vector Int -> Vector a
- map :: (a -> b) -> Vector a -> Vector b
- imap :: (Int -> a -> b) -> Vector a -> Vector b
- concatMap :: (a -> Vector b) -> Vector a -> Vector b
- zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c
- zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
- zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
- zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
- zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
- izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c
- izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
- izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
- izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
- izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
- zip :: Vector a -> Vector b -> Vector (a, b)
- zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)
- zip4 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)
- zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)
- zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)
- unzip :: Vector (a, b) -> (Vector a, Vector b)
- unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)
- unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)
- unzip5 :: Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)
- unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)
- filter :: (a -> Bool) -> Vector a -> Vector a
- ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a
- takeWhile :: (a -> Bool) -> Vector a -> Vector a
- dropWhile :: (a -> Bool) -> Vector a -> Vector a
- partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
- unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
- span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
- break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
- elem :: Eq a => a -> Vector a -> Bool
- notElem :: Eq a => a -> Vector a -> Bool
- find :: (a -> Bool) -> Vector a -> Maybe a
- findIndex :: (a -> Bool) -> Vector a -> Maybe Int
- findIndices :: (a -> Bool) -> Vector a -> Vector Int
- elemIndex :: Eq a => a -> Vector a -> Maybe Int
- elemIndices :: Eq a => a -> Vector a -> Vector Int
- foldl :: (a -> b -> a) -> a -> Vector b -> a
- foldl1 :: (a -> a -> a) -> Vector a -> a
- foldl' :: (a -> b -> a) -> a -> Vector b -> a
- foldl1' :: (a -> a -> a) -> Vector a -> a
- foldr :: (a -> b -> b) -> b -> Vector a -> b
- foldr1 :: (a -> a -> a) -> Vector a -> a
- foldr' :: (a -> b -> b) -> b -> Vector a -> b
- foldr1' :: (a -> a -> a) -> Vector a -> a
- ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a
- ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a
- ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b
- ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b
- all :: (a -> Bool) -> Vector a -> Bool
- any :: (a -> Bool) -> Vector a -> Bool
- and :: Vector Bool -> Bool
- or :: Vector Bool -> Bool
- sum :: Num a => Vector a -> a
- product :: Num a => Vector a -> a
- maximum :: Ord a => Vector a -> a
- maximumBy :: (a -> a -> Ordering) -> Vector a -> a
- minimum :: Ord a => Vector a -> a
- minimumBy :: (a -> a -> Ordering) -> Vector a -> a
- minIndex :: Ord a => Vector a -> Int
- minIndexBy :: (a -> a -> Ordering) -> Vector a -> Int
- maxIndex :: Ord a => Vector a -> Int
- maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Int
- unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a
- unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a
- prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a
- prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
- postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a
- postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
- scanl :: (a -> b -> a) -> a -> Vector b -> Vector a
- scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
- scanl1 :: (a -> a -> a) -> Vector a -> Vector a
- scanl1' :: (a -> a -> a) -> Vector a -> Vector a
- prescanr :: (a -> b -> b) -> b -> Vector a -> Vector b
- prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
- postscanr :: (a -> b -> b) -> b -> Vector a -> Vector b
- postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
- scanr :: (a -> b -> b) -> b -> Vector a -> Vector b
- scanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
- scanr1 :: (a -> a -> a) -> Vector a -> Vector a
- scanr1' :: (a -> a -> a) -> Vector a -> Vector a
- enumFromN :: Num a => a -> Int -> Vector a
- enumFromStepN :: Num a => a -> a -> Int -> Vector a
- enumFromTo :: Enum a => a -> a -> Vector a
- enumFromThenTo :: Enum a => a -> a -> a -> Vector a
- toList :: Vector a -> [a]
- fromList :: [a] -> Vector a
- fromListN :: Int -> [a] -> Vector a
- replicateM :: Monad m => Int -> m a -> m (Vector a)
- mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)
- mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()
- forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)
- forM_ :: Monad m => Vector a -> (a -> m b) -> m ()
- zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
- zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()
- filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)
- foldM :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a
- foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a
- fold1M :: Monad m => (a -> a -> m a) -> Vector a -> m a
- fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m a
- create :: (forall s. ST s (MVector s a)) -> Vector a
- modify :: (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a
- copy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()
- unsafeCopy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()

# The pure and mutable array types

Boxed vectors, supporting efficient slicing.

Mutable boxed vectors keyed on the monad they live in (`IO`

or

).
`ST`

s

# Constructing vectors

replicate :: Int -> a -> Vector aSource

*O(n)*.

yields a vector of length `replicate`

n e`n`

storing `e`

at each position

generate :: Int -> (Int -> a) -> Vector aSource

*O(n)*, Generate a vector of the given length by applying a (pure)
generator function to each index

force :: Vector a -> Vector aSource

*O(n)*, Create a copy of a vector.
`force`

is useful when dealing with slices, as the garbage collector
may be able to free the original vector if no further references are held.

# Operations based on length information

# Accessing individual elements

## Accessors in a monad

indexM :: Monad m => Vector a -> Int -> m aSource

Monadic indexing which can be strict in the vector while remaining lazy in the element

headM :: Monad m => Vector a -> m aSource

Monadic head which can be strict in the vector while remaining lazy in the element

lastM :: Monad m => Vector a -> m aSource

Monadic last which can be strict in the vector while remaining lazy in the element

## Accessor functions with no bounds checking

unsafeIndex :: Vector a -> Int -> aSource

*O(1)*, Unsafe indexing without bounds checking

By not performing bounds checks, this function may be faster when this function is used in an inner loop)

unsafeHead :: Vector a -> aSource

*O(1)*, Yield the first element of a vector without checking if the vector is empty

By not performing bounds checks, this function may be faster when this function is used in an inner loop)

unsafeLast :: Vector a -> aSource

Yield the last element of a vector without checking if the vector is empty

By not performing bounds checks, this function may be faster when this function is used in an inner loop)

unsafeIndexM :: Monad m => Vector a -> Int -> m aSource

Unsafe monadic indexing without bounds checks

unsafeHeadM :: Monad m => Vector a -> m aSource

Unsafe monadic head (access the first element) without bounds checks

unsafeLastM :: Monad m => Vector a -> m aSource

Unsafe monadic last (access the last element) without bounds checks

# Subvectors

*O(1)*, Yield a part of the vector without copying it.

# Subvector construction without bounds checks

*O(1)*, Unsafely yield a part of the vector without copying it and without
performing bounds checks.

unsafeInit :: Vector a -> Vector aSource

*O(1)*, Zero-copying `init`

without bounds checks.

unsafeTail :: Vector a -> Vector aSource

*O(1)*, Zero-copying `tail`

without bounds checks.

# Permutations

accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector aSource

TODO accumulate_

backpermute :: Vector a -> Vector Int -> Vector aSource

backpermute, courtesy Blelloch. The back-permute is a gather/get operation.

unsafeAccum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector aSource

TODO unsafeAccum.

unsafeAccumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector aSource

TODO unsafeAccumulate

unsafeAccumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector aSource

TODO unsafeAccumulate_

# Mapping

imap :: (Int -> a -> b) -> Vector a -> Vector bSource

*O(n)*, Apply a function to every index/value pair yielding a new vector

concatMap :: (a -> Vector b) -> Vector a -> Vector bSource

*O(n)*, generate a vector from each element of the input vector, then join the results.

# Zipping and unzipping

zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector cSource

*O(n)*, Zip two vectors with the given function.

zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector dSource

*O(n)*, Zip three vectors with the given function.

zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector eSource

*O(n)*, Zip four vectors with the given function.

zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector fSource

*O(n)*, Zip five vectors with the given function.

zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector gSource

*O(n)*, Zip six vectors with the given function.

izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector cSource

*O(n)*, Zip two vectors and their indices with the given function.

izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector dSource

*O(n)*, Zip three vectors and their indices with the given function.

izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector eSource

*O(n)*, Zip four vectors and their indices with the given function.

izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector fSource

*O(n)*, Zip five vectors and their indices with the given function.

izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector gSource

*O(n)*, Zip six vectors and their indices with the given function.

zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)Source

zip together three vectors into a vector of triples

zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)Source

unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)Source

# Filtering

filter :: (a -> Bool) -> Vector a -> Vector aSource

*O(n)*, Remove elements from the vector which do not satisfy the predicate

ifilter :: (Int -> a -> Bool) -> Vector a -> Vector aSource

*O(n)*, Drop elements that do not satisfy the predicate (applied to values and
their indices)

takeWhile :: (a -> Bool) -> Vector a -> Vector aSource

*O(n)*, Yield the longest prefix of elements satisfying the predicate.

dropWhile :: (a -> Bool) -> Vector a -> Vector aSource

*O(n)*, Drop the longest prefix of elements that satisfy the predicate.

partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)Source

Split the vector in two parts, the first one containing those elements
that satisfy the predicate and the second one those that don't. The
relative order of the elements is preserved at the cost of a (sometimes)
reduced performance compared to `unstablePartition`

.

unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)Source

*O(n)*, Split the vector in two parts, the first one containing those elements
that satisfy the predicate and the second one those that don't. The order
of the elements is not preserved.

span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)Source

*O(n)*, Split the vector into the longest prefix of elements that satisfy the
predicate and the rest.

break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)Source

Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest.

# Searching

findIndices :: (a -> Bool) -> Vector a -> Vector IntSource

Yield the indices of elements satisfying the predicate

elemIndices :: Eq a => a -> Vector a -> Vector IntSource

Yield the indices of all occurences of the given element

# Folding

foldl1' :: (a -> a -> a) -> Vector a -> aSource

Left fold on non-empty vectors with strict accumulator

foldr1' :: (a -> a -> a) -> Vector a -> aSource

Right fold on non-empty vectors with strict accumulator

ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> aSource

Left fold (function applied to each element and its index)

ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> aSource

Left fold with strict accumulator (function applied to each element and its index)

ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> bSource

Right fold (function applied to each element and its index)

ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> bSource

Right fold with strict accumulator (function applied to each element and its index)

# Specialised folds

all :: (a -> Bool) -> Vector a -> BoolSource

*O(n)*.

determines whether all elements in array `all`

p u`u`

satisfy
predicate `p`

.

any :: (a -> Bool) -> Vector a -> BoolSource

*O(n)*.

determines whether any element in array `any`

p u`u`

satisfies
predicate `p`

.

product :: Num a => Vector a -> aSource

*O(n)*. `sum`

computes the product (with `(*)`

) of an array of elements.

maximum :: Ord a => Vector a -> aSource

*O(n)*. `maximum`

finds the maximum element in an array of orderable elements.

maximumBy :: (a -> a -> Ordering) -> Vector a -> aSource

*O(n)*. `maximumBy`

finds the maximum element in an array under the given ordering.

minimum :: Ord a => Vector a -> aSource

*O(n)*. `minimum`

finds the minimum element in an array of orderable elements.

minimumBy :: (a -> a -> Ordering) -> Vector a -> aSource

*O(n)*. `minimumBy`

finds the minimum element in an array under the given ordering.

minIndexBy :: (a -> a -> Ordering) -> Vector a -> IntSource

TODO minIndexBy

maxIndexBy :: (a -> a -> Ordering) -> Vector a -> IntSource

TODO maxIndexBy

# Unfolding

unfoldr :: (b -> Maybe (a, b)) -> b -> Vector aSource

The `unfoldr`

function is a `dual' to `foldr`

: while `foldr`

reduces a vector to a summary value, `unfoldr`

builds a list from
a seed value. The function takes the element and returns `Nothing`

if it is done generating the vector or returns `Just`

`(a,b)`

, in which
case, `a`

is a prepended to the vector and `b`

is used as the next
element in a recursive call.

A simple use of unfoldr:

unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10 [10,9,8,7,6,5,4,3,2,1]

# Scans

postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector aSource

Suffix scan with strict accumulator

scanl' :: (a -> b -> a) -> a -> Vector b -> Vector aSource

Haskell-style scan with strict accumulator

scanl1' :: (a -> a -> a) -> Vector a -> Vector aSource

Scan over a non-empty `Vector`

with a strict accumulator

prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector bSource

Prefix right-to-left scan with strict accumulator

postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector bSource

Suffix right-to-left scan with strict accumulator

scanr' :: (a -> b -> b) -> b -> Vector a -> Vector bSource

Haskell-style right-to-left scan with strict accumulator

scanr1' :: (a -> a -> a) -> Vector a -> Vector aSource

Right-to-left scan over a non-empty vector with a strict accumulator

# Enumeration

enumFromN :: Num a => a -> Int -> Vector aSource

Yield a vector of the given length containing the values `x`

, `x+1`

etc.
This operation is usually more efficient than `enumFromTo`

.

enumFromStepN :: Num a => a -> a -> Int -> Vector aSource

Yield a vector of the given length containing the values `x`

, `x+y`

,
`x+y+y`

etc. This operations is usually more efficient than
`enumFromThenTo`

.

enumFromTo :: Enum a => a -> a -> Vector aSource

Enumerate values from `x`

to `y`

.

*WARNING:* This operation can be very inefficient. If at all possible, use
`enumFromN`

instead.

enumFromThenTo :: Enum a => a -> a -> a -> Vector aSource

Enumerate values from `x`

to `y`

with a specific step `z`

.

*WARNING:* This operation can be very inefficient. If at all possible, use
`enumFromStepN`

instead.

# Conversion to/from lists

fromListN :: Int -> [a] -> Vector aSource

Convert the first `n`

elements of a list to a vector

fromListN n xs = fromList (take n xs)

# Monadic operations

replicateM :: Monad m => Int -> m a -> m (Vector a)Source

Perform the monadic action the given number of times and store the results in a vector.

mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)Source

Apply the monadic action to all elements of the vector, yielding a vector of results

mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()Source

Apply the monadic action to all elements of a vector and ignore the results

forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)Source

Apply the monadic action to all elements of the vector, yielding a vector of results

forM_ :: Monad m => Vector a -> (a -> m b) -> m ()Source

Apply the monadic action to all elements of a vector and ignore the results

zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)Source

Zip the two vectors with the monadic action and yield a vector of results

zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()Source

Zip the two vectors with the monadic action and ignore the results

filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)Source

Drop elements that do not satisfy the monadic predicate

foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m aSource

Monadic fold with strict accumulator

fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m aSource

Monad fold over non-empty vectors with strict accumulator

# Destructive operations

modify :: (forall s. MVector s a -> ST s ()) -> Vector a -> Vector aSource

Apply a destructive operation to a vector. The operation is applied to a copy of the vector unless it can be safely performed in place.