h$w      !"#$%&'()*+,-./0123456789: ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone$. (c) Roman Leshchinskiy 2009 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimentalportableNone& vectorIdentity monadvectorDelay inlining a function until late in the game (simplifier phase 0).vector inlined in phase 0   (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimentalportableNone) 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 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portable Safe-Inferred4;#vectorClass of mutable vectors parameterised 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.0vectorGrow 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#$%&'()*+,-./0#$%&'()*+,-./0(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone ?@A 1vectorClass of immutable vectors. Every immutable vector is associated with its mutable version through the 9 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:234562vectorAssumed complexity: O(1)Unsafely convert a mutable vector to its immutable version without copying. The mutable vector may not be used after this operation.3vectorAssumed complexity: O(1)Unsafely convert an immutable vector to its mutable version without copying. The immutable vector may not be used after this operation.4vectorAssumed complexity: O(1)Yield the length of the vector.5vectorAssumed complexity: O(1)Yield a slice of the vector without copying it. No range checks are performed.6vectorAssumed 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 6 , 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.7vectorAssumed 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 1 should redefine this method if they wish to support an efficient block copy operation.%Default definition: copying based on 6 and basicUnsafeWrite.8vector 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. This method is only used for optimisation purposes. Thus, it is safe for instances of 1 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 all.9vector Mutable v s a5 is the mutable version of the immutable vector type v a with the state token s%. It is injective on GHC 8 and newer.5vectorstarting indexvectorlength 145723689(c) Roman Leshchinskiy 2009 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone?Aj 32 (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone'(>Yz:vectorMonadic streamsBvector)Convert a pure stream to a monadic streamFvector hint of a :Gvector Attach a  hint to a :Hvector Length of a :Ivector Check if a : is emptyJvectorEmpty :Kvector Singleton :Lvector#Replicate a value to a given lengthMvectorYield a : of values obtained by performing the monadic action the given number of timesOvector"Generate a stream from its indicesPvectorPrepend an elementQvectorAppend an elementRvectorConcatenate two :sSvectorFirst element of the : or error if emptyTvectorLast element of the : or error if emptyUvectorElement at the given positionVvector!Element at the given position or  if out of boundsWvectorExtract a substream of the given length starting at the given position.XvectorAll but the last elementYvectorAll but the first elementZvector The first n elements[vectorAll but the first n elements\vectorMap 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 monadavectorPair each element in a : with its indexbvectorPair each element in a :; with its index, starting from the right and counting downcvectorZip two :!s with the given monadic functionsvector Check if two : s are equaltvectorLexicographically compare two :suvector0Drop elements which do not satisfy the predicatevvector8Drop elements which do not satisfy the monadic predicatew vectorDrop the longest prefix of elements that satisfy the predicate{vectorDrop the longest prefix of elements that satisfy the monadic predicate|vectorCheck whether the : contains an element}vector 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 accumulator 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 operatorvectorInitial-value free scan over a :vectorInitial-value free scan over a : with a monadic operatorvectorInitial-value free scan over a : with a strict accumulatorvectorInitial-value free scan over a :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.Wvectorstarting indexvectorlength:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~:;<=>?@ABFGHIJKPQLMNORSTUVWXYZ[\]^_`abdcefghijklmnopqrstuvwxyz{|}~CDER5U9 V9 |4}4(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone>lgvector$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 accumulatorvectorInitial-value free scan over a vectorInitial-value free scan over a  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 indexvectorlength @AB @AB59 9 44(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone ?"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 empty.vectorYield a part of the mutable vector without copying it. The vector must contain at least i+n elements.vector Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged.vector Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned.vectorO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that  n v is equivalent to ( n v,  n v), but slightly more efficient.vectorDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vectorSame as , but doesn't do range checks.vectorSame as , but doesn't do range checks.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.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 assumed to be uninitialized. However, the exact semantics depend on the vector implementation. For example, unboxed and storable vectors will create a vector filled with whatever the 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. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0.vector"Create a copy of a mutable vector.vectorGrow a vector by the given number of elements. The number must not be negative, otherwise an exception is thrown. The semantics of this function are exactly the same as of , 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 bottoms. 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.vectorYield the element at the given position. Will throw an exception if the index is out of range.Examples*import qualified Data.Vector.Mutable as MVv <- MV.generate 10 (\x -> x*x) MV.read v 39 vector1Yield the element at the given position. Returns  if the index is out of range.Examples*import qualified Data.Vector.Mutable as MVv <- MV.generate 10 (\x -> x*x)MV.readMaybe v 3Just 9MV.readMaybe v 13Nothingvector*Replace the element at the given position.vector)Modify the element at the given position. vectorModify the element at the given position using a monadic function.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. vectorModify the element at the given position using a monadic function. 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. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_. vectorO(n) Pure left fold. vectorO(n)( Pure left fold with strict accumulator. vectorO(n) Pure left fold using a function applied to each element and its index. vectorO(n) Pure left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Pure right fold. vectorO(n)) Pure right fold with strict accumulator. vectorO(n) Pure right fold using a function applied to each element and its index. vectorO(n) Pure right fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic fold. vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic right fold. vectorO(n), Monadic right fold with strict accumulator. vectorO(n) Monadic right fold using a function applied to each element and its index. vectorO(n) Monadic right fold with strict accumulator using a function applied to each element and its index.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, but 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 (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation.vectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevectormutable vector to copy fromvectornumber of elements to grow the vector by (must be non-negative, but this is not checked)vectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource#$%&'()*+,-./0#$%&'()*+,-./0 (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone?(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone ?vectorO(1) Yield the length of the vector.vectorO(1) Test whether a vector is empty.vectorO(1) Indexing.vectorO(1) Safe indexing.vectorO(1) First element.vectorO(1) Last element.vectorO(1)) Unsafe indexing without bounds checking.vectorO(1)8 First element, without checking if the vector is empty.vectorO(1)7 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 element) 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)1 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 n2 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 n5 elements, in which case an empty vector is returned.vectorO(1) Yield the first n5 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 the vector is empty. vectorO(1) Yield the  and  of the vector, or  if the vector is 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) The empty vector.vectorO(1)# A vector with exactly one element.vectorO(n) A 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 the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is 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 2 5 = <1,3,5,7,9>vectorO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If 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)/ Concatenate all vectors in the non-empty 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 the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a 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) from the list of index/value pairs, 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 1& 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,2000,3000]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004]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,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])[1003,2016,3004]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 1& 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 vector.vectorO(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 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 isUpper a == isUpper b) (V.fromList "Mississippi River")["M","ississippi ","R","iver"] See also . vectorO(n)& Split a vector into a list of slices.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.)This is the equivalent of 'groupBy (==)'.!import qualified Data.Vector as V"V.group (V.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also .vectorO(n)) Check if the vector contains an element.vectorO(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 occurrence 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 occurrences of the given element in ascending order. This is a specialised version of .vectorO(n) Left fold.vectorO(n) Left fold on non-empty vectors.vectorO(n)# Left fold with strict accumulator.vectorO(n)8 Left fold on non-empty vectors with strict accumulator.vectorO(n) Right fold.vectorO(n)! Right fold on non-empty vectors.vectorO(n)& Right fold with a strict accumulator.vectorO(n)9 Right fold on non-empty vectors with strict accumulator.vectorO(n) Left fold using a function applied to each element and its index.vectorO(n) Left fold with strict accumulator using a function applied to each element and its index.vectorO(n) Right fold using a function applied to each element and its index.vectorO(n) Right fold with strict accumulator using a 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 the same implementation as the corresponding method of the 4 type cless. Note that it's implemented in terms of  and won't fuse with functions that traverse the vector from left to right (, , etc.). vectorO(n) Like , but strict in the accumulator. It uses the same implementation as the corresponding method of the 5 type class. Note that 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]True"V.all even $ V.fromList [2, 4, 13]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]False"V.any even $ V.fromList [3, 2, 13]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 elements.Examples!import qualified Data.Vector as VV.sum $ V.fromList [300,20,1]321V.sum (V.empty :: V.Vector Int)0vectorO(n)% Compute the product of the elements.Examples!import qualified Data.Vector as V V.product $ V.fromList [1,2,3,4]24#V.product (V.empty :: V.Vector Int)1vectorO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples!import qualified Data.Vector as VV.maximum $ V.fromList [2, 1]2import Data.Semigroup-V.maximum $ V.fromList [Arg 1 'a', Arg 2 'b'] Arg 2 'b'-V.maximum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a'vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from  which returns the last tie.Examplesimport Data.Ord!import qualified Data.Vector as V;V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](2,'a');V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a') vectorO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples!import qualified Data.Vector as V/V.maximumOn fst $ V.fromList [(2,'a'), (1,'b')](2,'a')/V.maximumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a')vectorO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples!import qualified Data.Vector as VV.minimum $ V.fromList [2, 1]1import Data.Semigroup-V.minimum $ V.fromList [Arg 2 'a', Arg 1 'b'] Arg 1 'b'-V.minimum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a'vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.Examplesimport Data.Ord!import qualified Data.Vector as V;V.minimumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](1,'b');V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a') vectorO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples!import qualified Data.Vector as V/V.minimumOn fst $ V.fromList [(2,'a'), (1,'b')](1,'b')/V.minimumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a')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. In case of a tie, the first occurrence wins.Examplesimport Data.Ord!import qualified Data.Vector as V Monadic fold over non-empty vectors that discards the result.vectorO(n)? Monadic fold with strict accumulator that discards the result.vectorO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index.vectorO(n) Monad fold over non-empty vectors with strict accumulator that discards the result.vector-Evaluate each action and collect the results.vector-Evaluate each action and discard the results.vectorO(n) Left-to-right prescan. prescanl f z =  .  f z Examples!import qualified Data.Vector as V'V.prescanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6]vectorO(n)/ Left-to-right prescan with strict accumulator.vectorO(n) Left-to-right postscan. postscanl f z =  .  f z Examples!import qualified Data.Vector as V(V.postscanl (+) 0 (V.fromList [1,2,3,4]) [1,3,6,10]vectorO(n)0 Left-to-right postscan with strict accumulator.vectorO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples!import qualified Data.Vector as V$V.scanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6,10]vectorO(n), Left-to-right scan with strict accumulator.vectorO(n)1 Left-to-right scan over a vector with its index.vectorO(n)< Left-to-right scan over a vector (strictly) with its index.vectorO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V(V.scanl1 min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1](V.scanl1 max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]&V.scanl1 min (V.empty :: V.Vector Int)[]vectorO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V)V.scanl1' min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1])V.scanl1' max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]'V.scanl1' min (V.empty :: V.Vector Int)[]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 postscan.vectorO(n)0 Right-to-left postscan with strict accumulator.vectorO(n) Right-to-left scan.vectorO(n), Right-to-left scan with strict accumulator.vectorO(n)1 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)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V(V.scanr1 min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4](V.scanr1 max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]&V.scanr1 min (V.empty :: V.Vector Int)[]vectorO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V)V.scanr1' min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4])V.scanr1' max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]'V.scanr1' min (V.empty :: V.Vector Int)[]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. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =  ( n xs) Examples!import qualified Data.Vector as VV.fromListN 3 [1,2,3,4,5][1,2,3]V.fromListN 3 [1][1]vectorO(n)( Convert between different vector types.vectorO(1) Unsafely 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. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't."vectorO(n)- Yield a mutable copy of an immutable 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) Convert a vector to a .vectorO(n) Construct a vector from a .vectorO(1) Convert a vector to a  , proceeding from right to left.vectorO(n) Construct a vector from a  , proceeding from right to left. vectorLoad a 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 1" 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 the supplied equality predicate.vectorO(n), Compare two vectors lexicographically. All 1" 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 the supplied comparison function for vector elements. Comparison works the same as for lists. cmpBy compare == cmpvectorGeneric definition of .vectorGeneric definition of .vectorNote: uses .vectorGeneric definion of  that views a 1 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)1457236891457236899 9 544 (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone 3>Fvector7Mutable boxed vectors keyed on the monad they live in ( or ST s).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.vector Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged.vector Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned.vectorO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that  n v is equivalent to ( n v,  n v), but slightly more efficient.vectorDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.vectorSame as , but doesn't do range checks.vectorSame as , but doesn't do range checks.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. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0.vector"Create a copy of a mutable vector.vectorGrow a boxed vector by the given number of elements. The number must be non-negative. This has the same semantics as ' for generic vectors. It differs from grow functions for unpacked vectors, however, in that only pointers to values are copied over, therefore the values themselves will be shared between the two vectors. This is an important distinction to know about during memory usage analysis and in case the values themselves are of a mutable type, e.g.  ! 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 777 V.freeze 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 888 V.freeze mv'[10,20,888,999,777] V.freeze mv [10,20,30]vectorGrow a vector by the given number of elements. The number must be non-negative, but this is not checked. This has the same semantics as  for generic vectors.vectorReset all elements of the vector to some undefined value, clearing all references to external objects.vectorYield the element at the given position. Will throw an exception if the index is out of range.Examples*import qualified Data.Vector.Mutable as MVv <- MV.generate 10 (\x -> x*x) MV.read v 39 vector1Yield the element at the given position. Returns  if the index is out of range.Examples*import qualified Data.Vector.Mutable as MVv <- MV.generate 10 (\x -> x*x)MV.readMaybe v 3Just 9MV.readMaybe v 13Nothingvector*Replace the element at the given position.vector)Modify the element at the given position. vectorModify the element at the given position using a monadic function.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. vectorModify the element at the given position using a monadic function. 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.vectorCopy a vector. The two vectors must have the same length and may not overlap, but 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 (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_. vectorO(n) Pure left fold. vectorO(n)( Pure left fold with strict accumulator. vectorO(n) Pure left fold using a function applied to each element and its index. vectorO(n) Pure left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Pure right fold. vectorO(n)) Pure right fold with strict accumulator. vectorO(n) Pure right fold using a function applied to each element and its index. vectorO(n) Pure right fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic fold. vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic right fold. vectorO(n), Monadic right fold with strict accumulator. vectorO(n) Monadic right fold using a function applied to each element and its index. vectorO(n) Monadic right fold with strict accumulator using a function applied to each element and its index. 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.vectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone 3>ǔvector,Boxed vectors, supporting efficient slicing.vectorO(1) Yield the length of the vector.vectorO(1) Test whether a vector is empty.vectorO(1) Indexing.vectorO(1) Safe indexing.vectorO(1) First element.vectorO(1) Last element.vectorO(1)) Unsafe indexing without bounds checking.vectorO(1)8 First element, without checking if the vector is empty.vectorO(1)7 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 element) 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)1 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 n2 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 n5 elements, in which case an empty vector is returned.vectorO(1) Yield the first n5 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 the vector is empty. vectorO(1) Yield the  and  of the vector, or  if the vector is 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) The empty vector.vectorO(1)# A vector with exactly one element.vectorO(n) A 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 the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is 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 2 5 = <1,3,5,7,9>vectorO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If 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 the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a 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) from the list of index/value pairs, 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,2000,3000]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004]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,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])[1003,2016,3004]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 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 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 isUpper a == isUpper b) (V.fromList "Mississippi River")["M","ississippi ","R","iver"] See also , . vectorO(n): Split a vector into a list of slices of the input vector.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.Does not fuse.)This is the equivalent of 'groupBy (==)'.!import qualified Data.Vector as V"V.group (V.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also .vectorO(n)) Check if the vector contains an element.vectorO(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 indices of elements satisfying the predicate in ascending order.vectorO(n) Yield < the index of the first occurrence 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 occurrences of the given element in ascending order. This is a specialised version of .vectorO(n) Left fold.vectorO(n) Left fold on non-empty vectors.vectorO(n)# Left fold with strict accumulator.vectorO(n)8 Left fold on non-empty vectors with strict accumulator.vectorO(n) Right fold.vectorO(n)! Right fold on non-empty vectors.vectorO(n)& Right fold with a strict accumulator.vectorO(n)9 Right fold on non-empty vectors with strict accumulator.vectorO(n) Left fold using a function applied to each element and its index.vectorO(n) Left fold with strict accumulator using a function applied to each element and its index.vectorO(n) Right fold using a function applied to each element and its index.vectorO(n) Right fold with strict accumulator using a 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 the same implementation as the corresponding method of the 4 type class. Note that it's implemented in terms of  and won't fuse with functions that traverse the vector from left to right (, , etc.). vectorO(n) Like , but strict in the accumulator. It uses the same implementation as the corresponding method of the 5 type class. Note that 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]True"V.all even $ V.fromList [2, 4, 13]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]False"V.any even $ V.fromList [3, 2, 13]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 elements.Examples!import qualified Data.Vector as VV.sum $ V.fromList [300,20,1]321V.sum (V.empty :: V.Vector Int)0vectorO(n)% Compute the product of the elements.Examples!import qualified Data.Vector as V V.product $ V.fromList [1,2,3,4]24#V.product (V.empty :: V.Vector Int)1vectorO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples!import qualified Data.Vector as VV.maximum $ V.fromList [2, 1]2import Data.Semigroup-V.maximum $ V.fromList [Arg 1 'a', Arg 2 'b'] Arg 2 'b'-V.maximum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a'vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from  which returns the last tie.Examplesimport Data.Ord!import qualified Data.Vector as V;V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](2,'a');V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a') vectorO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples!import qualified Data.Vector as V/V.maximumOn fst $ V.fromList [(2,'a'), (1,'b')](2,'a')/V.maximumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a')vectorO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples!import qualified Data.Vector as VV.minimum $ V.fromList [2, 1]1import Data.Semigroup-V.minimum $ V.fromList [Arg 2 'a', Arg 1 'b'] Arg 1 'b'-V.minimum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a'vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.Examplesimport Data.Ord!import qualified Data.Vector as V;V.minimumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](1,'b');V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a') vectorO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples!import qualified Data.Vector as V/V.minimumOn fst $ V.fromList [(2,'a'), (1,'b')](1,'b')/V.minimumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a')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. In case of a tie, the first occurrence wins.Examplesimport Data.Ord!import qualified Data.Vector as V Monadic fold over non-empty vectors that discards the result.vectorO(n)? Monadic fold with strict accumulator that discards the result.vectorO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index.vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result.vector-Evaluate each action and collect the results.vector-Evaluate each action and discard the results.vectorO(n) Left-to-right prescan. prescanl f z =  .  f z Examples!import qualified Data.Vector as V'V.prescanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6]vectorO(n)/ Left-to-right prescan with strict accumulator.vectorO(n) Left-to-right postscan. postscanl f z =  .  f z Examples!import qualified Data.Vector as V(V.postscanl (+) 0 (V.fromList [1,2,3,4]) [1,3,6,10]vectorO(n)0 Left-to-right postscan with strict accumulator.vectorO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples!import qualified Data.Vector as V$V.scanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6,10]vectorO(n), Left-to-right scan with strict accumulator. vectorO(n)1 Left-to-right scan over a vector with its index. vectorO(n)< Left-to-right scan over a vector (strictly) with its index.vectorO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V(V.scanl1 min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1](V.scanl1 max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]&V.scanl1 min (V.empty :: V.Vector Int)[]vectorO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V)V.scanl1' min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1])V.scanl1' max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]'V.scanl1' min (V.empty :: V.Vector Int)[]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 postscan.vectorO(n)0 Right-to-left postscan with strict accumulator.vectorO(n) Right-to-left scan.vectorO(n), Right-to-left scan with strict accumulator. vectorO(n)1 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)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V(V.scanr1 min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4](V.scanr1 max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]&V.scanr1 min (V.empty :: V.Vector Int)[]vectorO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples!import qualified Data.Vector as V)V.scanr1' min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4])V.scanr1' max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]'V.scanr1' min (V.empty :: V.Vector Int)[] vectorO(n) Check if two vectors are equal using the supplied equality predicate. vectorO(n) Compare two vectors using the supplied comparison function for vector elements. Comparison works the same as for lists. cmpBy compare == comparevectorO(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. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =  ( n xs)  vectorO(1) Convert an array to a vector. vectorO(n) Convert a vector to an array. vectorO(1) Extract the underlying , offset where vector starts and the total number of elements in the vector. Below property always holds: let (array, offset, len) = toArraySlice v v === unsafeFromArraySlice len offset array vectorO(1) Convert an array slice to a vector. This function is very unsafe, because constructing an invalid vector can yield almost all other safe functions in this module unsafe. These are equivalent: unsafeFromArraySlice len offset === unsafeTake len . unsafeDrop offset . fromArrayvectorO(1) Unsafely 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. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't."vectorO(n)- Yield a mutable copy of an immutable 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:This instance has the same semantics as the one for lists. vector vector 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)vectorImmutable boxed array.vectorOffsetvectorLength544(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone 3>vector#Mutable vectors of primitive types.vectorO(1) Unsafely coerce a mutable vector from one element type to another, representationally equal type. The operation just changes the type of the underlying pointer and does not modify the elements.'Note that this function is unsafe. The  Coercible constraint guarantees that the element types are representationally equal. It however cannot guarantee that their respective  instances are compatible.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.vector Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged.vector Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned.vectorO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that  n v is equivalent to ( n v,  n v), but slightly more efficient.vectorDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.vectorYield a part of the mutable vector without copying it. No bounds checks are performed.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.vectorUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.vectorSame as , but doesn't do range checks.vectorSame as , but doesn't do range checks.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 the 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. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0. vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0.vector"Create a copy of a mutable vector.vectorGrow a primitive vector by the given number of elements. The number must be non-negative. This has the same semantics as  for generic vectors.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  instances will usually correspond to some default value for a particular type, e.g. 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.freeze mv'[10,20,30,0,0]8Having the extra space we can write new values in there:MVP.write mv' 3 999 VP.freeze 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 888 VP.freeze mv'[10,20,888,999,0] VP.freeze mv [10,20,30]vectorGrow a vector by the given number of elements. The number must be non-negative, but this is not checked. This has the same semantics as  for generic vectors.vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is a noop.vectorYield the element at the given position. Will throw an exception if the index is out of range.Examples5import qualified Data.Vector.Primitive.Mutable as MVP v <- MVP.generate 10 (\x -> x*x) MVP.read v 39 vector1Yield the element at the given position. Returns  if the index is out of range.Examples5import qualified Data.Vector.Primitive.Mutable as MVP v <- MVP.generate 10 (\x -> x*x)MVP.readMaybe v 3Just 9MVP.readMaybe v 13Nothingvector*Replace the element at the given position.vector)Modify the element at the given position. vectorModify the element at the given position using a monadic function.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. vectorModify the element at the given position using a monadic function. 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.vectorCopy a vector. The two vectors must have the same length and may not overlap, but 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 (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. vectorO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_. vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_. vectorO(n) Pure left fold. vectorO(n)( Pure left fold with strict accumulator. vectorO(n) Pure left fold using a function applied to each element and its index. vectorO(n) Pure left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Pure right fold. vectorO(n)) Pure right fold with strict accumulator. vectorO(n) Pure right fold using a function applied to each element and its index. vectorO(n) Pure right fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic fold. vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic right fold. vectorO(n), Monadic right fold with strict accumulator. vectorO(n) Monadic right fold using a function applied to each element and its index. vectorO(n) Monadic right fold with strict accumulator using a function applied to each element and its index.vectorO(1) Unsafely cast a vector from one element type to another. This operation just changes the type of the vector and does not modify the elements.This function will throw an error if elements are of mismatching sizes.| @since 0.13.0.0vectoroffsetvectorlengthvectorunderlying mutable byte arrayvectori starting indexvectorn lengthvectorstarting indexvectorlength of the slicevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsourcevectortargetvectorsource (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone3>gvector#Unboxed vectors of primitive types.vectorO(1) Unsafely coerce an immutable vector from one element type to another, representationally equal type. The operation just changes the type of the underlying pointer and does not modify the elements.This is marginally safer than  (, since this function imposes an extra  constraint. The constraint guarantees that the element types are representationally equal. It however cannot guarantee that their respective  instances are compatible.vectorO(1) Yield the length of the vector.vectorO(1) Test whether a vector is empty.vectorO(1) Indexing.vectorO(1) Safe indexing.vectorO(1) First element.vectorO(1) Last element.vectorO(1)) Unsafe indexing without bounds checking.vectorO(1)8 First element, without checking if the vector is empty.vectorO(1)7 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 element) 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)1 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 n2 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 n5 elements, in which case an empty vector is returned.vectorO(1) Yield the first n5 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 the vector is empty. vectorO(1) Yield the  and  of the vector, or  if the vector is 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) The empty vector.vectorO(1)# A vector with exactly one element.vectorO(n) A 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 the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is 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 2 5 = <1,3,5,7,9>vectorO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use  instead.vectorO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If 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 the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a 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) from the list of index/value pairs, 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,2000,3000 :: Int]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004]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 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 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 isUpper a == isUpper b) (VP.fromList "Mississippi River")["M","ississippi ","R","iver"] See also , . vectorO(n): Split a vector into a list of slices of the input vector.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.Does not fuse.)This is the equivalent of 'groupBy (==)'.,import qualified Data.Vector.Primitive as VP$VP.group (VP.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also .vectorO(n)) Check if the vector contains an element.vectorO(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 indices of elements satisfying the predicate in ascending order.vectorO(n) Yield < the index of the first occurrence 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 occurrences of the given element in ascending order. This is a specialised version of .vectorO(n) Left fold.vectorO(n) Left fold on non-empty vectors.vectorO(n)# Left fold with strict accumulator.vectorO(n)8 Left fold on non-empty vectors with strict accumulator.vectorO(n) Right fold.vectorO(n)! Right fold on non-empty vectors.vectorO(n)& Right fold with a strict accumulator.vectorO(n)9 Right fold on non-empty vectors with strict accumulator.vectorO(n) Left fold using a function applied to each element and its index.vectorO(n) Left fold with strict accumulator using a function applied to each element and its index.vectorO(n) Right fold using a function applied to each element and its index.vectorO(n) Right fold with strict accumulator using a 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 the same implementation as the corresponding method of the 4 type cless. Note that it's implemented in terms of  and won't fuse with functions that traverse the vector from left to right (, , etc.). vectorO(n) Like , but strict in the accumulator. It uses the same implementation as the corresponding method of the 5 type class. Note that 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.Primitive as VP+VP.all even $ VP.fromList [2, 4, 12 :: Int]True+VP.all even $ VP.fromList [2, 4, 13 :: Int]False'VP.all even (VP.empty :: VP.Vector Int)TruevectorO(n). Check if any element satisfies the predicate.Examples,import qualified Data.Vector.Primitive as VP*VP.any even $ VP.fromList [1, 3, 7 :: Int]False+VP.any even $ VP.fromList [3, 2, 13 :: Int]True'VP.any even (VP.empty :: VP.Vector Int)FalsevectorO(n)! Compute the sum of the elements.Examples,import qualified Data.Vector.Primitive as VP&VP.sum $ VP.fromList [300,20,1 :: Int]321"VP.sum (VP.empty :: VP.Vector Int)0vectorO(n)% Compute the product of the elements.Examples,import qualified Data.Vector.Primitive as VP)VP.product $ VP.fromList [1,2,3,4 :: Int]24&VP.product (VP.empty :: VP.Vector Int)1vectorO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples,import qualified Data.Vector.Primitive as VP&VP.maximum $ VP.fromList [2, 1 :: Int]2vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from  which returns the last tie. vectorO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.vectorO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples,import qualified Data.Vector.Primitive as VP&VP.minimum $ VP.fromList [2, 1 :: Int]1vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. vectorO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. 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. In case of a tie, the first occurrence wins.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 fold. vectorO(n) Monadic fold using a function applied to each element and its index.vectorO(n)% Monadic fold over non-empty vectors.vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index.vectorO(n)= Monadic fold over non-empty vectors with strict accumulator.vectorO(n)' Monadic fold that discards the result. vectorO(n) Monadic fold that discards the result using a function applied to each element and its index.vectorO(n)> Monadic fold over non-empty vectors that discards the result.vectorO(n)? Monadic fold with strict accumulator that discards the result. vectorO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index. vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result. vectorO(n) Left-to-right prescan. prescanl f z =  .   f z Examples,import qualified Data.Vector.Primitive as VP0VP.prescanl (+) 0 (VP.fromList [1,2,3,4 :: Int]) [0,1,3,6] vectorO(n)/ Left-to-right prescan with strict accumulator. vectorO(n) Left-to-right postscan. postscanl f z =  .   f z Examples,import qualified Data.Vector.Primitive as VP1VP.postscanl (+) 0 (VP.fromList [1,2,3,4 :: Int]) [1,3,6,10] vectorO(n)0 Left-to-right postscan with strict accumulator. vectorO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples,import qualified Data.Vector.Primitive as VP-VP.scanl (+) 0 (VP.fromList [1,2,3,4 :: Int]) [0,1,3,6,10] vectorO(n), Left-to-right scan with strict accumulator.  vectorO(n)1 Left-to-right scan over a vector with its index.  vectorO(n)< Left-to-right scan over a vector (strictly) with its index. vectorO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples,import qualified Data.Vector.Primitive as VP1VP.scanl1 min $ VP.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]1VP.scanl1 max $ VP.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5])VP.scanl1 min (VP.empty :: VP.Vector Int)[] vectorO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples,import qualified Data.Vector.Primitive as VP2VP.scanl1' min $ VP.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]2VP.scanl1' max $ VP.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5]*VP.scanl1' min (VP.empty :: VP.Vector Int)[] 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 postscan. vectorO(n)0 Right-to-left postscan with strict accumulator. vectorO(n) Right-to-left scan. vectorO(n), Right-to-left scan with strict accumulator.  vectorO(n)1 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)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples,import qualified Data.Vector.Primitive as VP1VP.scanr1 min $ VP.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]1VP.scanr1 max $ VP.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1])VP.scanr1 min (VP.empty :: VP.Vector Int)[] vectorO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples,import qualified Data.Vector.Primitive as VP2VP.scanr1' min $ VP.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]2VP.scanr1' max $ VP.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1]*VP.scanr1' min (VP.empty :: VP.Vector Int)[]  vectorO(n) Check if two vectors are equal using the supplied equality predicate.  vectorO(n) Compare two vectors using the supplied comparison function for vector elements. Comparison works the 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. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =   ( n xs) Examples,import qualified Data.Vector.Primitive as VP!VP.fromListN 3 [1,2,3,4,5 :: Int][1,2,3]VP.fromListN 3 [1 :: Int][1] vectorO(1) Unsafely cast a vector from one element type to another. This operation just changes the type of the vector and does not modify the elements.This function will throw an error if elements are of mismatching sizes.| @since 0.13.0.0 vectorO(1) Unsafely 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. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't." vectorO(n)- Yield a mutable copy of an immutable 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.  vectorvectoroffsetvectorlengthvectorunderlying byte arrayvectori 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 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNonelvectorA compatibility wrapper for #$" provided by GHC 9.0.1 and later.Only to be used when the continuation is known not to unconditionally diverge lest unsoundness can result.(c) Roman Leshchinskiy 2009-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone 3> vectorMutable -based vectors. vectorO(1) Unsafely coerce a mutable vector from one element type to another, representationally equal type. The operation just changes the type of the underlying pointer and does not modify the elements.This is marginally safer than  (, since this function imposes an extra  constraint. This function is still not safe, however, since it cannot guarantee that the two types have memory-compatible  instances. 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. vector Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged. vector Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned. vectorO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that   n v is equivalent to (  n v,   n v), but slightly more efficient. vectorDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown. vectorDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown. vectorYield a part of the mutable vector without copying it. No bounds checks are performed. vectorUnsafe variant of  . If n is out of range, it will simply create an invalid slice that likely violate memory safety. vectorUnsafe variant of  . If n is out of range, it will simply create an invalid slice that likely violate memory safety. vectorSame as  , but doesn't do range checks. vectorSame as  , but doesn't do range checks. 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 the 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.  vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0.  vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0. vector"Create a copy of a mutable vector. vectorGrow a storable vector by the given number of elements. The number must be non-negative. This has the same semantics as  for generic vectors.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  instances will usually correspond to some default value for a particular type, e.g. 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.freeze mv'[10,20,30,0,0]8Having the extra space we can write new values in there:MVS.write mv' 3 999 VS.freeze 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 888 VS.freeze mv'[10,20,888,999,0] VS.freeze mv [10,20,30] vectorGrow a vector by the given number of elements. The number must be non-negative, but this is not checked. This has the same semantics as  for generic vectors. vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is a noop. vectorYield the element at the given position. Will throw an exception if the index is out of range.Examples4import qualified Data.Vector.Storable.Mutable as MVS v <- MVS.generate 10 (\x -> x*x) MVS.read v 39  vector1Yield the element at the given position. Returns  if the index is out of range.Examples4import qualified Data.Vector.Storable.Mutable as MVS v <- MVS.generate 10 (\x -> x*x)MVS.readMaybe v 3Just 9MVS.readMaybe v 13Nothing vector*Replace the element at the given position. vector)Modify the element at the given position.  vectorModify the element at the given position using a monadic function. 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.  vectorModify the element at the given position using a monadic function. 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. vectorCopy a vector. The two vectors must have the same length and may not overlap, but 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 (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation.  vectorO(n) Apply the monadic action to every element of the vector, discarding the results.  vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results.  vectorO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_.  vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_.  vectorO(n) Pure left fold.  vectorO(n)( Pure left fold with strict accumulator.  vectorO(n) Pure left fold using a function applied to each element and its index.  vectorO(n) Pure left fold with strict accumulator using a function applied to each element and its index.  vectorO(n) Pure right fold.  vectorO(n)) Pure right fold with strict accumulator.  vectorO(n) Pure right fold using a function applied to each element and its index.  vectorO(n) Pure right fold with strict accumulator using a function applied to each element and its index.  vectorO(n) Monadic fold.  vectorO(n)& Monadic fold with strict accumulator.  vectorO(n) Monadic fold using a function applied to each element and its index.  vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index.  vectorO(n) Monadic right fold.  vectorO(n), Monadic right fold with strict accumulator.  vectorO(n) Monadic right fold using a function applied to each element and its index.  vectorO(n) Monadic right fold with strict accumulator using a function applied to each element and its index. 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. vectorO(1) Create 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.1If your offset is 0, it is more efficient to use  . vectorO(1) Create a mutable vector from a  and a length.It is assumed that 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. vectorO(1) Yield the underlying  together with the offset to the data and its length. Modifying the data through the  is unsafe if the vector could have been frozen before the modification. vectorO(1) Yield the underlying  together with its length.You can assume that the pointer points directly to the data (no offset).Modifying the data through the  is unsafe if the vector could have been 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 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone3> vector-based vectors. vectorO(1) Unsafely coerce a mutable vector from one element type to another, representationally equal type. The operation just changes the type of the underlying pointer and does not modify the elements.This is marginally safer than  (, since this function imposes an extra  constraint. This function is still not safe, however, since it cannot guarantee that the two types have memory-compatible  instances. vectorO(1) Yield the length of the vector. vectorO(1) Test whether a vector is empty. vectorO(1) Indexing. vectorO(1) Safe indexing. vectorO(1) First element. vectorO(1) Last element. vectorO(1)) Unsafe indexing without bounds checking. vectorO(1)8 First element, without checking if the vector is empty. vectorO(1)7 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 element) 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)1 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 n2 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 n5 elements, in which case an empty vector is returned. vectorO(1) Yield the first n5 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 the vector is empty.  vectorO(1) Yield the   and   of the vector, or  if the vector is 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) The empty vector. vectorO(1)# A vector with exactly one element. vectorO(n) A 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 the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is 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 2 5 = <1,3,5,7,9> vectorO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use   instead. vectorO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If 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 the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a 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) from the list of index/value pairs, 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,2000,3000 :: Int]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004] 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 isUpper a == isUpper b) (VS.fromList "Mississippi River")["M","ississippi ","R","iver"] See also ,  .  vectorO(n): Split a vector into a list of slices of the input vector.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.Does not fuse.)This is the equivalent of 'groupBy (==)'.+import qualified Data.Vector.Storable as VS$VS.group (VS.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also . vectorO(n)) Check if the vector contains an element. vectorO(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 indices of elements satisfying the predicate in ascending order. vectorO(n) Yield < the index of the first occurrence 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 occurrences of the given element in ascending order. This is a specialised version of  . vectorO(n) Left fold. vectorO(n) Left fold on non-empty vectors. vectorO(n)# Left fold with strict accumulator. vectorO(n)8 Left fold on non-empty vectors with strict accumulator. vectorO(n) Right fold. vectorO(n)! Right fold on non-empty vectors. vectorO(n)& Right fold with a strict accumulator. vectorO(n)9 Right fold on non-empty vectors with strict accumulator. vectorO(n) Left fold using a function applied to each element and its index. vectorO(n) Left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Right fold using a function applied to each element and its index. vectorO(n) Right fold with strict accumulator using a 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 the same implementation as the corresponding method of the 4 type class. Note that it's implemented in terms of   and won't fuse with functions that traverse the vector from left to right ( ,  , etc.).  vectorO(n) Like  , but strict in the accumulator. It uses the same implementation as the corresponding method of the 5 type class. Note that 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.Storable as VS+VS.all even $ VS.fromList [2, 4, 12 :: Int]True+VS.all even $ VS.fromList [2, 4, 13 :: Int]False'VS.all even (VS.empty :: VS.Vector Int)True vectorO(n). Check if any element satisfies the predicate.Examples+import qualified Data.Vector.Storable as VS*VS.any even $ VS.fromList [1, 3, 7 :: Int]False+VS.any even $ VS.fromList [3, 2, 13 :: Int]True'VS.any even (VS.empty :: VS.Vector Int)False vectorO(n) Check if all elements are .Examples+import qualified Data.Vector.Storable as VS"VS.and $ VS.fromList [True, False]FalseVS.and VS.emptyTrue vectorO(n) Check if any element is .Examples+import qualified Data.Vector.Storable as VS!VS.or $ VS.fromList [True, False]TrueVS.or VS.emptyFalse vectorO(n)! Compute the sum of the elements.Examples+import qualified Data.Vector.Storable as VS&VS.sum $ VS.fromList [300,20,1 :: Int]321"VS.sum (VS.empty :: VS.Vector Int)0 vectorO(n)% Compute the product of the elements.Examples+import qualified Data.Vector.Storable as VS)VS.product $ VS.fromList [1,2,3,4 :: Int]24&VS.product (VS.empty :: VS.Vector Int)1 vectorO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples+import qualified Data.Vector.Storable as VS&VS.maximum $ VS.fromList [2, 1 :: Int]2 vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from  which returns the last tie.  vectorO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty. vectorO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples+import qualified Data.Vector.Storable as VS&VS.minimum $ VS.fromList [2, 1 :: Int]1 vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.  vectorO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. 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. In case of a tie, the first occurrence wins. 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 fold.  vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n)% Monadic fold over non-empty vectors. vectorO(n)& Monadic fold with strict accumulator.  vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n)= Monadic fold over non-empty vectors with strict accumulator. vectorO(n)' Monadic fold that discards the result.  vectorO(n) Monadic fold that discards the result using a function applied to each element and its index. vectorO(n)> Monadic fold over non-empty vectors that discards the result. vectorO(n)? Monadic fold with strict accumulator that discards the result.  vectorO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index. vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result. vectorO(n) Left-to-right prescan. prescanl f z =   .   f z Examples+import qualified Data.Vector.Storable as VS0VS.prescanl (+) 0 (VS.fromList [1,2,3,4 :: Int]) [0,1,3,6] vectorO(n)/ Left-to-right prescan with strict accumulator. vectorO(n) Left-to-right postscan. postscanl f z =   .   f z Examples+import qualified Data.Vector.Storable as VS1VS.postscanl (+) 0 (VS.fromList [1,2,3,4 :: Int]) [1,3,6,10] vectorO(n)0 Left-to-right postscan with strict accumulator. vectorO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples+import qualified Data.Vector.Storable as VS-VS.scanl (+) 0 (VS.fromList [1,2,3,4 :: Int]) [0,1,3,6,10] vectorO(n), Left-to-right scan with strict accumulator.  vectorO(n)1 Left-to-right scan over a vector with its index.  vectorO(n)< Left-to-right scan over a vector (strictly) with its index. vectorO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples+import qualified Data.Vector.Storable as VS1VS.scanl1 min $ VS.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]1VS.scanl1 max $ VS.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5])VS.scanl1 min (VS.empty :: VS.Vector Int)[] vectorO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples+import qualified Data.Vector.Storable as VS2VS.scanl1' min $ VS.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]2VS.scanl1' max $ VS.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5]*VS.scanl1' min (VS.empty :: VS.Vector Int)[] 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 postscan. vectorO(n)0 Right-to-left postscan with strict accumulator. vectorO(n) Right-to-left scan. vectorO(n), Right-to-left scan with strict accumulator.  vectorO(n)1 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)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples+import qualified Data.Vector.Storable as VS1VS.scanr1 min $ VS.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]1VS.scanr1 max $ VS.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1])VS.scanr1 min (VS.empty :: VS.Vector Int)[] vectorO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples+import qualified Data.Vector.Storable as VS2VS.scanr1' min $ VS.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]2VS.scanr1' max $ VS.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1]*VS.scanr1' min (VS.empty :: VS.Vector Int)[]  vectorO(n) Check if two vectors are equal using the supplied equality predicate.  vectorO(n) Compare two vectors using supplied the comparison function for vector elements. Comparison works the 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. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =   (  n xs) Examples+import qualified Data.Vector.Storable as VS!VS.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. This 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) Unsafely 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. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't." vectorO(n)- Yield a mutable copy of an immutable 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. experimental non-portableNone.239>?+  vector8Newtype which allows to derive unbox instances for type a which uses b4 as underlying representation (usually tuple). Type a and its representation b are connected by type class  %. Here's example which uses explicit   instance:6:set -XTypeFamilies -XStandaloneDeriving -XDerivingVia:set -XMultiParamTypeClasses -XTypeOperators -XFlexibleInstances2import qualified Data.Vector.Unboxed as VU2import qualified Data.Vector.Generic as VG3import qualified Data.Vector.Generic.Mutable as VGM:{ data Foo a = Foo Int a deriving Show*instance VU.IsoUnbox (Foo a) (Int,a) where toURepr (Foo i a) = (i,a) fromURepr (i,a) = Foo i a {-# INLINE toURepr #-} {-# INLINE fromURepr #-}newtype instance VU.MVector s (Foo a) = MV_Foo (VU.MVector s (Int, a))newtype instance VU.Vector (Foo a) = V_Foo (VU.Vector (Int, a))deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VGM.MVector MVector (Foo a)deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VG.Vector Vector (Foo a)'instance VU.Unbox a => VU.Unbox (Foo a):}5It's also possible to use generic-based instance for  * which should work for all product types.:set -XTypeFamilies -XStandaloneDeriving -XDerivingVia -XDeriveGeneric:set -XMultiParamTypeClasses -XTypeOperators -XFlexibleInstances2import qualified Data.Vector.Unboxed as VU2import qualified Data.Vector.Generic as VG3import qualified Data.Vector.Generic.Mutable as VGM:{ data Bar a = Bar Int a deriving (Show,Generic)*instance VU.IsoUnbox (Bar a) (Int,a) wherenewtype instance VU.MVector s (Bar a) = MV_Bar (VU.MVector s (Int, a))newtype instance VU.Vector (Bar a) = V_Bar (VU.Vector (Int, a))deriving via (Bar a `VU.As` (Int, a)) instance VU.Unbox a => VGM.MVector VU.MVector (Bar a)deriving via (Bar a `VU.As` (Int, a)) instance VU.Unbox a => VG.Vector VU.Vector (Bar a)'instance VU.Unbox a => VU.Unbox (Bar a):}  vectorIsomorphism between type a+ and its representation in unboxed vector b?. Default instance coerces between generic representations of a and b which means they have same shape and corresponding fields could be coerced to each other. Note that this means it's possible to have fields that have different types::set -XMultiParamTypeClasses -XDeriveGeneric -XFlexibleInstancesimport GHC.Generics (Generic)import Data.Monoid*import qualified Data.Vector.Unboxed as VU:{data Foo a = Foo Int a deriving (Show,Generic)%instance VU.IsoUnbox (Foo a) (Int, a)1instance VU.IsoUnbox (Foo a) (Sum Int, Product a):} vector7Convert value into it representation in unboxed vector. vector=Convert value representation in unboxed vector back to value.  vectorNewtype wrapper which allows to derive unboxed vector in term of primitive vectors using  DerivingVia; mechanism. This is mostly used as illustration of use of  DerivingVia for vector, see examples below.First is rather straightforward: we define newtype and use GND to derive  instance. Newtype instances should be defined manually. Then we use deriving via to define necessary instances.:set -XTypeFamilies -XStandaloneDeriving -XDerivingVia -XMultiParamTypeClasses-- Needed to derive Prim:set -XGeneralizedNewtypeDeriving -XDataKinds -XUnboxedTuples -XPolyKinds1import qualified Data.Vector.Unboxed as U1import qualified Data.Vector.Primitive as P1import qualified Data.Vector.Generic as G1import qualified Data.Vector.Generic.Mutable as M%newtype Foo = Foo Int deriving P.Prim;newtype instance U.MVector s Foo = MV_Int (P.MVector s Foo);newtype instance U.Vector Foo = V_Int (P.Vector Foo)deriving via (U.UnboxViaPrim Foo) instance M.MVector MVector Fooderiving via (U.UnboxViaPrim Foo) instance G.Vector Vector Fooinstance Unbox FooSecond example is essentially same but with a twist. Instead of using Prim6 instance of data type, we use underlying instance of Int::set -XTypeFamilies -XStandaloneDeriving -XDerivingVia -XMultiParamTypeClasses1import qualified Data.Vector.Unboxed as U1import qualified Data.Vector.Primitive as P1import qualified Data.Vector.Generic as G1import qualified Data.Vector.Generic.Mutable as Mnewtype Foo = Foo Int;newtype instance U.MVector s Foo = MV_Int (P.MVector s Int);newtype instance U.Vector Foo = V_Int (P.Vector Int)deriving via (U.UnboxViaPrim Int) instance M.MVector MVector Fooderiving via (U.UnboxViaPrim Int) instance G.Vector Vector Fooinstance Unbox Foo vector vector  (c) Roman Leshchinskiy 2009-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portableNone vectorO(1) Yield the length of the vector. vectorO(1) Test whether a vector is empty. vectorO(1) Indexing. vectorO(1) Safe indexing. vectorO(1) First element. vectorO(1) Last element. vectorO(1)) Unsafe indexing without bounds checking. vectorO(1)8 First element, without checking if the vector is empty. vectorO(1)7 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 element) 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)1 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 n2 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 n5 elements, in which case an empty vector is returned. vectorO(1) Yield the first n5 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 the vector is empty.  vectorO(1) Yield the   and   of the vector, or  if the vector is 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) The empty vector. vectorO(1)# A vector with exactly one element. vectorO(n) A 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 the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is 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 2 5 = <1,3,5,7,9> vectorO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use   instead. vectorO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If 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 the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a 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) from the list of idnex/value pairs, 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,2000,3000 :: Int]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004] 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,2000,3000 :: Int]) (VU.fromList [(2,4),(1,6),(0,3),(1,10)])[1003,2016,3004] 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 isUpper a == isUpper b) (VU.fromList "Mississippi River")["M","ississippi ","R","iver"] See also ,  .  vectorO(n): Split a vector into a list of slices of the input vector.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.Does not fuse.)This is the equivalent of 'groupBy (==)'.*import qualified Data.Vector.Unboxed as VU$VU.group (VU.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also . vectorO(n)) Check if the vector contains an element. vectorO(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 indices of elements satisfying the predicate in ascending order. vectorO(n) Yield < the index of the first occurrence 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 occurrences of the given element in ascending order. This is a specialised version of  . vectorO(n) Left fold. vectorO(n) Left fold on non-empty vectors. vectorO(n)# Left fold with strict accumulator. vectorO(n)8 Left fold on non-empty vectors with strict accumulator. vectorO(n) Right fold. vectorO(n)! Right fold on non-empty vectors. vectorO(n)& Right fold with a strict accumulator. vectorO(n)9 Right fold on non-empty vectors with strict accumulator. vectorO(n) Left fold using a function applied to each element and its index. vectorO(n) Left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Right fold using a function applied to each element and its index. vectorO(n) Right fold with strict accumulator using a 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 the same implementation as the corresponding method of the 4 type cless. Note that it's implemented in terms of   and won't fuse with functions that traverse the vector from left to right ( ,  , etc.).  vectorO(n) Like  , but strict in the accumulator. It uses the same implementation as the corresponding method of the 5 type class. Note that 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.Unboxed as VU+VU.all even $ VU.fromList [2, 4, 12 :: Int]True+VU.all even $ VU.fromList [2, 4, 13 :: Int]False'VU.all even (VU.empty :: VU.Vector Int)True vectorO(n). Check if any element satisfies the predicate.Examples*import qualified Data.Vector.Unboxed as VU*VU.any even $ VU.fromList [1, 3, 7 :: Int]False+VU.any even $ VU.fromList [3, 2, 13 :: Int]True'VU.any even (VU.empty :: VU.Vector Int)False vectorO(n) Check if all elements are .Examples*import qualified Data.Vector.Unboxed as VU"VU.and $ VU.fromList [True, False]FalseVU.and VU.emptyTrue vectorO(n) Check if any element is .Examples*import qualified Data.Vector.Unboxed as VU!VU.or $ VU.fromList [True, False]TrueVU.or VU.emptyFalse vectorO(n)! Compute the sum of the elements.Examples*import qualified Data.Vector.Unboxed as VU&VU.sum $ VU.fromList [300,20,1 :: Int]321"VU.sum (VU.empty :: VU.Vector Int)0 vectorO(n)% Compute the product of the elements.Examples*import qualified Data.Vector.Unboxed as VU)VU.product $ VU.fromList [1,2,3,4 :: Int]24&VU.product (VU.empty :: VU.Vector Int)1 vectorO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples*import qualified Data.Vector.Unboxed as VU&VU.maximum $ VU.fromList [2, 1 :: Int]2import Data.Semigroup8VU.maximum $ VU.fromList [Arg 1 'a', Arg (2 :: Int) 'b'] Arg 2 'b'8VU.maximum $ VU.fromList [Arg 1 'a', Arg (1 :: Int) 'b'] Arg 1 'a' vectorO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from  which returns the last tie.Examplesimport Data.Ord*import qualified Data.Vector.Unboxed as VUVU.maximumBy (comparing fst) $ VU.fromList [(2,'a'), (1 :: Int,'b')](2,'a')VU.maximumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')](1,'a')  vectorO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples*import qualified Data.Vector.Unboxed as VU8VU.maximumOn fst $ VU.fromList [(2,'a'), (1 :: Int,'b')](2,'a')8VU.maximumOn fst $ VU.fromList [(1,'a'), (1 :: Int,'b')](1,'a') vectorO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples*import qualified Data.Vector.Unboxed as VU&VU.minimum $ VU.fromList [2, 1 :: Int]1import Data.Semigroup8VU.minimum $ VU.fromList [Arg 2 'a', Arg (1 :: Int) 'b'] Arg 1 'b'8VU.minimum $ VU.fromList [Arg 1 'a', Arg (1 :: Int) 'b'] Arg 1 'a' vectorO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty.O(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.Examplesimport Data.Ord*import qualified Data.Vector.Unboxed as VUVU.minimumBy (comparing fst) $ VU.fromList [(2,'a'), (1 :: Int,'b')](1,'b')VU.minimumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')](1,'a')  vectorO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples*import qualified Data.Vector.Unboxed as VU8VU.minimumOn fst $ VU.fromList [(2,'a'), (1 :: Int,'b')](1,'b')8VU.minimumOn fst $ VU.fromList [(1,'a'), (1 :: Int,'b')](1,'a') 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. In case of a tie, the first occurrence wins.Examplesimport Data.Ord*import qualified Data.Vector.Unboxed as VU>VU.maxIndexBy (comparing fst) $ VU.fromList [(2,'a'), (1,'b')]0>VU.maxIndexBy (comparing fst) $ VU.fromList [(1,'a'), (1,'b')]0 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.Examplesimport Data.Ord*import qualified Data.Vector.Unboxed as VU>VU.minIndexBy (comparing fst) $ VU.fromList [(2,'a'), (1,'b')]1>VU.minIndexBy (comparing fst) $ VU.fromList [(1,'a'), (1,'b')]0 vectorO(n) Monadic fold. vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n)% Monadic fold over non-empty vectors. vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n)= Monadic fold over non-empty vectors with strict accumulator. vectorO(n)' Monadic fold that discards the result. vectorO(n) Monadic fold that discards the result using a function applied to each element and its index. vectorO(n)> Monadic fold over non-empty vectors that discards the result. vectorO(n)? Monadic fold with strict accumulator that discards the result. vectorO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index. vectorO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result. vectorO(n) Left-to-right prescan. prescanl f z =   .   f z Examples"import qualified Data.Vector as VU0VU.prescanl (+) 0 (VU.fromList [1,2,3,4 :: Int]) [0,1,3,6] vectorO(n)/ Left-to-right prescan with strict accumulator. vectorO(n) Left-to-right postscan. postscanl f z =   .   f z Examples*import qualified Data.Vector.Unboxed as VU1VU.postscanl (+) 0 (VU.fromList [1,2,3,4 :: Int]) [1,3,6,10] vectorO(n)0 Left-to-right postscan with strict accumulator. vectorO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples*import qualified Data.Vector.Unboxed as VU-VU.scanl (+) 0 (VU.fromList [1,2,3,4 :: Int]) [0,1,3,6,10] vectorO(n), Left-to-right scan with strict accumulator.  vectorO(n)1 Left-to-right scan over a vector with its index.  vectorO(n)< Left-to-right scan over a vector (strictly) with its index. vectorO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples*import qualified Data.Vector.Unboxed as VU1VU.scanl1 min $ VU.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]1VU.scanl1 max $ VU.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5])VU.scanl1 min (VU.empty :: VU.Vector Int)[] vectorO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples*import qualified Data.Vector.Unboxed as VU2VU.scanl1' min $ VU.fromListN 5 [4,2,4,1,3 :: Int] [4,2,2,1,1]2VU.scanl1' max $ VU.fromListN 5 [1,3,2,5,4 :: Int] [1,3,3,5,5]*VU.scanl1' min (VU.empty :: VU.Vector Int)[] 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 postscan. vectorO(n)0 Right-to-left postscan with strict accumulator. vectorO(n) Right-to-left scan. vectorO(n), Right-to-left scan with strict accumulator.  vectorO(n)1 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)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples*import qualified Data.Vector.Unboxed as VU1VU.scanr1 min $ VU.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]1VU.scanr1 max $ VU.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1])VU.scanr1 min (VU.empty :: VU.Vector Int)[] vectorO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples*import qualified Data.Vector.Unboxed as VU2VU.scanr1' min $ VU.fromListN 5 [3,1,4,2,4 :: Int] [1,1,2,2,4]2VU.scanr1' max $ VU.fromListN 5 [4,5,2,3,1 :: Int] [5,5,3,3,1]*VU.scanr1' min (VU.empty :: VU.Vector Int)[]  vectorO(n) Check if two vectors are equal using the supplied equality predicate.  vectorO(n) Compare two vectors using the supplied comparison function for vector elements. Comparison works the 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. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =   (  n xs) Examples*import qualified Data.Vector.Unboxed as VU!VU.fromListN 3 [1,2,3,4,5 :: Int][1,2,3]VU.fromListN 3 [1 :: Int][1] vectorO(1) Unsafely 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. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't." vectorO(n)- Yield a mutable copy of an immutable 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 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  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. vector Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged. vector Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned. vectorO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that   n v is equivalent to (  n v,   n v), but slightly more efficient. vectorDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown. vectorDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown. vectorYield a part of the mutable vector without copying it. No bounds checks are performed. vectorUnsafe variant of  . If n is out of range, it will simply create an invalid slice that likely violate memory safety. vectorUnsafe variant of  . If n is out of range, it will simply create an invalid slice that likely violate memory safety. vectorSame as  , but doesn't do range checks. vectorSame as  , but doesn't do range checks. 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 the 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.  vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0.  vectorO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0. vector"Create a copy of a mutable vector. vectorGrow an unboxed vector by the given number of elements. The number must be non-negative. It has the same semantics as  for generic vectors.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, e.g. 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.freeze 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.freeze 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.freeze mv'2[('a',10),('b',20),('X',888),('d',999),('\NUL',0)] VU.freeze 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. This has the same semantics as  for generic vectors. vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors. vectorYield the element at the given position. Will throw an exception if the index is out of range.Examples3import qualified Data.Vector.Unboxed.Mutable as MVU v <- MVU.generate 10 (\x -> x*x) MVU.read v 39  vector1Yield the element at the given position. Returns  if the index is out of range.Examples3import qualified Data.Vector.Unboxed.Mutable as MVU v <- MVU.generate 10 (\x -> x*x)MVU.readMaybe v 3Just 9MVU.readMaybe v 13Nothing vector*Replace the element at the given position. vector)Modify the element at the given position.  vectorModify the element at the given position using a monadic function. 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.  vectorModify the element at the given position using a monadic function. 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. vectorCopy a vector. The two vectors must have the same length and may not overlap, but 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 (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation.  vectorO(n) Apply the monadic action to every element of the vector, discarding the results.  vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results.  vectorO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_.  vectorO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_. vectorO(n) Pure left fold. vectorO(n)( Pure left fold with strict accumulator. vectorO(n) Pure left fold using a function applied to each element and its index. vectorO(n) Pure left fold with strict accumulator using a function applied to each element and its index. vectorO(n) Pure right fold. vectorO(n)) Pure right fold with strict accumulator. vectorO(n) Pure right fold using a function applied to each element and its index. vectorO(n) Pure right fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic fold. vectorO(n)& Monadic fold with strict accumulator. vectorO(n) Monadic fold using a function applied to each element and its index. vectorO(n) Monadic fold with strict accumulator using a function applied to each element and its index. vectorO(n) Monadic right fold. vectorO(n), Monadic right fold with strict accumulator. vectorO(n) Monadic right fold using a function applied to each element and its index. vectorO(n) Monadic right fold with strict accumulator using a function applied to each element and its index.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    &'()*+,-.,/0,/123423523623623723823923:;;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`QRa[bc d d e f g h i i j k l m n o p q r s t u v w x y z { | } ~                                                                                                    dnopqrstvxyz{|}~pqtuvw                    pq~{|rstvxyzuw   P P p q               t u v w                                               ^ p q  ~ { |                       r s t v              x y z  u w                                                                                                                                                                                         PPpqtuvw ^ ^  p q  ~ { |                       r s t v              x y z  u w                                                                                                                                                    PPpqtuvw^pq~{|rstvxyzuw%%%%%%%%%%%^%P%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%pq~{|rstvxyzuwpqtuvw&&&2323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323~23}23|23{23z23y23x23w23v23u23t23s23r23q23p2323&)p)t)))))))&&&)&,&"$""")#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&vector-0.13.0.0-Isuxt6i9i5JITGRjEhCjvKData.Vector.Generic.MutableData.Vector.Storable.MutableData.Vector.Primitive.MutableData.Vector.Fusion.UtilData.Vector.Fusion.BundleData.Vector.Fusion.Bundle.Size Data.Vector.Generic.Mutable.BaseData.Vector.Generic!Data.Vector.Fusion.Bundle.MonadicData.Vector.Generic.NewData.Vector.Mutable Data.VectorData.Vector.PrimitiveData.Vector.StorableData.Vector.UnboxedData.Vector.Unboxed.Mutable!Data.Vector.Fusion.Stream.MonadicData.Vector.Generic.BaseData.Vector.Internal.Check Foreign.PtrPtr Data.ListgroupBygroup maximumByPrelude showsPrec Text.ReadreadPrec Data.Datagfoldl Data.IORefIORefData.Vector.Storable.InternalGHC.ForeignPtrunsafeWithForeignPtrData.Vector.Unboxed.Baseghc-primGHC.Prim RealWorldbaseForeign.StorableStorable(primitive-0.7.4.0-Jn1nYXToEHPK8exID3XEUlData.Primitive.TypesPrimControl.Monad.Primitive PrimState PrimMonad,vector-stream-0.1.0.0-6UufFtoaTP73gTDZeHsWfxData.Stream.MonadicliftBoxunBoxBoxDoneSkipYieldStepIdunId delay_inline delayed_min $fMonadId$fApplicativeId $fFunctorIdSizeExactMaxUnknownclampedSubtractsmaller smallerThanlargertoMax lowerBound upperBound $fNumSize$fEqSize $fShowSizeMVector basicLengthbasicUnsafeSlice basicOverlapsbasicUnsafeNewbasicInitializebasicUnsafeReplicatebasicUnsafeReadbasicUnsafeWrite basicClearbasicSetbasicUnsafeCopybasicUnsafeMovebasicUnsafeGrowVectorbasicUnsafeFreezebasicUnsafeThawbasicUnsafeIndexMelemseqMutableBundlesElemssChunkssVectorsSizeChunklift fromStreamchunkselementssizesizedlengthnullempty singleton replicate replicateMgenerate generateMconssnoc++headlast!!!?sliceinittailtakedropmapmapMmapM_transunboxindexedindexedRzipWithM zipWithM_ zipWith3M zipWith4M zipWith5M zipWith6MzipWithzipWith3zipWith4zipWith5zipWith6zipzip3zip4zip5zip6eqBycmpByfilterfilterM mapMaybeM 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 fromListNunsafeFromList fromVector fromVectors concatVectorsreVector$fFunctorBundleMBundleinplaceeqcmp $fOrd1Bundle $fEq1Bundle $fOrdBundle $fEqBundlemstreamfill transformmstreamRfillR transformRunstream munstream vunstream unstreamR munstreamRsplitAt unsafeSlice unsafeInit unsafeTail unsafeTake unsafeDropoverlapsnew unsafeNewclonegrow growFront unsafeGrowunsafeGrowFrontclearread readMaybewritemodifymodifyMswapexchange unsafeRead unsafeWrite unsafeModify unsafeModifyM unsafeSwapunsafeExchangeimapM_forM_iforM_ifoldlifoldl'foldr'ifoldrifoldr'ifoldMifoldM'foldrM'ifoldrMifoldrM'setcopymove unsafeCopy unsafeMoveaccumupdate unsafeAccum unsafeUpdatereverseunstablePartitionunstablePartitionBundlepartitionBundlepartitionWithBundlenextPermutationNewcreaterunrunPrimapplymodifyWithBundle! unsafeIndex unsafeHead unsafeLastindexMheadMlastM unsafeIndexM unsafeHeadM unsafeLastMunconsunsnoc constructN constructrN enumFromNconcatconcatNEcreateTforce//update_ unsafeUpd unsafeUpdate_ accumulate accumulate_unsafeAccumulateunsafeAccumulate_ backpermuteunsafeBackpermuteimapimapMforMiforMizipWith izipWith3 izipWith4 izipWith5 izipWith6 izipWithM izipWithM_unzipunzip3unzip4unzip5unzip6ifilteruniqmapMaybe imapMaybe imapMaybeM partition partitionWithspanbreak findIndexR findIndices elemIndex elemIndicesfoldr1'foldMapfoldMap'allanysumproductmaximum maximumOnminimum minimumBy minimumOnmaxIndex maxIndexByminIndex minIndexByfoldM_ifoldM_fold1M_foldM'_ifoldM'_fold1M'_sequence sequence_iscanliscanl'prescanr prescanr' postscanr postscanr'scanrscanr'iscanriscanr'scanr1scanr1'convert unsafeFreezefreeze unsafeThawthawstreamstreamR unstreamM liftShowsPrec liftReadsPrec mkVecConstr mkVecTypemkTypegunfolddataCastSTVectorIOVectorfromMutableArraytoMutableArray$fMVectorMVectora catMaybes fromArraytoArray toArraySliceunsafeFromArraySlice$fTraversableVector$fFoldableVector$fAlternativeVector$fApplicativeVector$fMonadFixVector$fMonadZipVector$fMonadPlusVector$fMonadFailVector $fMonadVector$fFunctorVector$fMonoidVector$fSemigroupVector $fOrd1Vector $fEq1Vector $fOrdVector $fEqVector$fVectorVectora $fDataVector$fIsListVector $fRead1Vector $fShow1Vector $fReadVector $fShowVector$fNFData1Vector$fNFDataVectorunsafeCoerceMVector unsafeCast$fNFData1MVector$fNFDataMVectorunsafeCoerceVectorunsafeFromForeignPtrunsafeFromForeignPtr0unsafeToForeignPtrunsafeToForeignPtr0 unsafeWith isSameVectorAsIsoUnboxtoURepr fromURepr UnboxViaPrimUnboxMV_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_Int V_UnboxAs MV_UnboxAsMV_UnboxViaPrimMV_Unit GHC.TypesSPECSPEC2Stream GHC.Classesmin Data.FoldableGHC.ListGHC.Stack.Types HasCallStackChecksUnsafeInternalBoundsdoChecks internalErrorcheck checkIndex checkLength checkSliceinRange&&|| GHC.MaybeNothingJustGHC.Baseflip Data.EitherLeftRightFoldableTrueEqOrdText.ParserCombinators.ReadPReadSIOData.Primitive.ArrayArray CoerciblegetPtrsetPtrupdPtr ForeignPtrV_UnitV_UnboxViaPrimV_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