h$_       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (c) Roman Leshchinskiy 2009 BSD-style'Roman Leshchinskiy  experimentalportable Safe-Inferred#vector Box monadvectorIdentity monad vectorDelay inlining a function until late in the game (simplifier phase 0). vector  inlined in phase 0    (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimentalportable Safe-Inferred% vector Size hintvector Exact sizevectorUpper bound on the sizevector Unknown sizevector;Subtract two sizes with clamping to 0, for drop-like thingsvectorMinimum of two size hintsvector&Select a safe smaller than known size.vectorMaximum of two size hintsvector%Convert a size hint to an upper boundvector)Compute the minimum size from a size hintvector5Compute the maximum size from a size hint if possible   (c) Roman Leshchinskiy 2008-2011 BSD-style'Roman Leshchinskiy  experimental non-portableNone/!vectorClass of mutable vectors parametrised with a primitive state token."vectorLength of the mutable vector. This method should not be called directly, use   instead.#vectorYield a part of the mutable vector without copying it. This method should not be called directly, use  unsafeSlice instead.$vectorCheck whether two vectors overlap. This method should not be called directly, use overlaps instead.%vectorCreate a mutable vector of the given length. This method should not be called directly, use  unsafeNew instead.& vectorInitialize a vector to a standard value. This is intended to be called as part of the safe new operation (and similar operations), to properly blank the newly allocated memory if necessary.Vectors that are necessarily initialized as part of creation may implement this as a no-op.'vectorCreate a mutable vector of the given length and fill it with an initial value. This method should not be called directly, use   instead.(vectorYield the element at the given position. This method should not be called directly, use  unsafeRead instead.)vectorReplace the element at the given position. This method should not be called directly, use  unsafeWrite instead.*vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors. This method should not be called directly, use clear instead.+vectorSet all elements of the vector to the given value. This method should not be called directly, use set instead.,vectorCopy a vector. The two vectors may not overlap. This method should not be called directly, use  unsafeCopy instead.-vectorMove the contents of a vector. The two vectors may overlap. This method should not be called directly, use  unsafeMove instead..vectorGrow a vector by the given number of elements. Allocates a new vector and copies all of the elements over starting at 0 index. This method should not be called directly, use grow/ unsafeGrow instead.#vectorstarting indexvectorlength of the slice,vectortargetvectorsource-vectortargetvectorsource!"#$%&'()*+,-.!"#$%&'()*+,-. (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone ?; /vectorClass of immutable vectors. Every immutable vector is associated with its mutable version through the 7 type family. Methods of this class should not be used directly. Instead, Data.Vector.Generic and other Data.Vector modules provide safe and fusible wrappers. Minimum complete implementation:012340vectorAssumed complexity: O(1)Unsafely convert a mutable vector to its immutable version without copying. The mutable vector may not be used after this operation.1vectorAssumed complexity: O(1)Unsafely convert an immutable vector to its mutable version without copying. The immutable vector may not be used after this operation.2vectorAssumed complexity: O(1)Yield the length of the vector.3vectorAssumed complexity: O(1)Yield a slice of the vector without copying it. No range checks are performed.4vectorAssumed complexity: O(1)Yield the element at the given position in a monad. No range checks are performed.The monad allows us to be strict in the vector if we want. Suppose we had unsafeIndex :: v a -> Int -> ainstead. Now, if we wanted to copy a vector, we'd do something like :copy mv v ... = ... unsafeWrite mv i (unsafeIndex v i) ...For lazy vectors, the indexing would not be evaluated which means that we would retain a reference to the original vector in each element we write. This is not what we want!With 4 , we can do copy mv v ... = ... case basicUnsafeIndexM v i of Box x -> unsafeWrite mv i x ...which does not have this problem because indexing (but not the returned element!) is evaluated immediately.5vectorAssumed complexity: O(n)Copy an immutable vector into a mutable one. The two vectors must have the same length but this is not checked. Instances of / should redefine this method if they wish to support an efficient block copy operation.%Default definition: copying basic on 4 and basicUnsafeWrite.6vector Evaluate a2 as far as storing it in a vector would and yield b. The v a argument only fixes the type and is not touched. The method is only used for optimisation purposes. Thus, it is safe for instances of / to evaluate a less than it would be when stored in a vector although this might result in suboptimal code. 2elemseq v x y = (singleton x `asTypeOf` v) `seq` yDefault defintion: a is not evaluated at all7vector Mutable v s a0 is the mutable version of the pure vector type v a with the state token s%. It is injective on GHC 8 and newer.3vectorstarting indexvectorlength /23501467(c) Roman Leshchinskiy 2009 BSD-style'Roman Leshchinskiy  experimental non-portableNone; 8;9:<=>?@AB 8;9:<=>?@AB 3 2 (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone'(>RDvectorMonadic streamsFvector*Result of taking a single step in a streamJvector Length of a DKvector Check if a D is emptyLvectorEmpty DMvector Singleton DNvector#Replicate a value to a given lengthOvectorYield a D of values obtained by performing the monadic action the given number of timesQvector"Generate a stream from its indicesRvectorPrepend an elementSvectorAppend an elementTvectorConcatenate two DsUvectorFirst element of the D or error if emptyVvectorLast element of the D or error if emptyWvectorElement at the given positionXvector!Element at the given position or   if out of boundsYvectorExtract a substream of the given length starting at the given position.ZvectorAll but the last element[vectorAll but the first element\vector The first n elements]vectorAll but the first n elements^vectorMap a function over a D_vectorMap a monadic function over a D`vector1Execute a monadic action for each element of the Davector Transform a D to use a different monadcvectorPair each element in a D with its indexdvectorPair each element in a D; with its index, starting from the right and counting downevectorZip two D!s with the given monadic functionuvector Check if two D s are equalvvectorLexicographically compare two Dswvector0Drop elements which do not satisfy the predicatezvector8Drop elements which do not satisfy the monadic predicate{ vectorDrop the longest prefix of elements that satisfy the predicatevectorDrop the longest prefix of elements that satisfy the monadic predicatevectorCheck whether the D contains an elementvector Inverse of vectorYield  3 the first element that satisfies the predicate or   if no such element exists.vectorYield  < the first element that satisfies the monadic predicate or   if no such element exists.vectorYield   the index of the first element that satisfies the predicate or   if no such element exists.vectorYield   the index of the first element that satisfies the monadic predicate or   if no such element exists.vector Left foldvector!Left fold with a monadic operatorvectorSame as vectorLeft fold over a non-empty DvectorLeft fold over a non-empty D with a monadic operatorvectorSame as vector#Left fold with a strict accumulatorvector:Left fold with a strict accumulator and a monadic operatorvectorSame as vectorLeft fold over a non-empty D with a strict accumulatorvectorLeft fold over a non-empty D2 with a strict accumulator and a monadic operatorvectorSame as vector Right foldvector"Right fold with a monadic operatorvector"Right fold over a non-empty streamvector:Right fold over a non-empty stream with a monadic operatorvector Create a D of values from a D of streamable thingsvectorUnfoldvectorUnfold with a monadic functionvectorUnfold at most n" elements with a monadic function. vectorUnfold exactly n elements vectorUnfold exactly n" elements with a monadic function.vectorO(n) Apply monadic function \max(n - 1, 0)3 times to an initial value, producing a stream of  \max(n, 0) values.vectorO(n) Apply function \max(n - 1, 0)3 times to an initial value, producing a stream of  \max(n, 0) values.vector Prefix scanvector#Prefix scan with a monadic operatorvector#Prefix scan with strict accumulatorvector:Prefix scan with strict accumulator and a monadic operatorvector Suffix scanvector#Suffix scan with a monadic operatorvector#Suffix scan with strict accumulatorvector;Suffix scan with strict acccumulator and a monadic operatorvectorHaskell-style scanvector*Haskell-style scan with a monadic operatorvector*Haskell-style scan with strict accumulatorvectorHaskell-style scan with strict accumulator and a monadic operatorvectorScan over a non-empty DvectorScan over a non-empty D with a monadic operatorvectorScan over a non-empty D with a strict accumulatorvectorScan over a non-empty D2 with a strict accumulator and a monadic operatorvectorYield a D+ of the given length containing the values x, x+y, x+y+y etc.vectorEnumerate valuesWARNING: This operation can be very inefficient. If at all possible, use  instead.vector#Enumerate values with a given step.WARNING:> This operation is very inefficient. If at all possible, use  instead.vector Convert a D to a listvectorConvert a list to a DvectorConvert the first n elements of a list to a BundleYvectorstarting indexvectorlengthDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~DEFGHIJKLMRSNOPQTUVWXYZ[\]^_`abcdfeghijklmnopqrstuvwz|x{y}~T5W9 X9 44  (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone'(>k vectorMonadic streamsvector)Convert a pure stream to a monadic streamvector hint of a vector Attach a  hint to a vector Length of a vector Check if a  is emptyvectorEmpty vector Singleton vector#Replicate a value to a given lengthvectorYield a  of values obtained by performing the monadic action the given number of timesvector"Generate a stream from its indicesvectorPrepend an elementvectorAppend an elementvectorConcatenate two svectorFirst element of the  or error if emptyvectorLast element of the  or error if emptyvectorElement at the given positionvector!Element at the given position or   if out of boundsvectorExtract a substream of the given length starting at the given position.vectorAll but the last elementvectorAll but the first elementvector The first n elementsvectorAll but the first n elementsvectorMap a function over a vectorMap a monadic function over a vector1Execute a monadic action for each element of the vector Transform a  to use a different monadvectorPair each element in a  with its indexvectorPair each element in a ; with its index, starting from the right and counting downvectorZip two !s with the given monadic functionvector Check if two  s are equalvectorLexicographically compare two svector0Drop elements which do not satisfy the predicatevector8Drop elements which do not satisfy the monadic predicate vectorDrop the longest prefix of elements that satisfy the predicatevectorDrop the longest prefix of elements that satisfy the monadic predicatevectorCheck whether the  contains an elementvector Inverse of vectorYield  3 the first element that satisfies the predicate or   if no such element exists.vectorYield  < the first element that satisfies the monadic predicate or   if no such element exists.vectorYield   the index of the first element that satisfies the predicate or   if no such element exists.vectorYield   the index of the first element that satisfies the monadic predicate or   if no such element exists.vector Left foldvector!Left fold with a monadic operatorvectorSame as vectorLeft fold over a non-empty vectorLeft fold over a non-empty  with a monadic operatorvectorSame as vector#Left fold with a strict accumulatorvector:Left fold with a strict accumulator and a monadic operatorvectorSame as vectorLeft fold over a non-empty  with a strict accumulatorvectorLeft fold over a non-empty 2 with a strict accumulator and a monadic operatorvectorSame as vector Right foldvector"Right fold with a monadic operatorvector"Right fold over a non-empty streamvector:Right fold over a non-empty stream with a monadic operatorvector Create a  of values from a  of streamable thingsvectorUnfoldvectorUnfold with a monadic functionvectorUnfold at most n elementsvectorUnfold at most n" elements with a monadic function. vectorUnfold exactly n elements vectorUnfold exactly n" elements with a monadic function.vectorO(n) Apply monadic function \max(n - 1, 0) times to an initial value, producing a monadic bundle of exact length  \max(n, 0)1. Zeroth element will contain the initial value.vectorO(n) Apply function \max(n - 1, 0) times to an initial value, producing a monadic bundle of exact length  \max(n, 0)1. Zeroth element will contain the initial value.vector Prefix scanvector#Prefix scan with a monadic operatorvector#Prefix scan with strict accumulatorvector:Prefix scan with strict accumulator and a monadic operatorvector Suffix scanvector#Suffix scan with a monadic operatorvector#Suffix scan with strict accumulatorvector;Suffix scan with strict acccumulator and a monadic operatorvectorHaskell-style scanvector*Haskell-style scan with a monadic operatorvector*Haskell-style scan with strict accumulatorvectorHaskell-style scan with strict accumulator and a monadic operatorvectorScan over a non-empty vectorScan over a non-empty  with a monadic operatorvectorScan over a non-empty  with a strict accumulatorvectorScan over a non-empty 2 with a strict accumulator and a monadic operatorvectorYield a + of the given length containing the values x, x+y, x+y+y etc.vectorEnumerate valuesWARNING: This operation can be very inefficient. If at all possible, use  instead.vector#Enumerate values with a given step.WARNING:> This operation is very inefficient. If at all possible, use  instead.vector Convert a  to a listvectorConvert a list to a vectorConvert the first n elements of a list to a vectorConvert a list to a  with the given  hint.vectorstarting indexvectorlength59 9 44  (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone>}vector$Alternative name for monadic streamsvectorThe type of pure streamsvector hint of a vector Attach a  hint to a vector Length of a vector Check if a  is emptyvectorEmpty vector Singleton vector#Replicate a value to a given lengthvector"Generate a stream from its indicesvectorPrepend an elementvectorAppend an elementvectorConcatenate two svectorFirst element of the  or error if emptyvectorLast element of the  or error if emptyvectorElement at the given positionvector!Element at the given position or   if out of boundsvectorExtract a substream of the given length starting at the given position.vectorAll but the last elementvectorAll but the first elementvector The first n elementsvectorAll but the first n elementsvectorMap a function over a vectorPair each element in a  with its indexvectorPair each element in a ; with its index, starting from the right and counting downvectorZip two s with the given functionvector Zip three s with the given functionvector0Drop elements which do not satisfy the predicatevector5Longest prefix of elements that satisfy the predicatevector>Drop the longest prefix of elements that satisfy the predicatevectorCheck whether the  contains an elementvector Inverse of vectorYield  - the first element matching the predicate or   if no such element exists.vectorYield  ; the index of the first element matching the predicate or   if no such element exists.vector Left foldvectorLeft fold on non-empty svector!Left fold with strict accumulatorvectorLeft fold on non-empty s with strict accumulatorvector Right foldvectorRight fold on non-empty svectorUnfoldvectorUnfold at most n elements vectorUnfold exactly n elementsvectorO(n) Apply function \max(n - 1, 0) times to an initial value, producing a pure bundle of exact length  \max(n, 0)0. Zeroth element will contain the initial value.vector Prefix scanvector#Prefix scan with strict accumulatorvector Suffix scanvector#Suffix scan with strict accumulatorvectorHaskell-style scanvector*Haskell-style scan with strict accumulatorvectorScan over a non-empty vectorScan over a non-empty  with a strict accumulatorvector Check if two  s are equalvectorLexicographically compare two svectorApply a monadic action to each element of the stream, producing a monadic stream of resultsvector4Apply a monadic action to each element of the streamvectorYield a monadic stream of elements that satisfy the monadic predicate vectorO(n) Apply monadic function to each element of a bundle and discard elements returning Nothing.vector Monadic foldvector"Monadic fold over non-empty streamvector$Monadic fold with strict accumulatorvector8Monad fold over non-empty stream with strict accumulatorvectorYield a + of the given length containing the values x, x+y, x+y+y etc.vectorEnumerate valuesWARNING: This operations can be very inefficient. If at all possible, use  instead.vector#Enumerate values with a given step.WARNING:? This operations is very inefficient. If at all possible, use  instead.vector Convert a  to a listvector Create a  from a listvector Create a  from the first n elements of a list %fromListN n xs = fromList (take n xs)vector Create a  of values from a  of streamable thingsvectorstarting indexvectorlengthFGHIFGHI59 9 44  (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone ?C$vector?Create a new mutable vector and fill it with elements from the . The vector will grow exponentially if the maximum size of the  is unknown.vectorCreate a new mutable vector and fill it with elements from the monadic stream. The vector will grow exponentially if the maximum size of the stream is unknown.vector?Create a new mutable vector and fill it with elements from the . The vector will grow exponentially if the maximum size of the  is unknown.vector?Create a new mutable vector and fill it with elements from the  from right to left. The vector will grow exponentially if the maximum size of the  is unknown.vectorCreate a new mutable vector and fill it with elements from the monadic stream from right to left. The vector will grow exponentially if the maximum size of the stream is unknown.vectorLength of the mutable vector.vector!Check whether the vector is emptyvectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vector"Check whether two vectors overlap.vector,Create a mutable vector of the given length.vectorCreate a mutable vector of the given length. The vector content should be presumed uninitialized. However exact semantics depends on vector implementation. For example unboxed and storable vectors will create vector filled with whatever underlying memory buffer happens to contain, while boxed vector's elements are initialized to bottoms which will throw exception when evaluated.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action.vector"Create a copy of a mutable vector.vectorGrow a vector by the given number of elements. The number must not be negative otherwise error is thrown. Semantics of this function is exactly the same as , except that it will initialize the newly allocated memory first.It is important to note that mutating the returned vector will not affect the vector that was used as a source. In other words it does not, nor will it ever have the semantics of realloc from C. grow mv 0 === clone mv vectorSame as , except that it copies data towards the end of the newly allocated vector making extra space available at the beginning.vectorGrow a vector by allocating a new mutable vector of the same size plus the the given number of elements and copying all the data over to the new vector starting at its beginning. The newly allocated memory is not initialized and the extra space at the end will likely contain garbage data or uninitialzed error. Use  to make the extra space available in the front of the new vector.It is important to note that mutating the returned vector will not affect elements of the vector that was used as a source. In other words it does not, nor will it ever have the semantics of realloc from C. Keep in mind, however, that values themselves can be of a mutable type (eg. ), in which case it would be possible to affect values stored in both vectors. unsafeGrow mv 0 === clone mv vectorSame as , except that it copies data towards the end of the newly allocated vector making extra space available at the beginning.vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors.vector(Yield the element at the given position.vector*Replace the element at the given position.vector)Modify the element at the given position.vector)Swap the elements at the given positions.vectorReplace the element at the given position and return the old element.vectorYield the element at the given position. No bounds checks are performed.vectorReplace the element at the given position. No bounds checks are performed.vectorModify the element at the given position. No bounds checks are performed.vectorSwap the elements at the given positions. No bounds checks are performed.vectorReplace the element at the given position and return the old element. No bounds checks are performed.vector2Set all elements of the vector to the given value.vectorCopy a vector. The two vectors must have the same length and may not overlap.vectorMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorCopy a vector. The two vectors must have the same length and may not overlap. This is not checked.vectorMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorCompute the next (lexicographically) permutation of given vector in-place. Returns False when input is the last permutationvectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevector'A mutable vector to copy the data from.vectorNumber of elements to grow the vector by. It must be non-negative but this is not checked.vectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource!"#$%&'()*+,-.!"#$%&'()*+,-.  (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone? (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone ?vectorO(1) Yield the length of the vectorvectorO(1) Test whether a vector is emptyvector O(1) IndexingvectorO(1) Safe indexingvectorO(1) First elementvectorO(1) Last elementvectorO(1)( Unsafe indexing without bounds checkingvectorO(1)6 First element without checking if the vector is emptyvectorO(1)5 Last element without checking if the vector is emptyvectorO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not% the elements) is evaluated eagerly.vectorO(1)+ First element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)* Last element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)0 Indexing in a monad without bounds checks. See + for an explanation of why this is useful.vectorO(1) First element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Last element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements.vectorO(1) Yield all but the last element without copying. The vector may not be empty.vectorO(1) Yield all but the first element without copying. The vector may not be empty.vectorO(1) Yield the first n= elements without copying. The vector may contain less than n1 elements in which case it is returned unchanged.vectorO(1) Yield all but the first n= elements without copying. The vector may contain less than n4 elements in which case an empty vector is returned.vectorO(1) Yield the first n4 elements paired with the remainder without copying. Note that  n v is equivalent to ( n v,  n v) but slightly more efficient. vectorO(1) Yield the  and  of the vector, or   if empty. vectorO(1) Yield the  and  of the vector, or   if empty.vectorO(1) Yield a slice of the vector without copying. The vector must contain at least i+n" elements but this is not checked.vectorO(1) Yield all but the last element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield all but the first element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Yield all but the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Empty vectorvectorO(1) Vector with exactly one elementvectorO(n) Vector of the given length with the same value in each positionvectorO(n) Construct a vector of the given length by applying the function to each indexvectorO(n) Apply function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} vectorO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1>vectorO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8> vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8>vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed.vectorO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in vectorO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in vectorO(n): Yield a vector of the given length containing the values x, x+15 etc. This operation is usually more efficient than . enumFromN 5 3 = <5,6,7>vectorO(n): Yield a vector of the given length containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than . +enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>vectorO(n) Enumerate values from x to y.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Prepend an elementvectorO(n) Append an elementvectorO(m+n) Concatenate two vectorsvectorO(n)$ Concatenate all vectors in the listvectorO(n). Concatenate all vectors in the non-empty listvectorO(n) Execute the monadic action the given number of times and store the results in a vector.vectorO(n) Construct a vector of the given length by applying the monadic action to each index vectorO(n) Apply monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector.For non-monadic version see vector;Execute the monadic action and freeze the resulting vector. create (do { v <-  2;  v 0 'a';  v 1 'b'; return v }) = <a,b> vector)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected.vectorO(m+n) For each pair (i,a)8 from the list, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>vectorO(m+n) For each pair (i,a) from the vector of index/value pairs, replace the vector element at position i by a. 0update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>)This function is useful for instances of /& that cannot store pairs. Otherwise,  is probably more convenient. update_ xs is ys =  xs ( is ys) vector Same as () but without bounds checking.vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples!import qualified Data.Vector as VV.accum (+) (V.fromList [1000.0,2000.0,3000.0]) [(2,4),(1,6),(0,3),(1,10)][1003.0,2016.0,3004.0]vectorO(m+n) For each pair (i,b)7 from the vector of pairs, replace the vector element a at position i by f a b.Examples!import qualified Data.Vector as VV.accumulate (+) (V.fromList [1000.0,2000.0,3000.0]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])[1003.0,2016.0,3004.0]vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>)This function is useful for instances of /& that cannot store pairs. Otherwise,  is probably more convenient: accumulate_ f as is bs =  f as ( is bs) vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorO(n) Reverse a vectorvectorO(n)5 Yield the vector obtained by replacing each element i of the index vector by xsi. This is equivalent to  (xs) is# but is often much more efficient. 3backpermute <0,3,2,3,1,0> = vectorSame as  but without bounds checking.vectorApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v ->  v 0 'x') ( 3 'a') = <'x','a','a'> vectorO(n)- Pair each element in a vector with its indexvectorO(n) Map a function over a vectorvectorO(n)< Apply a function to every element of a vector and its indexvector9Map a function over a vector and concatenate the results.vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of resultsvectorO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of resultsvectorO(n) Apply the monadic action to all elements of a vector and ignore the resultsvectorO(n) Apply the monadic action to every element of a vector and its index, ignoring the resultsvectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip .vectorO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip . vectorO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to   . vectorO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to   .vector O(min(m,n))) Zip two vectors with the given function.vector*Zip three vectors with the given function.vector O(min(m,n)) Zip two vectors with a function that also takes the elements' indices.vector O(min(m,n)) Zip two vectorsvector O(min(m,n)) Zip the two vectors with the monadic action and yield a vector of resultsvector O(min(m,n)) Zip the two vectors with a monadic action that also takes the element index and yield a vector of resultsvector O(min(m,n)) Zip the two vectors with the monadic action and ignore the resultsvector O(min(m,n)) Zip the two vectors with a monadic action that also takes the element index and ignore the resultsvector O(min(m,n)) Unzip a vector of pairs.vectorO(n)0 Drop elements that do not satisfy the predicatevectorO(n) Drop elements that do not satisfy the predicate which is applied to values and their indicesvectorO(n)! Drop repeated adjacent elements.vectorO(n)- Drop elements when predicate returns NothingvectorO(n) Drop elements when predicate, applied to index and value, returns NothingvectorO(n)8 Drop elements that do not satisfy the monadic predicate vectorO(n) Apply monadic function to each element of vector and discard elements returning Nothing. vectorO(n) Apply monadic function to each element of vector and its index. Discards elements returning Nothing.vectorO(n) Yield the longest prefix of elements satisfying the predicate. Current implementation is not copy-free, unless the result vector is fused away.vectorO(n) Drop the longest prefix of elements that satisfy the predicate without copying.vectorO(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 relative order of the elements is preserved at the cost of a sometimes reduced performance compared to . vectorO(n) Split the vector into two parts, the first one containing the  ( elements and the second containing the  < elements. The relative order of the elements is preserved.vectorO(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 but the operation is often faster than .vectorO(n) Split the vector into the longest prefix of elements that satisfy the predicate and the rest without copying.vectorO(n) Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.vectorO(n)( Check if the vector contains an elementvectorO(n)= Check if the vector does not contain an element (inverse of )vectorO(n) Yield  - the first element matching the predicate or   if no such element exists.vectorO(n) Yield  ; the index of the first element matching the predicate or   if no such element exists. vectorO(n) Yield   the index of the last$ element matching the predicate or   if no such element exists.vectorO(n) Yield the indices of elements satisfying the predicate in ascending order.vectorO(n) Yield  ; the index of the first occurence of the given element or   if the vector does not contain the element. This is a specialised version of .vectorO(n) Yield the indices of all occurences of the given element in ascending order. This is a specialised version of .vectorO(n) Left foldvectorO(n) Left fold on non-empty vectorsvectorO(n)" Left fold with strict accumulatorvectorO(n)7 Left fold on non-empty vectors with strict accumulatorvectorO(n) Right foldvectorO(n) Right fold on non-empty vectorsvectorO(n)% Right fold with a strict accumulatorvectorO(n)8 Right fold on non-empty vectors with strict accumulatorvectorO(n); Left fold (function applied to each element and its index)vectorO(n) Left fold with strict accumulator (function applied to each element and its index)vectorO(n)< Right fold (function applied to each element and its index)vectorO(n) Right fold with strict accumulator (function applied to each element and its index) vectorO(n) Map each element of the structure to a monoid, and combine the results. It uses same implementation as corresponding method of  / type cless. Note it's implemented in terms of  and won't fuse with functions that traverse vector from left to right (, , etc.). vectorO(n)  which is strict in accumulator. It uses same implementation as corresponding method of  0 type class. Note it's implemented in terms of  so it fuses in most contexts.vectorO(n)- Check if all elements satisfy the predicate.Examples!import qualified Data.Vector as V)V.all even $ V.fromList [2, 4, 12 :: Int]True)V.all even $ V.fromList [2, 4, 13 :: Int]False$V.all even (V.empty :: V.Vector Int)TruevectorO(n). Check if any element satisfies the predicate.Examples!import qualified Data.Vector as V(V.any even $ V.fromList [1, 3, 7 :: Int]False)V.any even $ V.fromList [3, 2, 13 :: Int]True$V.any even (V.empty :: V.Vector Int)FalsevectorO(n) Check if all elements are  Examples!import qualified Data.Vector as V V.and $ V.fromList [True, False]False V.and V.emptyTruevectorO(n) Check if any element is  Examples!import qualified Data.Vector as VV.or $ V.fromList [True, False]True V.or V.emptyFalsevectorO(n) Compute the sum of the elementsExamples!import qualified Data.Vector as V$V.sum $ V.fromList [300,20,1 :: Int]321V.sum (V.empty :: V.Vector Int)0vectorO(n)$ Compute the produce of the elementsExamples!import qualified Data.Vector as V'V.product $ V.fromList [1,2,3,4 :: Int]24#V.product (V.empty :: V.Vector Int)1vectorO(n) Yield the maximum element of the vector. The vector may not be empty.Examples!import qualified Data.Vector as V!V.maximum $ V.fromList [2.0, 1.0]2.0vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty.vectorO(n) Yield the minimum element of the vector. The vector may not be empty.Examples!import qualified Data.Vector as V!V.minimum $ V.fromList [2.0, 1.0]1.0vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty.vectorO(n) Yield the index of the maximum element of the vector. The vector may not be empty.vectorO(n) Yield the index of the maximum element of the vector according to the given comparison function. The vector may not be empty.vectorO(n) Yield the index of the minimum element of the vector. The vector may not be empty.vectorO(n) Yield the index of the minimum element of the vector according to the given comparison function. The vector may not be empty.vectorO(n) Monadic foldvectorO(n)< Monadic fold (action applied to each element and its index)vectorO(n)$ Monadic fold over non-empty vectorsvectorO(n)% Monadic fold with strict accumulatorvectorO(n) Monadic fold with strict accumulator (action applied to each element and its index)vectorO(n)< Monadic fold over non-empty vectors with strict accumulatorvectorO(n)& Monadic fold that discards the resultvectorO(n) Monadic fold that discards the result (action applied to each element and its index)vectorO(n)= Monadic fold over non-empty vectors that discards the resultvectorO(n)> Monadic fold with strict accumulator that discards the resultvectorO(n) Monadic fold with strict accumulator that discards the result (action applied to each element and its index)vectorO(n) Monad fold over non-empty vectors with strict accumulator that discards the resultvector,Evaluate each action and collect the resultsvector,Evaluate each action and discard the resultsvectorO(n) Prescan prescanl f z =  .  f z  Example: $prescanl (+) 0 <1,2,3,4> = <0,1,3,6>vectorO(n) Prescan with strict accumulatorvectorO(n) Scan postscanl f z =  .  f z  Example: &postscanl (+) 0 <1,2,3,4> = <1,3,6,10>vectorO(n) Scan with strict accumulatorvectorO(n) Haskell-style scan scanl f z = where y1 = z yi = f y(i-1) x(i-1) Example: $scanl (+) 0 <1,2,3,4> = <0,1,3,6,10>vectorO(n)+ Haskell-style scan with strict accumulatorvectorO(n)" Scan over a vector with its indexvectorO(n)- Scan over a vector (strictly) with its indexvectorO(n) Scan over a non-empty vector scanl f = where y1 = x1 yi = f y(i-1) xivectorO(n)7 Scan over a non-empty vector with a strict accumulatorvectorO(n) Right-to-left prescan prescanr f z =  .  (flip f) z .  vectorO(n). Right-to-left prescan with strict accumulatorvectorO(n) Right-to-left scanvectorO(n)+ Right-to-left scan with strict accumulatorvectorO(n)! Right-to-left Haskell-style scanvectorO(n)9 Right-to-left Haskell-style scan with strict accumulatorvectorO(n)0 Right-to-left scan over a vector with its indexvectorO(n); Right-to-left scan over a vector (strictly) with its indexvectorO(n)+ Right-to-left scan over a non-empty vectorvectorO(n) Right-to-left scan over a non-empty vector with a strict accumulatorvectorO(n) Convert a vector to a listvectorO(n) Convert a list to a vectorvectorO(n) Convert the first n elements of a list to a vector fromListN n xs =  ( n xs) Examples!import qualified Data.Vector as VV.fromListN 3 [1,2,3,4,5::Int][1,2,3]V.fromListN 3 [1::Int][1]vectorO(n) Convert different vector typesvectorO(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation.vectorO(n)/ Yield an immutable copy of the mutable vector.vectorO(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation.vectorO(n). Yield a mutable copy of the immutable vector.vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length.vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked.vectorO(1) Convert a vector to a vectorO(n) Construct a vector from a vectorO(1) Convert a vector to a , proceeding from right to leftvectorO(n) Construct a vector from a , proceeding from right to left vectorLoad monadic stream bundle into a newly allocated vector. This function goes through a list, so prefer using #, unless you need to be in a monad.vector.Construct a vector from a monadic initialiser.vectorConvert a vector to an initialiser which, when run, produces a copy of the vector.vectorO(n)% Check if two vectors are equal. All /" instances are also instances of   and it is usually more appropriate to use those. This function is primarily intended for implementing  ! instances for new vector types.vectorO(n) Check if two vectors are equal using supplied equality predicate.vectorO(n), Compare two vectors lexicographically. All /" instances are also instances of  and it is usually more appropriate to use those. This function is primarily intended for implementing ! instances for new vector types.vectorO(n) Compare two vectors using supplied comparison function for vector elements. Comparison works same as for lists. cmpBy compare == cmpvectorGeneric definition of vectorGeneric definition of vectorNote: uses vectorGeneric definion of  that views a / as a list. vectori starting indexvectorn lengthvectori starting indexvectorn lengthvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectorinitial vector (of length m)vector'vector of index/value pairs (of length n)vectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)vectoraccumulating function fvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectoraccumulating function fvectorinitial vector (of length m)vector'vector of index/value pairs (of length n)vectoraccumulating function fvectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)vectorxs value vectorvectoris index vector (of length n)/23501467/235014679 9 544  (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone 3>uvector7Mutable boxed vectors keyed on the monad they live in ( or ST s).vectorLength of the mutable vector.vector!Check whether the vector is emptyvectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vector"Check whether two vectors overlap.vector,Create a mutable vector of the given length.vectorCreate a mutable vector of the given length. The vector elements are set to bottom so accessing them will cause an exception.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action.vector"Create a copy of a mutable vector.vectorGrow a boxed vector by the given number of elements. The number must be non-negative. Same semantics as in & for generic vector. It differs from grow functions for unpacked vectors, however, in that only pointers to values are copied over, therefore values themselves will be shared between two vectors. This is an important distinction to know about during memory usage analysis and in case when values themselves are of a mutable type, eg.  or another mutable vector.Examples!import qualified Data.Vector as V*import qualified Data.Vector.Mutable as MV5mv <- V.thaw $ V.fromList ([10, 20, 30] :: [Integer])mv' <- MV.grow mv 2The two extra elements at the end of the newly allocated vector will be uninitialized and will result in an error if evaluated, so me must overwrite them with new values first:MV.write mv' 3 999MV.write mv' 4 777V.unsafeFreeze mv'[10,20,30,999,777]It is important to note that the source mutable vector is not affected when the newly allocated one is mutated.MV.write mv' 2 888V.unsafeFreeze mv'[10,20,888,999,777]V.unsafeFreeze mv [10,20,30]vectorGrow a vector by the given number of elements. The number must be non-negative but this is not checked. Same semantics as in  for generic vector.vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors.vector(Yield the element at the given position.vector*Replace the element at the given position.vector)Modify the element at the given position.vector)Swap the elements at the given positions.vectorYield the element at the given position. No bounds checks are performed.vectorReplace the element at the given position. No bounds checks are performed.vectorModify the element at the given position. No bounds checks are performed.vectorSwap the elements at the given positions. No bounds checks are performed.vector2Set all elements of the vector to the given value.vectorCopy a vector. The two vectors must have the same length and may not overlap.vectorCopy a vector. The two vectors must have the same length and may not overlap. This is not checked.vectorMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorCompute the next (lexicographically) permutation of given vector in-place. Returns False when input is the last permutation vectorO(n)8 Make a copy of a mutable array to a new mutable vector. vectorO(n): Make a copy of a mutable vector into a new mutable array.vectorOffset in underlying arrayvector Size of slicevectorUnderlying arrayvectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource** (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone 3>~$vector,Boxed vectors, supporting efficient slicing.vectorO(1) Yield the length of the vectorvectorO(1) Test whether a vector is emptyvector O(1) IndexingvectorO(1) Safe indexingvectorO(1) First elementvectorO(1) Last elementvectorO(1)( Unsafe indexing without bounds checkingvectorO(1)6 First element without checking if the vector is emptyvectorO(1)5 Last element without checking if the vector is emptyvectorO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not% the elements) is evaluated eagerly.vectorO(1)+ First element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)* Last element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)0 Indexing in a monad without bounds checks. See + for an explanation of why this is useful.vectorO(1) First element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Last element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements.vectorO(1) Yield all but the last element without copying. The vector may not be empty.vectorO(1) Yield all but the first element without copying. The vector may not be empty.vectorO(1) Yield at the first n= elements without copying. The vector may contain less than n1 elements in which case it is returned unchanged.vectorO(1) Yield all but the first n= elements without copying. The vector may contain less than n4 elements in which case an empty vector is returned.vectorO(1) Yield the first n4 elements paired with the remainder without copying. Note that  n v is equivalent to ( n v,  n v) but slightly more efficient. vectorO(1) Yield the  and  of the vector, or   if empty. vectorO(1) Yield the  and  of the vector, or   if empty.vectorO(1) Yield a slice of the vector without copying. The vector must contain at least i+n" elements but this is not checked.vectorO(1) Yield all but the last element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield all but the first element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Yield all but the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Empty vectorvectorO(1) Vector with exactly one elementvectorO(n) Vector of the given length with the same value in each positionvectorO(n) Construct a vector of the given length by applying the function to each indexvectorO(n) Apply function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} Examples!import qualified Data.Vector as V3V.iterateN 0 undefined undefined :: V.Vector String[] V.iterateN 4 (\x -> x <> x) "Hi"+["Hi","HiHi","HiHiHiHi","HiHiHiHiHiHiHiHi"]vectorO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1>vectorO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8> vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8>vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed.vectorO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in vectorO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in vectorO(n): Yield a vector of the given length containing the values x, x+15 etc. This operation is usually more efficient than . enumFromN 5 3 = <5,6,7>vectorO(n): Yield a vector of the given length containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than . +enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>vectorO(n) Enumerate values from x to y.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Prepend an elementvectorO(n) Append an elementvectorO(m+n) Concatenate two vectorsvectorO(n)$ Concatenate all vectors in the listvectorO(n) Execute the monadic action the given number of times and store the results in a vector.vectorO(n) Construct a vector of the given length by applying the monadic action to each index vectorO(n) Apply monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector.For non-monadic version see vector;Execute the monadic action and freeze the resulting vector. create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b> vector)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected.vectorO(m+n) For each pair (i,a)8 from the list, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>vectorO(m+n) For each pair (i,a) from the vector of index/value pairs, replace the vector element at position i by a. 0update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7> The function  provides the same functionality and is usually more convenient. update_ xs is ys =  xs ( is ys) vector Same as () but without bounds checking.vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples!import qualified Data.Vector as VV.accum (+) (V.fromList [1000.0,2000.0,3000.0]) [(2,4),(1,6),(0,3),(1,10)][1003.0,2016.0,3004.0]vectorO(m+n) For each pair (i,b)7 from the vector of pairs, replace the vector element a at position i by f a b.Examples!import qualified Data.Vector as VV.accumulate (+) (V.fromList [1000.0,2000.0,3000.0]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])[1003.0,2016.0,3004.0]vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4> The function  provides the same functionality and is usually more convenient. accumulate_ f as is bs =  f as ( is bs) vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorO(n) Reverse a vectorvectorO(n)5 Yield the vector obtained by replacing each element i of the index vector by xsi. This is equivalent to  (xs) is# but is often much more efficient. 3backpermute <0,3,2,3,1,0> = vectorSame as  but without bounds checking.vectorApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v -> write v 0 'x') ( 3 'a') = <'x','a','a'> vectorO(n)- Pair each element in a vector with its indexvectorO(n) Map a function over a vectorvectorO(n)< Apply a function to every element of a vector and its indexvector9Map a function over a vector and concatenate the results.vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of resultsvectorO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of resultsvectorO(n) Apply the monadic action to all elements of a vector and ignore the resultsvectorO(n) Apply the monadic action to every element of a vector and its index, ignoring the resultsvectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip .vectorO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip . vectorO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to   . vectorO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to   .vector O(min(m,n))) Zip two vectors with the given function.vector*Zip three vectors with the given function.vector O(min(m,n)) Zip two vectors with a function that also takes the elements' indices.vector Monadic fold with strict accumulator that discards the resultvectorO(n) Monadic fold with strict accumulator that discards the result (action applied to each element and its index)vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the resultvector,Evaluate each action and collect the resultsvector,Evaluate each action and discard the resultsvectorO(n) Prescan prescanl f z =  .  f z  Example: $prescanl (+) 0 <1,2,3,4> = <0,1,3,6>vectorO(n) Prescan with strict accumulatorvectorO(n) Scan postscanl f z =  .  f z  Example: &postscanl (+) 0 <1,2,3,4> = <1,3,6,10>vectorO(n) Scan with strict accumulatorvectorO(n) Haskell-style scan scanl f z = where y1 = z yi = f y(i-1) x(i-1) Example: $scanl (+) 0 <1,2,3,4> = <0,1,3,6,10>vectorO(n)+ Haskell-style scan with strict accumulator vectorO(n)" Scan over a vector with its index vectorO(n)- Scan over a vector (strictly) with its indexvectorO(n) Scan over a non-empty vector scanl f = where y1 = x1 yi = f y(i-1) xivectorO(n)7 Scan over a non-empty vector with a strict accumulatorvectorO(n) Right-to-left prescan prescanr f z =  .  (flip f) z .  vectorO(n). Right-to-left prescan with strict accumulatorvectorO(n) Right-to-left scanvectorO(n)+ Right-to-left scan with strict accumulatorvectorO(n)! Right-to-left Haskell-style scanvectorO(n)9 Right-to-left Haskell-style scan with strict accumulator vectorO(n)0 Right-to-left scan over a vector with its index vectorO(n); Right-to-left scan over a vector (strictly) with its indexvectorO(n)+ Right-to-left scan over a non-empty vectorvectorO(n) Right-to-left scan over a non-empty vector with a strict accumulator vectorO(n) Check if two vectors are equal using supplied equality predicate. vectorO(n) Compare two vectors using supplied comparison function for vector elements. Comparison works same as for lists. cmpBy compare == comparevectorO(n) Convert a vector to a listvectorO(n) Convert a list to a vectorvectorO(n) Convert the first n elements of a list to a vector fromListN n xs =  ( n xs)  vectorO(1) Convert an array to a vector. vectorO(n) Convert a vector to an array.vectorO(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation.vectorO(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation.vectorO(n). Yield a mutable copy of the immutable vector.vectorO(n)/ Yield an immutable copy of the mutable vector.vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked.vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. vector,Instance has same semantics as one for lists vector vectorvectori starting indexvectorn lengthvectori starting indexvectorn lengthvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectorinitial vector (of length m)vector'vector of index/value pairs (of length n)vectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)vectoraccumulating function fvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectoraccumulating function fvectorinitial vector (of length m)vector'vector of index/value pairs (of length n)vectoraccumulating function fvectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)544 (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone3>Qvector#Mutable vectors of primitive types.vector-offset, length, underlying mutable byte arrayvectorLength of the mutable vector.vector!Check whether the vector is emptyvectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vector"Check whether two vectors overlap.vector,Create a mutable vector of the given length.vectorCreate a mutable vector of the given length. The vector content is uninitialized, which means it is filled with whatever underlying memory buffer happens to contain.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action.vector"Create a copy of a mutable vector.vectorGrow a primitive vector by the given number of elements. The number must be non-negative. Same semantics as in  for generic vector.Examples,import qualified Data.Vector.Primitive as VP5import qualified Data.Vector.Primitive.Mutable as MVP3mv <- VP.thaw $ VP.fromList ([10, 20, 30] :: [Int])mv' <- MVP.grow mv 2Extra memory at the end of the newly allocated vector is initialized to 0 bytes, which for  instance will usually correspond to some default value for a particular type, eg. 0 for Int, NUL for Char, etc. However, if  was used instead this would not have been guaranteed and some garbage would be there instead:VP.unsafeFreeze mv'[10,20,30,0,0]8Having the extra space we can write new values in there:MVP.write mv' 3 999VP.unsafeFreeze mv'[10,20,30,999,0]It is important to note that the source mutable vector is not affected when the newly allocated one is mutated.MVP.write mv' 2 888VP.unsafeFreeze mv'[10,20,888,999,0]VP.unsafeFreeze mv [10,20,30]vectorGrow a vector by the given number of elements. The number must be non-negative but this is not checked. Same semantics as in  for generic vector.vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors.vector(Yield the element at the given position.vector*Replace the element at the given position.vector)Modify the element at the given position.vector)Swap the elements at the given positions.vectorYield the element at the given position. No bounds checks are performed.vectorReplace the element at the given position. No bounds checks are performed.vectorModify the element at the given position. No bounds checks are performed.vectorSwap the elements at the given positions. No bounds checks are performed.vector2Set all elements of the vector to the given value.vectorCopy a vector. The two vectors must have the same length and may not overlap.vectorCopy a vector. The two vectors must have the same length and may not overlap. This is not checked.vectorMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.vectorCompute the next (lexicographically) permutation of given vector in-place. Returns False when input is the last permutationvectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource)) (c) Roman Leshchinskiy 2008-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone 3>ȴvector"Unboxed vectors of primitive typesvector%offset, length, underlying byte arrayvectorO(1) Yield the length of the vectorvectorO(1) Test whether a vector is emptyvector O(1) IndexingvectorO(1) Safe indexingvectorO(1) First elementvectorO(1) Last elementvectorO(1)( Unsafe indexing without bounds checkingvectorO(1)6 First element without checking if the vector is emptyvectorO(1)5 Last element without checking if the vector is emptyvectorO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not% the elements) is evaluated eagerly.vectorO(1)+ First element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)* Last element of a vector in a monad. See + for an explanation of why this is useful.vectorO(1)0 Indexing in a monad without bounds checks. See + for an explanation of why this is useful.vectorO(1) First element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Last element in a monad without checking for empty vectors. See * for an explanation of why this is useful.vectorO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements.vectorO(1) Yield all but the last element without copying. The vector may not be empty.vectorO(1) Yield all but the first element without copying. The vector may not be empty.vectorO(1) Yield at the first n= elements without copying. The vector may contain less than n1 elements in which case it is returned unchanged.vectorO(1) Yield all but the first n= elements without copying. The vector may contain less than n4 elements in which case an empty vector is returned.vectorO(1) Yield the first n4 elements paired with the remainder without copying. Note that  n v is equivalent to ( n v,  n v) but slightly more efficient. vectorO(1) Yield the  and  of the vector, or   if empty. vectorO(1) Yield the  and  of the vector, or   if empty.vectorO(1) Yield a slice of the vector without copying. The vector must contain at least i+n" elements but this is not checked.vectorO(1) Yield all but the last element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield all but the first element without copying. The vector may not be empty but this is not checked.vectorO(1) Yield the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Yield all but the first n= elements without copying. The vector must contain at least n" elements but this is not checked.vectorO(1) Empty vectorvectorO(1) Vector with exactly one elementvectorO(n) Vector of the given length with the same value in each positionvectorO(n) Construct a vector of the given length by applying the function to each indexvectorO(n) Apply function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} Examples,import qualified Data.Vector.Primitive as VP2VP.iterateN 0 undefined undefined :: VP.Vector Int[]VP.iterateN 26 succ 'a'"abcdefghijklmnopqrstuvwxyz"vectorO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1>vectorO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8> vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8>vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed.vectorO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in vectorO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in vectorO(n): Yield a vector of the given length containing the values x, x+15 etc. This operation is usually more efficient than . enumFromN 5 3 = <5,6,7>vectorO(n): Yield a vector of the given length containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than . +enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>vectorO(n) Enumerate values from x to y.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING: This operation can be very inefficient. If at all possible, use  instead.vectorO(n) Prepend an elementvectorO(n) Append an elementvectorO(m+n) Concatenate two vectorsvectorO(n)$ Concatenate all vectors in the listvectorO(n) Execute the monadic action the given number of times and store the results in a vector.vectorO(n) Construct a vector of the given length by applying the monadic action to each index vectorO(n) Apply monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector.For non-monadic version see vector;Execute the monadic action and freeze the resulting vector. create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b> vector)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected.vectorO(m+n) For each pair (i,a)8 from the list, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>vector Same as () but without bounds checking.vectorSame as  but without bounds checking.vectorO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples,import qualified Data.Vector.Primitive as VPVP.accum (+) (VP.fromList [1000.0,2000.0,3000.0]) [(2,4),(1,6),(0,3),(1,10)][1003.0,2016.0,3004.0]vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>vectorSame as  but without bounds checking.vectorSame as  but without bounds checking.vectorO(n) Reverse a vectorvectorO(n)5 Yield the vector obtained by replacing each element i of the index vector by xsi. This is equivalent to  (xs) is# but is often much more efficient. 3backpermute <0,3,2,3,1,0> = vectorSame as  but without bounds checking.vectorApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v -> write v 0 'x') ( 3 'a') = <'x','a','a'> vectorO(n) Map a function over a vectorvectorO(n)< Apply a function to every element of a vector and its indexvector9Map a function over a vector and concatenate the results.vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results vectorO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of resultsvectorO(n) Apply the monadic action to all elements of a vector and ignore the results vectorO(n) Apply the monadic action to every element of a vector and its index, ignoring the resultsvectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip .vectorO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip . vectorO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to   . vectorO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to   .vector O(min(m,n))) Zip two vectors with the given function.vector*Zip three vectors with the given function.vector O(min(m,n)) Zip two vectors with a function that also takes the elements' indices.vector Monadic fold with strict accumulator that discards the result  vectorO(n) Monadic fold with strict accumulator that discards the result (action applied to each element and its index) vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result vectorO(n) Prescan prescanl f z =  .   f z  Example: $prescanl (+) 0 <1,2,3,4> = <0,1,3,6> vectorO(n) Prescan with strict accumulator vectorO(n) Scan postscanl f z =  .   f z  Example: &postscanl (+) 0 <1,2,3,4> = <1,3,6,10> vectorO(n) Scan with strict accumulator vectorO(n) Haskell-style scan scanl f z = where y1 = z yi = f y(i-1) x(i-1) Example: $scanl (+) 0 <1,2,3,4> = <0,1,3,6,10> vectorO(n)+ Haskell-style scan with strict accumulator  vectorO(n)" Scan over a vector with its index  vectorO(n)- Scan over a vector (strictly) with its index vectorO(n) Scan over a non-empty vector scanl f = where y1 = x1 yi = f y(i-1) xi vectorO(n)7 Scan over a non-empty vector with a strict accumulator vectorO(n) Right-to-left prescan prescanr f z =  .   (flip f) z .  vectorO(n). Right-to-left prescan with strict accumulator vectorO(n) Right-to-left scan vectorO(n)+ Right-to-left scan with strict accumulator vectorO(n)! Right-to-left Haskell-style scan vectorO(n)9 Right-to-left Haskell-style scan with strict accumulator  vectorO(n)0 Right-to-left scan over a vector with its index  vectorO(n); Right-to-left scan over a vector (strictly) with its index vectorO(n)+ Right-to-left scan over a non-empty vector vectorO(n) Right-to-left scan over a non-empty vector with a strict accumulator  vectorO(n) Check if two vectors are equal using supplied equality predicate.  vectorO(n) Compare two vectors using supplied comparison function for vector elements. Comparison works same as for lists. cmpBy compare == compare vectorO(n) Convert a vector to a list vectorO(n) Convert a list to a vector vectorO(n) Convert the first n elements of a list to a vector fromListN n xs =   ( n xs) Examples,import qualified Data.Vector.Primitive as VPVP.fromListN 3 [1,2,3,4,5::Int][1,2,3]VP.fromListN 3 [1::Int][1] vectorO(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation. vectorO(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation. vectorO(n). Yield a mutable copy of the immutable vector. vectorO(n)/ Yield an immutable copy of the mutable vector. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length.  vectorvectori starting indexvectorn lengthvectori starting indexvectorn lengthvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)vectoraccumulating function fvectorinitial vector (of length m)vector%list of index/value pairs (of length n)vectoraccumulating function fvectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)   544 (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone[   (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone 3> ! vectorMutable -based vectors vectorLength of the mutable vector. vector!Check whether the vector is empty vectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements. vectorYield a part of the mutable vector without copying it. No bounds checks are performed. vector"Check whether two vectors overlap. vector,Create a mutable vector of the given length. vectorCreate a mutable vector of the given length. The vector content is uninitialized, which means it is filled with whatever underlying memory buffer happens to contain. vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value. vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action. vector"Create a copy of a mutable vector. vectorGrow a storable vector by the given number of elements. The number must be non-negative. Same semantics as in  for generic vector.Examples+import qualified Data.Vector.Storable as VS4import qualified Data.Vector.Storable.Mutable as MVS3mv <- VS.thaw $ VS.fromList ([10, 20, 30] :: [Int])mv' <- MVS.grow mv 2Extra memory at the end of the newly allocated vector is initialized to 0 bytes, which for  instance will usually correspond to some default value for a particular type, eg. 0 for Int, False for Bool, etc. However, if   was used instead this would not have been guaranteed and some garbage would be there instead:VS.unsafeFreeze mv'[10,20,30,0,0]8Having the extra space we can write new values in there:MVS.write mv' 3 999VS.unsafeFreeze mv'[10,20,30,999,0]It is important to note that the source mutable vector is not affected when the newly allocated one is mutated.MVS.write mv' 2 888VS.unsafeFreeze mv'[10,20,888,999,0]VS.unsafeFreeze mv [10,20,30] vectorGrow a vector by the given number of elements. The number must be non-negative but this is not checked. Same semantics as in  for generic vector. vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors. vector(Yield the element at the given position. vector*Replace the element at the given position. vector)Modify the element at the given position. vector)Swap the elements at the given positions. vectorYield the element at the given position. No bounds checks are performed. vectorReplace the element at the given position. No bounds checks are performed. vectorModify the element at the given position. No bounds checks are performed. vectorSwap the elements at the given positions. No bounds checks are performed. vector2Set all elements of the vector to the given value. vectorCopy a vector. The two vectors must have the same length and may not overlap. vectorCopy a vector. The two vectors must have the same length and may not overlap. This is not checked. vectorMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to  . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector. vectorMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to  . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector. vectorO(1) Unsafely cast a mutable vector from one element type to another. The operation just changes the type of the underlying pointer and does not modify the elements.The resulting vector contains as many elements as can fit into the underlying memory block. vectorCreate a mutable vector from a  with an offset and a length.Modifying data through the  afterwards is unsafe if the vector could have been frozen before the modification.0If your offset is 0 it is more efficient to use  . vectorO(1) Create a mutable vector from a  and a length.It is assumed the pointer points directly to the data (no offset). Use  " if you need to specify an offset.Modifying data through the  afterwards is unsafe if the vector could have been frozen before the modification. vectorYield the underlying  together with the offset to the data and its length. Modifying the data through the  is unsafe if the vector could have frozen before the modification. vectorO(1) Yield the underlying  together with its length.You can assume the pointer points directly to the data (no offset).Modifying the data through the  is unsafe if the vector could have frozen before the modification. vectorPass a pointer to the vector's data to the IO action. Modifying data through the pointer is unsafe if the vector could have been frozen before the modification. vectori starting indexvectorn length vectorstarting indexvectorlength of the slice vectortargetvectorsource vectortargetvectorsource vectortargetvectorsource vectortargetvectorsource vectorpointervectoroffsetvectorlength vectorpointervectorlength. .   (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone 3>p2 vector-based vectors vectorO(1) Yield the length of the vector vectorO(1) Test whether a vector is empty vector O(1) Indexing vectorO(1) Safe indexing vectorO(1) First element vectorO(1) Last element vectorO(1)( Unsafe indexing without bounds checking vectorO(1)6 First element without checking if the vector is empty vectorO(1)5 Last element without checking if the vector is empty vectorO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With  /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not% the elements) is evaluated eagerly. vectorO(1)+ First element of a vector in a monad. See  + for an explanation of why this is useful. vectorO(1)* Last element of a vector in a monad. See  + for an explanation of why this is useful. vectorO(1)0 Indexing in a monad without bounds checks. See  + for an explanation of why this is useful. vectorO(1) First element in a monad without checking for empty vectors. See  * for an explanation of why this is useful. vectorO(1) Last element in a monad without checking for empty vectors. See  * for an explanation of why this is useful. vectorO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements. vectorO(1) Yield all but the last element without copying. The vector may not be empty. vectorO(1) Yield all but the first element without copying. The vector may not be empty. vectorO(1) Yield at the first n= elements without copying. The vector may contain less than n1 elements in which case it is returned unchanged. vectorO(1) Yield all but the first n= elements without copying. The vector may contain less than n4 elements in which case an empty vector is returned. vectorO(1) Yield the first n4 elements paired with the remainder without copying. Note that   n v is equivalent to (  n v,   n v) but slightly more efficient.  vectorO(1) Yield the   and   of the vector, or   if empty.  vectorO(1) Yield the   and   of the vector, or   if empty. vectorO(1) Yield a slice of the vector without copying. The vector must contain at least i+n" elements but this is not checked. vectorO(1) Yield all but the last element without copying. The vector may not be empty but this is not checked. vectorO(1) Yield all but the first element without copying. The vector may not be empty but this is not checked. vectorO(1) Yield the first n= elements without copying. The vector must contain at least n" elements but this is not checked. vectorO(1) Yield all but the first n= elements without copying. The vector must contain at least n" elements but this is not checked. vectorO(1) Empty vector vectorO(1) Vector with exactly one element vectorO(n) Vector of the given length with the same value in each position vectorO(n) Construct a vector of the given length by applying the function to each index vectorO(n) Apply function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} Examples+import qualified Data.Vector.Storable as VS2VS.iterateN 0 undefined undefined :: VS.Vector Int[]VS.iterateN 26 succ 'a'"abcdefghijklmnopqrstuvwxyz" vectorO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1> vectorO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>  vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8> vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.  vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed. vectorO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in vectorO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in vectorO(n): Yield a vector of the given length containing the values x, x+15 etc. This operation is usually more efficient than  . enumFromN 5 3 = <5,6,7> vectorO(n): Yield a vector of the given length containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than  . +enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4> vectorO(n) Enumerate values from x to y.WARNING: This operation can be very inefficient. If at all possible, use   instead. vectorO(n) Enumerate values from x to y with a specific step z.WARNING: This operation can be very inefficient. If at all possible, use   instead. vectorO(n) Prepend an element vectorO(n) Append an element vectorO(m+n) Concatenate two vectors vectorO(n)$ Concatenate all vectors in the list vectorO(n) Execute the monadic action the given number of times and store the results in a vector. vectorO(n) Construct a vector of the given length by applying the monadic action to each index  vectorO(n) Apply monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector.For non-monadic version see  vector;Execute the monadic action and freeze the resulting vector. create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b> vector)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected. vectorO(m+n) For each pair (i,a)8 from the list, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7> vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7> vector Same as ( ) but without bounds checking. vectorSame as   but without bounds checking. vectorO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples+import qualified Data.Vector.Storable as VSVS.accum (+) (VS.fromList [1000.0,2000.0,3000.0]) [(2,4),(1,6),(0,3),(1,10)][1003.0,2016.0,3004.0] vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4> vectorSame as   but without bounds checking. vectorSame as   but without bounds checking. vectorO(n) Reverse a vector vectorO(n)5 Yield the vector obtained by replacing each element i of the index vector by xs i. This is equivalent to   (xs ) is# but is often much more efficient. 3backpermute <0,3,2,3,1,0> = vectorSame as   but without bounds checking. vectorApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v -> write v 0 'x') (  3 'a') = <'x','a','a'> vectorO(n) Map a function over a vector vectorO(n)< Apply a function to every element of a vector and its index vector9Map a function over a vector and concatenate the results. vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results  vectorO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of results vectorO(n) Apply the monadic action to all elements of a vector and ignore the results  vectorO(n) Apply the monadic action to every element of a vector and its index, ignoring the results vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip  . vectorO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip  .  vectorO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to    .  vectorO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to    . vector O(min(m,n))) Zip two vectors with the given function. vector*Zip three vectors with the given function. vector O(min(m,n)) Zip two vectors with a function that also takes the elements' indices. vector Monadic fold with strict accumulator that discards the result  vectorO(n) Monadic fold with strict accumulator that discards the result (action applied to each element and its index) vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result vectorO(n) Prescan prescanl f z =   .   f z  Example: $prescanl (+) 0 <1,2,3,4> = <0,1,3,6> vectorO(n) Prescan with strict accumulator vectorO(n) Scan postscanl f z =   .   f z  Example: &postscanl (+) 0 <1,2,3,4> = <1,3,6,10> vectorO(n) Scan with strict accumulator vectorO(n) Haskell-style scan scanl f z = where y1 = z yi = f y(i-1) x(i-1) Example: $scanl (+) 0 <1,2,3,4> = <0,1,3,6,10> vectorO(n)+ Haskell-style scan with strict accumulator  vectorO(n)" Scan over a vector with its index  vectorO(n)- Scan over a vector (strictly) with its index vectorO(n) Scan over a non-empty vector scanl f = where y1 = x1 yi = f y(i-1) xi vectorO(n)7 Scan over a non-empty vector with a strict accumulator vectorO(n) Right-to-left prescan prescanr f z =   .   (flip f) z .   vectorO(n). Right-to-left prescan with strict accumulator vectorO(n) Right-to-left scan vectorO(n)+ Right-to-left scan with strict accumulator vectorO(n)! Right-to-left Haskell-style scan vectorO(n)9 Right-to-left Haskell-style scan with strict accumulator  vectorO(n)0 Right-to-left scan over a vector with its index  vectorO(n); Right-to-left scan over a vector (strictly) with its index vectorO(n)+ Right-to-left scan over a non-empty vector vectorO(n) Right-to-left scan over a non-empty vector with a strict accumulator  vectorO(n) Check if two vectors are equal using supplied equality predicate.  vectorO(n) Compare two vectors using supplied comparison function for vector elements. Comparison works same as for lists. cmpBy compare == compare vectorO(n) Convert a vector to a list vectorO(n) Convert a list to a vector vectorO(n) Convert the first n elements of a list to a vector fromListN n xs =   (  n xs) Examples+import qualified Data.Vector.Storable as VSVS.fromListN 3 [1,2,3,4,5::Int][1,2,3]VS.fromListN 3 [1::Int][1] vectorO(1) Unsafely cast a vector from one element type to another. The operation just changes the type of the underlying pointer and does not modify the elements.The resulting vector contains as many elements as can fit into the underlying memory block. vectorO(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation. vectorO(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation. vectorO(n). Yield a mutable copy of the immutable vector. vectorO(n)/ Yield an immutable copy of the mutable vector. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. vectorO(1) Create a vector from a  with an offset and a length.)The data may not be modified through the  afterwards.0If your offset is 0 it is more efficient to use  . vectorO(1) Create a vector from a  and a length.It is assumed the pointer points directly to the data (no offset). Use  " if you need to specify an offset.)The data may not be modified through the  afterwards. vectorO(1) Yield the underlying  together with the offset to the data and its length. The data may not be modified through the . vectorO(1) Yield the underlying  together with its length.You can assume the pointer points directly to the data (no offset).)The data may not be modified through the . vectorPass a pointer to the vector's data to the IO action. The data may not be modified through the 'Ptr.  vector vectori starting indexvectorn length vectori starting indexvectorn length vectorinitial vector (of length m)vector%list of index/value pairs (of length n) vectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2) vectoraccumulating function fvectorinitial vector (of length m)vector%list of index/value pairs (of length n) vectoraccumulating function fvectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2) vectorpointervectoroffsetvectorlength vectorpointervectorlength     5 4 4 (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone .23?t vector vector   (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone vectorO(1) Yield the length of the vector vectorO(1) Test whether a vector is empty vector O(1) Indexing vectorO(1) Safe indexing vectorO(1) First element vectorO(1) Last element vectorO(1)( Unsafe indexing without bounds checking vectorO(1)6 First element without checking if the vector is empty vectorO(1)5 Last element without checking if the vector is empty vectorO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With  /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not% the elements) is evaluated eagerly. vectorO(1)+ First element of a vector in a monad. See  + for an explanation of why this is useful. vectorO(1)* Last element of a vector in a monad. See  + for an explanation of why this is useful. vectorO(1)0 Indexing in a monad without bounds checks. See  + for an explanation of why this is useful. vectorO(1) First element in a monad without checking for empty vectors. See  * for an explanation of why this is useful. vectorO(1) Last element in a monad without checking for empty vectors. See  * for an explanation of why this is useful. vectorO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements. vectorO(1) Yield all but the last element without copying. The vector may not be empty. vectorO(1) Yield all but the first element without copying. The vector may not be empty. vectorO(1) Yield at the first n= elements without copying. The vector may contain less than n1 elements in which case it is returned unchanged. vectorO(1) Yield all but the first n= elements without copying. The vector may contain less than n4 elements in which case an empty vector is returned. vectorO(1) Yield the first n4 elements paired with the remainder without copying. Note that   n v is equivalent to (  n v,   n v) but slightly more efficient.  vectorO(1) Yield the   and   of the vector, or   if empty.  vectorO(1) Yield the   and   of the vector, or   if empty. vectorO(1) Yield a slice of the vector without copying. The vector must contain at least i+n" elements but this is not checked. vectorO(1) Yield all but the last element without copying. The vector may not be empty but this is not checked. vectorO(1) Yield all but the first element without copying. The vector may not be empty but this is not checked. vectorO(1) Yield the first n= elements without copying. The vector must contain at least n" elements but this is not checked. vectorO(1) Yield all but the first n= elements without copying. The vector must contain at least n" elements but this is not checked. vectorO(1) Empty vector vectorO(1) Vector with exactly one element vectorO(n) Vector of the given length with the same value in each position vectorO(n) Construct a vector of the given length by applying the function to each index vectorO(n) Apply function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} Examples*import qualified Data.Vector.Unboxed as VU2VU.iterateN 0 undefined undefined :: VU.Vector Int[];VU.iterateN 3 (\(i, c) -> (pred i, succ c)) (0 :: Int, 'a')[(0,'a'),(-1,'b'),(-2,'c')] vectorO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1> vectorO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>  vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8> vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. vectorO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.  vectorO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed. vectorO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in vectorO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in vectorO(n): Yield a vector of the given length containing the values x, x+15 etc. This operation is usually more efficient than  . enumFromN 5 3 = <5,6,7> vectorO(n): Yield a vector of the given length containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than  . +enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4> vectorO(n) Enumerate values from x to y.WARNING: This operation can be very inefficient. If at all possible, use   instead. vectorO(n) Enumerate values from x to y with a specific step z.WARNING: This operation can be very inefficient. If at all possible, use   instead. vectorO(n) Prepend an element vectorO(n) Append an element vectorO(m+n) Concatenate two vectors vectorO(n)$ Concatenate all vectors in the list vectorO(n) Execute the monadic action the given number of times and store the results in a vector. vectorO(n) Construct a vector of the given length by applying the monadic action to each index  vectorO(n) Apply monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector.For non-monadic version see  vector;Execute the monadic action and freeze the resulting vector. create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b> vector)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected. vectorO(m+n) For each pair (i,a)8 from the list, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7> vectorO(m+n) For each pair (i,a) from the vector of index/value pairs, replace the vector element at position i by a. 0update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7> vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7> The function   provides the same functionality and is usually more convenient. update_ xs is ys =   xs (  is ys) vector Same as ( ) but without bounds checking. vectorSame as   but without bounds checking. vectorSame as   but without bounds checking. vectorO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples*import qualified Data.Vector.Unboxed as VUVU.accum (+) (VU.fromList [1000.0,2000.0,3000.0]) [(2,4),(1,6),(0,3),(1,10)][1003.0,2016.0,3004.0] vectorO(m+n) For each pair (i,b)7 from the vector of pairs, replace the vector element a at position i by f a b.Examples*import qualified Data.Vector.Unboxed as VUVU.accumulate (+) (VU.fromList [1000.0,2000.0,3000.0]) (VU.fromList [(2,4),(1,6),(0,3),(1,10)])[1003.0,2016.0,3004.0] vectorO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4> The function   provides the same functionality and is usually more convenient. accumulate_ f as is bs =   f as (  is bs) vectorSame as   but without bounds checking. vectorSame as   but without bounds checking. vectorSame as   but without bounds checking. vectorO(n) Reverse a vector vectorO(n)5 Yield the vector obtained by replacing each element i of the index vector by xs i. This is equivalent to   (xs ) is# but is often much more efficient. 3backpermute <0,3,2,3,1,0> = vectorSame as   but without bounds checking. vectorApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v -> write v 0 'x') (  3 'a') = <'x','a','a'> vectorO(n)- Pair each element in a vector with its index vectorO(n) Map a function over a vector vectorO(n)< Apply a function to every element of a vector and its index vector9Map a function over a vector and concatenate the results. vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results vectorO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of results vectorO(n) Apply the monadic action to all elements of a vector and ignore the results vectorO(n) Apply the monadic action to every element of a vector and its index, ignoring the results vectorO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip  . vectorO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip  .  vectorO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to    .  vectorO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to    . vector O(min(m,n))) Zip two vectors with the given function. vector*Zip three vectors with the given function. vector O(min(m,n)) Zip two vectors with a function that also takes the elements' indices. vector Monadic fold with strict accumulator that discards the result vectorO(n) Monadic fold with strict accumulator that discards the result (action applied to each element and its index) vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result vectorO(n) Prescan prescanl f z =   .   f z  Example: $prescanl (+) 0 <1,2,3,4> = <0,1,3,6> vectorO(n) Prescan with strict accumulator vectorO(n) Scan postscanl f z =   .   f z  Example: &postscanl (+) 0 <1,2,3,4> = <1,3,6,10> vectorO(n) Scan with strict accumulator vectorO(n) Haskell-style scan scanl f z = where y1 = z yi = f y(i-1) x(i-1) Example: $scanl (+) 0 <1,2,3,4> = <0,1,3,6,10> vectorO(n)+ Haskell-style scan with strict accumulator  vectorO(n)" Scan over a vector with its index  vectorO(n)- Scan over a vector (strictly) with its index vectorO(n) Scan over a non-empty vector scanl f = where y1 = x1 yi = f y(i-1) xi vectorO(n)7 Scan over a non-empty vector with a strict accumulator vectorO(n) Right-to-left prescan prescanr f z =   .   (flip f) z .   vectorO(n). Right-to-left prescan with strict accumulator vectorO(n) Right-to-left scan vectorO(n)+ Right-to-left scan with strict accumulator vectorO(n)! Right-to-left Haskell-style scan vectorO(n)9 Right-to-left Haskell-style scan with strict accumulator  vectorO(n)0 Right-to-left scan over a vector with its index vectorO(n); Right-to-left scan over a vector (strictly) with its index@sinqce 0.12.2.0 vectorO(n)+ Right-to-left scan over a non-empty vector vectorO(n) Right-to-left scan over a non-empty vector with a strict accumulator  vectorO(n) Check if two vectors are equal using supplied equality predicate.  vectorO(n) Compare two vectors using supplied comparison function for vector elements. Comparison works same as for lists. cmpBy compare == compare vectorO(n) Convert a vector to a list vectorO(n) Convert a list to a vector vectorO(n) Convert the first n elements of a list to a vector fromListN n xs =   (  n xs) Examples*import qualified Data.Vector.Unboxed as VUVU.fromListN 3 [1,2,3,4,5::Int][1,2,3]VU.fromListN 3 [1::Int][1] vectorO(1) Unsafe convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation. vectorO(1) Unsafely convert an immutable vector to a mutable one without copying. The immutable vector may not be used after this operation. vectorO(n). Yield a mutable copy of the immutable vector. vectorO(n)/ Yield an immutable copy of the mutable vector. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked. vectorO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. vectorO(1) Zip 2 vectors vectorO(1) Unzip 2 vectors vectorO(1) Zip 3 vectors vectorO(1) Unzip 3 vectors vectorO(1) Zip 4 vectors vectorO(1) Unzip 4 vectors vectorO(1) Zip 5 vectors vectorO(1) Unzip 5 vectors vectorO(1) Zip 6 vectors vectorO(1) Unzip 6 vectors vectori starting indexvectorn length vectori starting indexvectorn length vectorinitial vector (of length m)vector%list of index/value pairs (of length n) vectorinitial vector (of length m)vector'vector of index/value pairs (of length n) vectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2) vectoraccumulating function fvectorinitial vector (of length m)vector%list of index/value pairs (of length n) vectoraccumulating function fvectorinitial vector (of length m)vector'vector of index/value pairs (of length n) vectoraccumulating function fvectorinitial vector (of length m)vectorindex vector (of length n1)vectorvalue vector (of length n2)    5 4 4 (c) Roman Leshchinskiy 2009-2010 BSD-style'Roman Leshchinskiy  experimental non-portableNone*% vectorLength of the mutable vector. vector!Check whether the vector is empty vectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements. vectorYield a part of the mutable vector without copying it. No bounds checks are performed. vector"Check whether two vectors overlap. vector,Create a mutable vector of the given length. vectorCreate a mutable vector of the given length. The vector content is uninitialized, which means it is filled with whatever underlying memory buffer happens to contain. vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value. vectorCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action. vector"Create a copy of a mutable vector. vectorGrow an unboxed vector by the given number of elements. The number must be non-negative. Same semantics as in  for generic vector.Examples*import qualified Data.Vector.Unboxed as VU3import qualified Data.Vector.Unboxed.Mutable as MVUmv <- VU.thaw $ VU.fromList ([('a', 10), ('b', 20), ('c', 30)] :: [(Char, Int)])mv' <- MVU.grow mv 2Extra memory at the end of the newly allocated vector is initialized to 0 bytes, which for   instance will usually correspond to some default value for a particular type, eg. 0 for Int, False for Bool, etc. However, if   was used instead this would not have been guaranteed and some garbage would be there instead:VU.unsafeFreeze mv'2[('a',10),('b',20),('c',30),('\NUL',0),('\NUL',0)]8Having the extra space we can write new values in there:MVU.write mv' 3 ('d', 999)VU.unsafeFreeze mv'1[('a',10),('b',20),('c',30),('d',999),('\NUL',0)]It is important to note that the source mutable vector is not affected when the newly allocated one is mutated.MVU.write mv' 2 ('X', 888)VU.unsafeFreeze mv'2[('a',10),('b',20),('X',888),('d',999),('\NUL',0)]VU.unsafeFreeze mv[('a',10),('b',20),('c',30)] vectorGrow a vector by the given number of elements. The number must be non-negative but this is not checked. Same semantics as in  for generic vector. vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors. vector(Yield the element at the given position. vector*Replace the element at the given position. vector)Modify the element at the given position. vector)Swap the elements at the given positions. vectorYield the element at the given position. No bounds checks are performed. vectorReplace the element at the given position. No bounds checks are performed. vectorModify the element at the given position. No bounds checks are performed. vectorSwap the elements at the given positions. No bounds checks are performed. vector2Set all elements of the vector to the given value. vectorCopy a vector. The two vectors must have the same length and may not overlap. vectorCopy a vector. The two vectors must have the same length and may not overlap. This is not checked. vectorMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to  . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector. vectorMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to  . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector. vectorCompute the next (lexicographically) permutation of given vector in-place. Returns False when input is the last permutation vectorO(1) Zip 2 vectors vectorO(1) Unzip 2 vectors vectorO(1) Zip 3 vectors vectorO(1) Unzip 3 vectors vectorO(1) Zip 4 vectors vectorO(1) Unzip 4 vectors vectorO(1) Zip 5 vectors vectorO(1) Unzip 5 vectors vectorO(1) Zip 6 vectors vectorO(1) Unzip 6 vectors vectori starting indexvectorn length vectorstarting indexvectorlength of the slice vectortargetvectorsource vectortargetvectorsource vectortargetvectorsource vectortargetvectorsource  !" !# !"$%&'()**+,,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTEFUOVWXYZ[\]^_`abcddefghijklmnopqrstuvwxyz{|}~               i j k l m n o p q r s t u v w x y z { | } ~                                                                                                   i j k l m o q r s t u v w x y z { | }                                              ~                                     i j x { |  y z         m n                                            x y z { |   ijwtuxyz{|klmoqrsnp}~   D D i j x { |  y z         m n                     Rijwtuxyz{|klmoqrsnp}~DDijx{|yzmnRRijwtuxyz{|klmoqrsnp}~DDijx{|yzmnRijwtuxyz{|klmoqrsnp}~RDijwtuxyz{|klmoqrsnp}~ijx{|yzmn $i$m$$$$$$ !  $ !$&vector-0.12.2.0-JHTPqJflPVm5AbyFmGf02q!Data.Vector.Fusion.Stream.MonadicData.Vector.Storable.MutableData.Vector.Primitive.MutableData.Vector.Fusion.UtilData.Vector.Fusion.Bundle.Size Data.Vector.Generic.Mutable.BaseData.Vector.GenericData.Vector.Internal.Check!Data.Vector.Fusion.Bundle.MonadicData.Vector.Fusion.BundleData.Vector.Generic.MutableData.Vector.Generic.NewData.Vector.Mutable Data.VectorData.Vector.PrimitiveData.Vector.Storable.InternalData.Vector.StorableData.Vector.UnboxedData.Vector.Unboxed.MutableData.Vector.Generic.Base Foreign.PtrPtrPrelude showsPrec Text.ReadreadPrec Data.Datagfoldl Data.IORefIORefData.Vector.Unboxed.Baseghc-prim GHC.TypesSPECSPEC2baseForeign.StorableStorable'primitive-0.7.1.0-Jxsyd70oUttYiCXCa0HqVData.Primitive.TypesPrimBoxunBoxIdunId delay_inline delayed_min $fMonadId$fApplicativeId $fFunctorId $fMonadBox$fApplicativeBox $fFunctorBoxSizeExactMaxUnknownclampedSubtractsmaller smallerThanlargertoMax lowerBound upperBound $fNumSize$fEqSize $fShowSizeMVector basicLengthbasicUnsafeSlice basicOverlapsbasicUnsafeNewbasicInitializebasicUnsafeReplicatebasicUnsafeReadbasicUnsafeWrite basicClearbasicSetbasicUnsafeCopybasicUnsafeMovebasicUnsafeGrowVectorbasicUnsafeFreezebasicUnsafeThawbasicUnsafeIndexMelemseqMutableChecksBoundsUnsafeInternaldoCheckserror internalErrorcheck checkIndex checkLength checkSlice $fEqChecksStreamStepYieldSkipDonelengthnullempty singleton replicate replicateMgenerate generateMconssnoc++headlast!!!?sliceinittailtakedropmapmapMmapM_transunboxindexedindexedRzipWithM zipWithM_ zipWith3M zipWith4M zipWith5M zipWith6MzipWithzipWith3zipWith4zipWith5zipWith6zipzip3zip4zip5zip6eqBycmpByfiltermapMaybe catMaybesfilterM mapMaybeMuniq takeWhile takeWhileM dropWhile dropWhileMelemnotElemfindfindM findIndex findIndexMfoldlfoldlMfoldMfoldl1foldl1Mfold1Mfoldl'foldlM'foldM'foldl1'foldl1M'fold1M'foldrfoldrMfoldr1foldr1Mandor concatMap concatMapMflattenunfoldrunfoldrMunfoldrN unfoldrNM unfoldrExactNunfoldrExactNM iterateNMiterateNprescanl prescanlM prescanl' prescanlM' postscanl postscanlM postscanl' postscanlM'scanlscanlMscanl'scanlM'scanl1scanl1Mscanl1'scanl1M' enumFromStepN enumFromToenumFromThenTotoListfromList fromListN $fFunctorStep$fFunctorStreamBundlesElemssChunkssVectorsSizeChunklift fromStreamchunkselementssizesizedunsafeFromList fromVector fromVectors concatVectorsreVector$fFunctorBundleMBundleinplaceeqcmp $fOrd1Bundle $fEq1Bundle $fOrdBundle $fEqBundlemstreamfill transformmstreamRfillR transformRunstream munstream vunstream unstreamR munstreamRsplitAt unsafeSlice unsafeInit unsafeTail unsafeTake unsafeDropoverlapsnew unsafeNewclonegrow growFront unsafeGrowunsafeGrowFrontclearreadwritemodifyswapexchange unsafeRead unsafeWrite unsafeModify unsafeSwapunsafeExchangesetcopymove unsafeCopy unsafeMoveaccumupdate unsafeAccum unsafeUpdatereverseunstablePartitionunstablePartitionBundlepartitionBundlepartitionWithBundlenextPermutationNewcreaterunrunPrimapplymodifyWithBundle! unsafeIndex unsafeHead unsafeLastindexMheadMlastM unsafeIndexM unsafeHeadM unsafeLastMunconsunsnoc constructN constructrN enumFromNconcatconcatNEcreateTforce//update_ unsafeUpd unsafeUpdate_ accumulate accumulate_unsafeAccumulateunsafeAccumulate_ backpermuteunsafeBackpermuteimapimapMimapM_forMforM_iforMiforM_izipWith izipWith3 izipWith4 izipWith5 izipWith6 izipWithM izipWithM_unzipunzip3unzip4unzip5unzip6ifilter imapMaybe imapMaybeM partition partitionWithspanbreak findIndexR findIndices elemIndex elemIndicesfoldr'foldr1'ifoldlifoldl'ifoldrifoldr'foldMapfoldMap'allanysumproductmaximum maximumByminimum minimumBymaxIndex maxIndexByminIndex minIndexByifoldMifoldM'foldM_ifoldM_fold1M_foldM'_ifoldM'_fold1M'_sequence sequence_iscanliscanl'prescanr prescanr' postscanr postscanr'scanrscanr'iscanriscanr'scanr1scanr1'convert unsafeFreezefreeze unsafeThawthawstreamstreamR unstreamM liftShowsPrec liftReadsPrec mkVecConstr mkVecTypemkTypegunfolddataCastSTVectorIOVectorfromMutableArraytoMutableArray$fMVectorMVectora fromArraytoArray$fTraversableVector$fFoldableVector$fAlternativeVector$fApplicativeVector$fMonadFixVector$fMonadZipVector$fMonadPlusVector$fMonadFailVector $fMonadVector$fFunctorVector$fMonoidVector$fSemigroupVector $fOrd1Vector $fEq1Vector $fOrdVector $fEqVector$fVectorVectora $fDataVector$fIsListVector $fRead1Vector $fShow1Vector $fReadVector $fShowVector$fNFData1Vector$fNFDataVector$fNFData1MVector$fNFDataMVectorgetPtrsetPtrupdPtr unsafeCastunsafeFromForeignPtrunsafeFromForeignPtr0unsafeToForeignPtrunsafeToForeignPtr0 unsafeWith isSameVectorUnboxMV_6MV_5MV_4MV_3MV_2 MV_ComposeMV_AltMV_ConstMV_AllMV_AnyMV_ArgMV_WrappedMonoidMV_LastMV_FirstMV_MaxMV_Min MV_ProductMV_SumMV_DualMV_Down MV_Identity MV_ComplexMV_BoolMV_Char MV_DoubleMV_Float MV_Word64 MV_Word32 MV_Word16MV_Word8MV_WordMV_Int64MV_Int32MV_Int16MV_Int8MV_IntMV_Unit GHC.Classesmin Data.FoldableGHC.List&&|| GHC.MaybeNothingJustGHC.Baseflip Data.EitherLeftRightFoldableTrueEqOrdText.ParserCombinators.ReadPReadSIOGHC.ForeignPtr ForeignPtrV_UnitV_IntV_Int8V_Int16V_Int32V_Int64V_WordV_Word8V_Word16V_Word32V_Word64V_FloatV_DoubleV_CharV_Bool V_Complex V_IdentityV_DownV_DualV_Sum V_ProductV_MinV_MaxV_FirstV_LastV_WrappedMonoidV_ArgV_AnyV_AllV_ConstV_Alt V_ComposeV_2V_3V_4V_5V_6