!teo      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) 2019 Emily Pillmore BSD-style$Emily Pillmore <emilypi@cohomolo.gy> ExperimentalDataTypeable, CPPNone2MSXnonempty-vector is a thin wrapper around y that witnesses an API requiring non-empty construction, initialization, and generation of non-empty vectors by design.aA newtype wrapper was chosen so that no new pointer indirection is introduced when working with ;s, and all performance characteristics inherited from the  API still apply.nonempty-vectorO(1) Length.length $ unsafeFromList [1..10]10nonempty-vectorO(1)V First element. Since head is gauranteed, bounds checks are bypassed by deferring to  unsafeHead.head $ unsafeFromList [1..10]1nonempty-vectorO(1)_ Last element. Since a last element is gauranteed, bounds checks are bypassed by deferring to  unsafeLast.last $ unsafeFromList [1..10]10nonempty-vectorO(1) Indexing.(unsafeFromList [1..10]) ! 01nonempty-vectorO(1) Safe indexing.(unsafeFromList [1..10]) !? 0Just 1(unsafeFromList [1..10]) !? 11Nothingnonempty-vectorO(1)( Unsafe indexing without bounds checkingnonempty-vectorO(1) Indexing in a monad.QThe monad allows operations to be strict in the non-empty vector when necessary.See  for more details%indexM @[] (unsafeFromList [1..10]) 3[4]nonempty-vectorO(1)0 First element of a non-empty vector in a monad.See * for an explanation of why this is useful."Note that this function defers to  unsafeHeadM6 since head is gauranteed to be safe by construction."headM @[] (unsafeFromList [1..10])[1] nonempty-vectorO(1)4 Last element of a non-empty vector in a monad. See + for an explanation of why this is useful."Note that this function defers to  unsafeHeadM% since a last element is gauranteed."lastM @[] (unsafeFromList [1..10])[10] nonempty-vector4O(1) Indexing in a monad without bounds checks. See + for an explanation of why this is useful. nonempty-vectorO(1) Yield all but the first element without copying. Since the vector returned may be empty (i.e. input was a singleton), this function returns a normal tail (unsafeFromList [1..10])[2,3,4,5,6,7,8,9,10] nonempty-vectorO(1)= Yield a slice of a non-empty vector without copying at the 0th and 1 st indices.uncons (unsafeFromList [1..10])(1,[2,3,4,5,6,7,8,9,10]) nonempty-vectorO(1)= Yield a slice of a non-empty vector without copying at the n-1th and nth indicesunsnoc (unsafeFromList [1..10])([1,2,3,4,5,6,7,8,9],10)nonempty-vectorO(1) Yield a slice of the non-empty vector without copying it. The vector must contain at least i+n elements. Because this is not guaranteed, this function returns a  which could be empty"slice 0 3 (unsafeFromList [1..10])[1,2,3]nonempty-vectorO(1) Yield all but the last element without copying. Since the vector returned may be empty (i.e. input was a singleton), this function returns a normal init (unsafeFromList [1..3])[1,2]nonempty-vectorO(1) Yield at the first n elements without copying. The non-empty vector may contain less than n elements in which case it is returned as a vector unchanged.take 2 (unsafeFromList [1..3])[1,2]nonempty-vectorO(1) Yield all but the first n elements without copying. The non-empty vector may contain less than n elements in which case an empty vector is returned.drop 2 (unsafeFromList [1..3])[3]nonempty-vectorO(1)F Yield the first n elements paired with the remainder without copying.EThis function returns a pair of vectors, as one may slice a (0, n+1).!splitAt 2 (unsafeFromList [1..3]) ([1,2],[3])nonempty-vectorO(1)u Yield a slice of the vector without copying. The vector must contain at least i+n elements but this is not checked.nonempty-vectorO(1)r Yield the first n elements without copying. The vector must contain at least n elements but this is not checked.nonempty-vectorO(1)z Yield all but the first n elements without copying. The vector must contain at least n elements but this is not checked.nonempty-vectorO(1)* Non-empty vector with exactly one element singleton "a"["a"]nonempty-vectorO(n)L Non-empty vector of the given length with the same value in each position. When given a index n <= 0, then  is returned, otherwise .replicate 3 "a"Just ["a","a","a"]replicate 0 "a"Nothingnonempty-vectorO(n)L Non-empty vector of the given length with the same value in each position.This variant takes max n 1# for the supplied length parameter.replicate1 3 "a" ["a","a","a"]replicate1 0 "a"["a"]replicate1 (-1) "a"["a"]nonempty-vectorO(n)P Construct a vector of the given length by applying the function to each index. When given a index n <= 0, then  is returned, otherwise .,let f 0 = "a"; f _ = "k"; f :: Int -> String generate 1 f Just ["a"] generate 0 fNothing generate 2 fJust ["a","k"]nonempty-vectorO(n)P Construct a vector of the given length by applying the function to each index.This variant takes max n 1# for the supplied length parameter.,let f 0 = "a"; f _ = "k"; f :: Int -> String generate1 2 f ["a","k"] generate1 0 f["a"]generate1 (-1) f["a"]nonempty-vectorO(n)C Apply function n times to value. Zeroth element is original value. When given a index n <= 0, then  is returned, otherwise .iterateN 3 (+1) 0 Just [0,1,2]iterateN 0 (+1) 0NothingiterateN (-1) (+1) 0Nothingnonempty-vectorO(n)C Apply function n times to value. Zeroth element is original value.This variant takes max n 1# for the supplied length parameter.iterateN1 3 (+1) 0[0,1,2]iterateN1 0 (+1) 0[0]iterateN1 (-1) (+1) 0[0]nonempty-vectorO(n)Y Execute the monadic action the given number of times and store the results in a vector. When given a index n <= 0, then  is returned, otherwise .replicateM @Maybe 3 (Just "a")Just (Just ["a","a","a"])replicateM @Maybe 3 NothingNothingreplicateM @Maybe 0 (Just "a") Just Nothing!replicateM @Maybe (-1) (Just "a") Just Nothingnonempty-vectorO(n)Y Execute the monadic action the given number of times and store the results in a vector.This variant takes max n 1# for the supplied length parameter.replicate1M @Maybe 3 (Just "a")Just ["a","a","a"]replicate1M @Maybe 3 NothingNothingreplicate1M @Maybe 0 (Just "a") Just ["a"]"replicate1M @Maybe (-1) (Just "a") Just ["a"]nonempty-vectorO(n)U Construct a vector of the given length by applying the monadic action to each index When given a index n <= 0, then  is returned, otherwise .4generateM 3 (\i -> if i P.< 1 then ["a"] else ["b"])[Just ["a","b","b"]]generateM @[] @Int 3 (const [])[] generateM @[] @Int 0 (const [1]) [Nothing]*generateM @Maybe @Int (-1) (const Nothing) Just Nothing nonempty-vectorO(n)U Construct a vector of the given length by applying the monadic action to each indexThis variant takes max n 1# for the supplied length parameter.;generate1M 3 (\i -> if i P.< 1 then Just "a" else Just "b")Just ["a","b","b"]generate1M 3 (const [])[]generate1M 0 (const $ Just 1)Just [1]generate1M (-1) (const Nothing)Nothing!nonempty-vectorO(n)L Apply monadic function n times to value. Zeroth element is original value. When given a index n <= 0, then  is returned, otherwise .iterateNM @Maybe 3 return "a"Just (Just ["a","a","a"])&iterateNM @Maybe 3 (const Nothing) "a"NothingiterateNM @Maybe 0 return "a" Just Nothing"nonempty-vectorO(n)L Apply monadic function n times to value. Zeroth element is original value.This variant takes max n 1# for the supplied length parameter.iterateN1M @Maybe 3 return "a"Just ["a","a","a"]'iterateN1M @Maybe 3 (const Nothing) "a"NothingiterateN1M @Maybe 0 return "a" Just ["a"]!iterateN1M @Maybe (-1) return "a" Just ["a"]#nonempty-vectorEExecute the monadic action and freeze the resulting non-empty vector.$nonempty-vectorbExecute the monadic action and freeze the resulting non-empty vector, bypassing emptiness checks.GThe onus is on the caller to guarantee the created vector is non-empty.%nonempty-vectorEExecute the monadic action and freeze the resulting non-empty vector.&nonempty-vectorEExecute the monadic action and freeze the resulting non-empty vector.GThe onus is on the caller to guarantee the created vector is non-empty.'nonempty-vectorO(n)v Construct a non-empty 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.0If an unfold does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned.Cunfoldr (\b -> case b of "a" -> Just ("a", "b"); _ -> Nothing) "a" Just ["a"]unfoldr (const Nothing) "a"Nothing(nonempty-vectorO(n)k Construct a non-empty vector by repeatedly applying the generator function to a seed and a first element.This variant of 'P guarantees the resulting vector is non- empty by supplying an initial element a.Lunfoldr1 (\b -> case b of "a" -> Just ("a", "b"); _ -> Nothing) "first" "a" ["first","a"]$unfoldr1 (const Nothing) "first" "a" ["first"])nonempty-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.0If an unfold does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned.$unfoldrN 3 (\b -> Just (b+1, b+1)) 0 Just [1,2,3]unfoldrN 3 (const Nothing) 0Nothing$unfoldrN 0 (\b -> Just (b+1, b+1)) 0Nothing*nonempty-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.This variant of )P guarantees the resulting vector is non- empty by supplying an initial element a.'unfoldr1N 3 (\b -> Just (b+1, b+1)) 0 0 [0,1,2,3]unfoldr1N 3 (const Nothing) 0 0[0]'unfoldr1N 0 (\b -> Just (b+1, b+1)) 0 0[0]+nonempty-vectorO(n) Construct a non-empty vector by repeatedly applying the monadic generator function to a seed. The generator function yields Just the next element and the new seed or Nothing if there are no more elements.0If an unfold does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned.,nonempty-vectorO(n) Construct a non-empty vector by repeatedly applying the monadic generator function to a seed. The generator function yields Just the next element and the new seed or Nothing if there are no more elements.This variant of +P guarantees the resulting vector is non- empty by supplying an initial element a.-nonempty-vectorO(n) Construct a non-empty vector by repeatedly applying the monadic generator function to a seed. The generator function yields Just the next element and the new seed or Nothing if there are no more elements.0If an unfold does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned..nonempty-vectorO(n) Construct a non-empty vector by repeatedly applying the monadic generator function to a seed. The generator function yields Just the next element and the new seed or Nothing if there are no more elements.This variant of -P guarantees the resulting vector is non- empty by supplying an initial element a./nonempty-vectorO(n) Construct a non-empty vector with n elements by repeatedly applying the generator function to the already constructed part of the vector.If /$ does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned.0nonempty-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.If 0$ does not create meaningful values,  is returned. Otherwise, + containing a non-empty vector is returned.1nonempty-vectorO(n) Yield a non-emptyvector of the given length containing the values x, x+1 etc. This operation is usually more efficient than 5.3If an enumeration does not use meaningful indices,  is returned, otherwise,  containing a non-empty vector.2nonempty-vectorO(n)# Yield a non-emptyvector of length max n 1S containing the values x, x+1 etc. This operation is usually more efficient than 5.3nonempty-vectorO(n) Yield a non-empty vector of the given length containing the values x, x+y, x+y+y etc. This operations is usually more efficient than 6.3If an enumeration does not use meaningful indices,  is returned, otherwise,  containing a non-empty vector.4nonempty-vectorO(n)$ Yield a non-empty vector of length max n 1[ containing the values x, x+y, x+y+y etc. This operations is usually more efficient than 6.5nonempty-vectorO(n) Enumerate values from x to y.3If an enumeration does not use meaningful indices,  is returned, otherwise,  containing a non-empty vector.WARNINGC: This operation can be very inefficient. If at all possible, use 1 instead.6nonempty-vectorO(n)5 Enumerate values from x to y with a specific step z.3If an enumeration does not use meaningful indices,  is returned, otherwise,  containing a non-empty vector.WARNINGC: This operation can be very inefficient. If at all possible, use 3 instead.7nonempty-vectorO(n) Prepend an elementcons 1 (unsafeFromList [2,3])[1,2,3]8nonempty-vectorO(n) Append an elementsnoc (unsafeFromList [1,2]) 3[1,2,3]9nonempty-vectorO(m+n)" Concatenate two non-empty vectors2(unsafeFromList [1..3]) ++ (unsafeFromList [4..6]) [1,2,3,4,5,6]:nonempty-vectorO(n). Concatenate all non-empty vectors in the listIf list is empty,  is returned, otherwise / containing the concatenated non-empty vectors9concat [(unsafeFromList [1..3]), (unsafeFromList [4..6])]Just [1,2,3,4,5,6];nonempty-vector;O(n) Concatenate all non-empty vectors in a non-empty list.>concat1 ((unsafeFromList [1..3]) :| [(unsafeFromList [4..6])]) [1,2,3,4,5,6]<nonempty-vectorO(n)0 Convert a non-empty vector to a non-empty list."toNonEmpty (unsafeFromList [1..3]) 1 :| [2,3]=nonempty-vector9O(n) Convert from a non-empty list to a non-empty vector.fromNonEmpty (1 :| [2,3])[1,2,3]>nonempty-vectorRO(n) Convert from the first n-elements of a non-empty list to a non-empty vector.Returns  if indices are <= 0, otherwise " containing the non-empty vector.fromNonEmptyN 3 (1 :| [2..5]) Just [1,2,3]fromNonEmptyN 0 (1 :| [2..5])Nothing?nonempty-vectormO(n) Convert from the first n-elements of a non-empty list to a non-empty vector. This is a safe version of > which takes max n 1/ of the first n-elements of the non-empty list.fromNonEmptyN1 3 (1 :| [2..5])[1,2,3]fromNonEmptyN1 0 (1 :| [2..5])[1]@nonempty-vectorO(1)- Convert from a non-empty vector to a vector.Elet nev :: NonEmptyVector Int = unsafeFromList [1..3] in toVector nev[1,2,3]Anonempty-vectorO(1)- Convert from a vector to a non-empty vector.If the vector is empty, then  is returned, otherwise ! containing the non-empty vector.fromVector $ V.fromList [1..3] Just [1,2,3]fromVector $ V.fromList []NothingBnonempty-vectorO(1)F Convert from a vector to a non-empty vector without checking bounds.Warning`: the onus is on the user to ensure that their vector is not empty, otherwise all bets are off!$unsafeFromVector $ V.fromList [1..3][1,2,3]Cnonempty-vectorO(n)+ Convert from a non-empty vector to a list.Clet nev :: NonEmptyVector Int = unsafeFromList [1..3] in toList nev[1,2,3]Dnonempty-vectorO(n)+ Convert from a list to a non-empty vector.fromList [1..3] Just [1,2,3] fromList []NothingEnonempty-vectorO(n)+ Convert from a list to a non-empty vector.Warning`: the onus is on the user to ensure that their vector is not empty, otherwise all bets are off!unsafeFromList [1..3][1,2,3]Fnonempty-vectorO(n)> Convert the first n elements of a list to a non-empty vector.2If the list is empty or <= 0 elements are chosen,  is returned, otherwise  containing the non-empty vectorfromListN 3 [1..5] Just [1,2,3]fromListN 3 []NothingfromListN 0 [1..5]NothingGnonempty-vectorO(n)Y Yield the argument but force it not to retain any extra memory, possibly by copying it.Hnonempty-vectorO(m+n)] For each pair (i,a) from the list, replace the non-empty vector element at position i by a. unsafeFromList [1..3] // [(2,4)][1,2,4]unsafeFromList [1..3] // [][1,2,3]Inonempty-vectorpO(m+n) For each pair (i,a) from the vector of index/value pairs, replace the vector element at position i by a.1unsafeFromList [1..3] `update` V.fromList [(2,4)][1,2,4]&unsafeFromList [1..3] `update` V.empty[1,2,3]Jnonempty-vectorO(m+min(n1,n2)) For each index i 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.Aupdate_ (unsafeFromList [1..3]) (V.fromList [2]) (V.fromList [4])[1,2,4]/update_ (unsafeFromList [1..3]) V.empty V.empty[1,2,3]Knonempty-vector+Same as '(//)' but without bounds checking.Lnonempty-vectorSame as I but without bounds checking.Mnonempty-vectorSame as J but without bounds checking.Nnonempty-vectorO(m+n) For each pair (i,b)@ from the non-empty list, replace the non-empty vector element a at position i by f a b.*accum (+) (unsafeFromList [1..3]) [(2,10)][1,2,13]$accum (+) (unsafeFromList [1..3]) [][1,2,3]Ononempty-vectorO(m+n) For each pair (i,b)A from the vector of pairs, replace the non-empty vector element a at position i by f a b.<accumulate (+) (unsafeFromList [1..3]) (V.fromList [(2,10)])[1,2,13].accumulate (+) (unsafeFromList [1..3]) V.empty[1,2,3]Pnonempty-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 non-empty vector at position i by f a b.Jaccumulate_ (+) (unsafeFromList [1..3]) (V.fromList [2]) (V.fromList [10])[1,2,13]7accumulate_ (+) (unsafeFromList [1..3]) V.empty V.empty[1,2,3]Qnonempty-vectorSame as N but without bounds checking.Rnonempty-vectorSame as O but without bounds checking.Snonempty-vectorSame as P but without bounds checking.Tnonempty-vectorO(n) Reverse a non-empty vectorreverse $ unsafeFromList [1..3][3,2,1]Unonempty-vectorO(n)@ Yield the non-empty vector obtained by replacing each element i" of the non-empty index vector by xsi. This is equivalent to Y (xs) is" but is often much more efficient.:backpermute (unsafeFromList [1..3]) (unsafeFromList [2,0])[3,1]Vnonempty-vectorSame as U but without bounds checking.Wnonempty-vectorApply a destructive operation to a non-empty vector. The operation will be performed in place if it is safe to do so and will modify a copy of the non-empty vector otherwise.Xnonempty-vectorO(n). Pair each element in a vector with its index.&indexed $ unsafeFromList ["a","b","c"][(0,"a"),(1,"b"),(2,"c")]Ynonempty-vectorO(n)( Map a function over a non-empty vector. map (+1) $ unsafeFromList [1..3][2,3,4]Znonempty-vectorO(n)H Apply a function to every element of a non-empty vector and its index.Bimap (\i a -> if i == 2 then a+1 else a+0) $ unsafeFromList [1..3][1,2,4][nonempty-vector9Map a function over a vector and concatenate the results.?concatMap (\a -> unsafeFromList [a,a]) (unsafeFromList [1,2,3]) [1,1,2,2,3,3]\nonempty-vectorO(n)i Apply the monadic action to all elements of the non-empty vector, yielding non-empty vector of results.!mapM Just (unsafeFromList [1..3]) Just [1,2,3],mapM (const Nothing) (unsafeFromList [1..3])Nothing]nonempty-vectorO(n)x Apply the monadic action to every element of a non-empty vector and its index, yielding a non-empty vector of results.IimapM (\i a -> if i == 1 then Just a else Just 0) (unsafeFromList [1..3]) Just [0,2,0]/imapM (\_ _ -> Nothing) (unsafeFromList [1..3])Nothing^nonempty-vectorO(n)X Apply the monadic action to all elements of a non-empty vector and ignore the results./mapM_ (const $ Just ()) (unsafeFromList [1..3])Just ()-mapM_ (const Nothing) (unsafeFromList [1..3])Nothing_nonempty-vectorO(n)f Apply the monadic action to every element of a non-emptpy vector and its index, ignoring the resultsUimapM_ (\i a -> if i == 1 then P.print a else P.putStrLn "0") (unsafeFromList [1..3])0200imapM_ (\_ _ -> Nothing) (unsafeFromList [1..3])Nothing`nonempty-vectorO(n)l Apply the monadic action to all elements of the non-empty vector, yielding a non0empty vector of results.Equivalent to flip \.anonempty-vectorO(n)X Apply the monadic action to all elements of a non-empty vector and ignore the results.Equivalent to flip ^.bnonempty-vector O(min(m,n))3 Zip two non-empty vectors with the given function.;zipWith (+) (unsafeFromList [1..3]) (unsafeFromList [1..3])[2,4,6]cnonempty-vector4Zip three non-empty vectors with the given function.dnonempty-vector3Zip four non-empty vectors with the given function.enonempty-vector3Zip five non-empty vectors with the given function.fnonempty-vector2Zip six non-empty vectors with the given function.gnonempty-vector O(min(m,n))R Zip two non-empty vectors with a function that also takes the elements' indices.hnonempty-vectorFZip three non-empty vectors and their indices with the given function.inonempty-vectorEZip four non-empty vectors and their indices with the given function.jnonempty-vectorEZip five non-empty vectors and their indices with the given function.knonempty-vectorDZip six non-empty vectors and their indices with the given function.lnonempty-vector O(min(n,m))N Elementwise pairing of non-empty vector elements. This is a special case of b% where the function argument is '(,)'mnonempty-vector%Zip together three non-empty vectors.nnonempty-vector$Zip together four non-empty vectors.ononempty-vector$Zip together five non-empty vectors.pnonempty-vector#Zip together six non-empty vectors.qnonempty-vector O(min(m,n))` Zip the two non-empty vectors with the monadic action and yield a non-empty vector of results.rnonempty-vector O(min(m,n))v Zip the two non-empty vectors with a monadic action that also takes the element index and yield a vector of results.snonempty-vector O(min(m,n))O Zip the two non-empty vectors with the monadic action and ignore the results.tnonempty-vector O(min(m,n))o Zip the two non-empty vectors with a monadic action that also takes the element index and ignore the results.unonempty-vector O(min(m,n))# Unzip a non-empty vector of pairs.vnonempty-vector$Unzip a non-empty vector of triples.wnonempty-vector'Unzip a non-empty vector of quadruples.xnonempty-vector'Unzip a non-empty vector of quintuples.ynonempty-vector&Unzip a non-empty vector of sextuples.znonempty-vectorO(n)1 Drop elements that do not satisfy the predicate.HIf no elements satisfy the predicate, the resulting vector may be empty.Efilter (\a -> if a == 2 then False else True) (unsafeFromList [1..3])[1,3],filter (const False) (unsafeFromList [1..3])[]{nonempty-vectorO(n)_ Drop elements that do not satisfy the predicate which is applied to values and their indices.HIf no elements satisfy the predicate, the resulting vector may be empty.Rifilter (\i a -> if a == 2 || i == 0 then False else True) (unsafeFromList [1..3])[3]/ifilter (\_ _ -> False) (unsafeFromList [1..3])[]|nonempty-vectorO(n)9 Drop elements that do not satisfy the monadic predicate.HIf no elements satisfy the predicate, the resulting vector may be empty.PfilterM (\a -> if a == 2 then Just False else Just True) (unsafeFromList [1..3]) Just [1,3]MfilterM (\a -> if a == 2 then Nothing else Just True) (unsafeFromList [1..3])Nothing4filterM (const $ Just False) (unsafeFromList [1..3])Just []}nonempty-vectorO(n)` Drop elements that do not satisfy the monadic predicate that is a function of index and value.HIf no elements satisfy the predicate, the resulting vector may be empty.2TODO: this should be a more efficient function in vector.]ifilterM (\i a -> if a == 2 || i == 0 then Just False else Just True) (unsafeFromList [1..3])Just [3]ZifilterM (\i a -> if a == 2 || i == 0 then Nothing else Just True) (unsafeFromList [1..3])Nothing5ifilterM (\_ _ -> Just False) (unsafeFromList [1..3])Just []~nonempty-vectorO(n)! Drop repeated adjacent elements.%uniq $ unsafeFromList [1,1,2,2,3,3,1] [1,2,3,1]nonempty-vectorO(n)- Drop elements when predicate returns NothingHIf no elements satisfy the predicate, the resulting vector may be empty.KmapMaybe (\a -> if a == 2 then Nothing else Just a) (unsafeFromList [1..3])[1,3]nonempty-vectorO(n)J Drop elements when predicate, applied to index and value, returns NothingHIf no elements satisfy the predicate, the resulting vector may be empty.XimapMaybe (\i a -> if a == 2 || i == 2 then Nothing else Just a) (unsafeFromList [1..3])[1]nonempty-vectorO(n)P Yield the longest prefix of elements satisfying the predicate without copying.HIf no elements satisfy the predicate, the resulting vector may be empty.(takeWhile (/= 3) (unsafeFromList [1..3])[1,2]nonempty-vectorO(n)Q Drop the longest prefix of elements that satisfy the predicate without copying.IIf all elements satisfy the predicate, the resulting vector may be empty.(dropWhile (/= 3) (unsafeFromList [1..3])[3]nonempty-vectorO(n) Split the non-empty vector in two parts, the first one containing those elements that satisfy the predicate and the second one those that don't. The relative order of the elements is preserved at the cost of a sometimes reduced performance compared to .XIf all or no elements satisfy the predicate, one of the resulting vectors may be empty.'partition (< 3) (unsafeFromList [1..5])([1,2],[3,4,5])nonempty-vectorO(n) Split the non-empty vector in two parts, the first one containing those elements that satisfy the predicate and the second one those that don't. The order of the elements is not preserved but the operation is often faster than .XIf all or no elements satisfy the predicate, one of the resulting vectors may be empty.nonempty-vectorO(n)y Split the non-empty vector into the longest prefix of elements that satisfy the predicate and the rest without copying.XIf all or no elements satisfy the predicate, one of the resulting vectors may be empty.(span (== 1) (unsafeFromList [1,1,2,3,1])([1,1],[2,3,1])nonempty-vectorO(n)v Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.XIf all or no elements satisfy the predicate, one of the resulting vectors may be empty.)break (== 2) (unsafeFromList [1,1,2,3,1])([1,1],[2,3,1])nonempty-vectorO(n)2 Check if the non-empty vector contains an elementelem 1 $ unsafeFromList [1..3]Trueelem 4 $ unsafeFromList [1..3]Falsenonempty-vectorO(n)H Check if the non-empty vector does not contain an element (inverse of )!notElem 1 $ unsafeFromList [1..3]False!notElem 4 $ unsafeFromList [1..3]Truenonempty-vectorO(n) Yield . the first element matching the predicate or  if no such element exists."find (< 2) $ unsafeFromList [1..3]Just 1"find (< 0) $ unsafeFromList [1..3]Nothingnonempty-vectorO(n) Yield ; the index of the first element matching the predicate or  if no such element exists.'findIndex (< 2) $ unsafeFromList [1..3]Just 0'findIndex (< 0) $ unsafeFromList [1..3]Nothingnonempty-vectorO(n)L Yield the indices of elements satisfying the predicate in ascending order.)findIndices (< 3) $ unsafeFromList [1..3][0,1])findIndices (< 0) $ unsafeFromList [1..3][]nonempty-vectorO(n) Yield ; the index of the first occurence of the given element or Y if the non-empty vector does not contain the element. This is a specialised version of .#elemIndex 1 $ unsafeFromList [1..3]Just 0#elemIndex 0 $ unsafeFromList [1..3]Nothingnonempty-vectorO(n)p Yield the indices of all occurences of the given element in ascending order. This is a specialised version of .(elemIndices 1 $ unsafeFromList [1,2,3,1][0,3]%elemIndices 0 $ unsafeFromList [1..3][]nonempty-vectorO(n) Left monoidal foldnonempty-vectorO(n) Left semigroupal foldnonempty-vectorO(n) Strict Left monoidal foldnonempty-vectorO(n) Strict Left semigroupal foldnonempty-vectorO(n) Right monoidal foldnonempty-vectorO(n) Right semigroupal foldnonempty-vectorO(n) Strict right monoidal foldnonempty-vectorO(n) Strict right semigroupal foldnonempty-vectorO(n)H Left monoidal fold with function applied to each element and its indexnonempty-vectorO(n)O Strict left monoidal fold with function applied to each element and its indexnonempty-vectorO(n)I Right monoidal fold with function applied to each element and its indexnonempty-vectorO(n)P strict right monoidal fold with function applied to each element and its indexnonempty-vectorO(n)- Check if all elements satisfy the predicate.nonempty-vectorO(n). Check if any element satisfies the predicate.nonempty-vectorO(n) Check if all elements are True.nonempty-vectorO(n) Check if any element is Truenonempty-vectorO(n) Compute the sum of the elementsnonempty-vectorO(n)$ Compute the produce of the elementsnonempty-vectorO(n)3 Yield the maximum element of the non-empty vector.nonempty-vectorO(n)] Yield the maximum element of a non-empty vector according to the given comparison function.nonempty-vectorO(n)3 Yield the minimum element of the non-empty vector.nonempty-vectorO(n)_ Yield the minimum element of the non-empty vector according to the given comparison function.nonempty-vectorO(n)A Yield the index of the minimum element of the non-empty vector.nonempty-vectorO(n)b Yield the index of the minimum element of the vector according to the given comparison function.nonempty-vectorO(n)A Yield the index of the maximum element of the non-empty vector.nonempty-vectorO(n)b Yield the index of the maximum element of the vector according to the given comparison function.nonempty-vectorO(n) Monadic foldnonempty-vectorO(n)< Monadic fold (action applied to each element and its index)nonempty-vectorO(n) Strict monadic foldnonempty-vectorO(n)C Strict monadic fold (action applied to each element and its index)nonempty-vectorO(n) Monadic semigroupal foldnonempty-vectorO(n) Strict monadic semigroupal foldnonempty-vectorO(n)& Monadic fold that discards the resultnonempty-vectorO(n)V Monadic fold that discards the result (action applied to each element and its index)nonempty-vectorO(n)- Strict monadic fold that discards the resultnonempty-vectorO(n)] Strict monadic fold that discards the result (action applied to each element and its index)nonempty-vectorO(n)2 Monadic semigroupal fold that discards the resultnonempty-vectorO(n)9 Strict monadic semigroupal fold that discards the resultnonempty-vector,Evaluate each action and collect the resultsnonempty-vector,Evaluate each action and discard the resultsnonempty-vectorO(n) Prescannonempty-vectorO(n) Prescan with strict accumulatornonempty-vectorO(n) Scannonempty-vectorO(n) Scan with a strict accumulatornonempty-vectorO(n) Haskell-style scannonempty-vectorO(n)+ Haskell-style scan with strict accumulatornonempty-vectorO(n) Semigroupal left scannonempty-vectorO(n) Strict semigroupal scannonempty-vectorO(n)" Scan over a vector with its indexnonempty-vectorO(n): Scan over a vector with its index with strict accumulatornonempty-vectorO(n) Right-to-left prescannonempty-vectorO(n). Right-to-left prescan with strict accumulatornonempty-vectorO(n) Right-to-left scannonempty-vectorO(n)+ Right-to-left scan with strict accumulatornonempty-vectorO(n)! Right-to-left Haskell-style scannonempty-vectorO(n)9 Right-to-left Haskell-style scan with strict accumulatornonempty-vectorO(n)- Right-to-left Haskell-style semigroupal scannonempty-vectorO(n)E Right-to-left Haskell-style semigroupal scan with strict accumulatornonempty-vectorO(n)0 Right-to-left scan over a vector with its indexnonempty-vectorO(n)J Right-to-left scan over a vector with its index and a strict accumulatorNnonempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vector%list of index/value pairs (of length n)Ononempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vector'vector of index/value pairs (of length n)Pnonempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vectorvector of indices (of length n1)nonempty-vectorvector of values (of length n2)Qnonempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vector%list of index/value pairs (of length n)Rnonempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vector'vector of index/value pairs (of length n)Snonempty-vectoraccumulating function fnonempty-vector$initial non-empty vector (of length m)nonempty-vectorvector of indices of length n1nonempty-vectorvector of values (of length n2)  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~    !"#$%&'()*+,-./0123456789:;G<=>?E@ABCDFHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqsrtuvwxy~z{|}(c) 2019 Emily Pillmore BSD-style$Emily Pillmore <emilypi@cohomolo.gy> experimental non-portableNone2d*nonempty-vector parametrized by STnonempty-vector parametrized by  nonempty-vector is a thin wrapper around  y that witnesses an API requiring non-empty construction, initialization, and generation of non-empty vectors by design.aA newtype wrapper was chosen so that no new pointer indirection is introduced when working with  ;s, and all performance characteristics inherited from the   API still apply.nonempty-vectorLength of the mutable vector.nonempty-vector3Yield a part of the mutable vector without copying.nonempty-vector.Yield at the first n elements without copying.nonempty-vector3Yield all but the first n elements without copying.nonempty-vectorEYield the first n elements paired with the remainder without copying.nonempty-vector/Yield all but the last element without copying.nonempty-vector0Yield all but the first element without copying.nonempty-vectorWYield a part of the mutable vector without copying it. No bounds checks are performed.nonempty-vectorqYield the first n elements without copying. The vector must contain at least n elements but this is not checked.nonempty-vectoryYield all but the first n elements without copying. The vector must contain at least n elements but this is not checked.nonempty-vector"Check whether two vectors overlap.nonempty-vector6Convert a mutable vector to a non-empty mutable vectornonempty-vector6Convert a non-empty mutable vector to a mutable vectornonempty-vector6Convert a mutable vector to a non-empty mutable vectorWarning: this function is unsafe and can result in empty non-empty mutable vectors. If you call this function, the onus is on you to make sure the mutable vector being converted is not empty.nonempty-vector,Create a mutable vector of the given length.nonempty-vector6Create a mutable vector of the given length which is max n 1.nonempty-vectorKCreate a mutable vector of the given length. The memory is not initialized.nonempty-vectormCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.nonempty-vector&Create a mutable vector of the length max n 18 for a given length, and fill it with an initial value.nonempty-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.nonempty-vector&Create a mutable vector of the length max n 1b for a given length, and fill it with values produced by repeatedly executing the monadic action.nonempty-vector"Create a copy of a mutable vector.nonempty-vectorLGrow a vector by the given number of elements. The number must be positive.nonempty-vectordGrow a vector by the given number of elements. The number must be positive but this is not checked.nonempty-vectorReset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors.nonempty-vector(Yield the element at the given position.nonempty-vector*Replace the element at the given position.nonempty-vector)Modify the element at the given position.nonempty-vector)Swap the elements at the given positions.nonempty-vectorHYield the element at the given position. No bounds checks are performed.nonempty-vectorJReplace the element at the given position. No bounds checks are performed.nonempty-vectorIModify the element at the given position. No bounds checks are performed.nonempty-vectorISwap the elements at the given positions. No bounds checks are performed.nonempty-vector2Set all elements of the vector to the given value.nonempty-vectorNCopy a vector. The two vectors must have the same length and may not overlap.nonempty-vectorcCopy a vector. The two vectors must have the same length and may not overlap. This is not checked.nonempty-vectorJMove 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.nonempty-vectorcMove 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.nonempty-vector~Compute the next (lexicographically) permutation of given vector in-place. Returns False when input is the last permtuationnonempty-vectorstarting indexnonempty-vectorlength of the slicenonempty-vectortargetnonempty-vectorsourcenonempty-vectortargetnonempty-vectorsource**       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !Z nonempty-vector-0.2.0.1-inplaceData.Vector.NonEmptyData.Vector.NonEmpty.MutableNonEmptyVectorlengthheadlast!!? unsafeIndexindexMheadMlastM unsafeIndexMtailunconsunsnocsliceinittakedropsplitAt unsafeSlice unsafeTake unsafeDrop singleton replicate replicate1generate generate1iterateN iterateN1 replicateM replicate1M generateM generate1M iterateNM iterateN1Mcreate unsafeCreatecreateT unsafeCreateTunfoldrunfoldr1unfoldrN unfoldr1NunfoldrM unfoldr1M unfoldrNM unfoldr1NM constructN constructrN enumFromN enumFromN1 enumFromStepNenumFromStepN1 enumFromToenumFromThenToconssnoc++concatconcat1 toNonEmpty fromNonEmpty fromNonEmptyNfromNonEmptyN1toVector fromVectorunsafeFromVectortoListfromListunsafeFromList fromListNforce//updateupdate_ unsafeUpd unsafeUpdate unsafeUpdate_accum accumulate accumulate_ unsafeAccumunsafeAccumulateunsafeAccumulate_reverse backpermuteunsafeBackpermutemodifyindexedmapimap concatMapmapMimapMmapM_imapM_forMforM_zipWithzipWith3zipWith4zipWith5zipWith6izipWith izipWith3 izipWith4 izipWith5 izipWith6zipzip3zip4zip5zip6zipWithM izipWithM zipWithM_ izipWithM_unzipunzip3unzip4unzip5unzip6filterifilterfilterMifilterMuniqmapMaybe imapMaybe takeWhile dropWhile partitionunstablePartitionspanbreakelemnotElemfind findIndex findIndices elemIndex elemIndicesfoldlfoldl1foldl'foldl1'foldrfoldr1foldr'foldr1'ifoldlifoldl'ifoldrifoldr'allanyandorsumproductmaximum maximumByminimum minimumByminIndex minIndexBymaxIndex maxIndexByfoldMifoldMfoldM'ifoldM'fold1Mfold1M'foldM_ifoldM_foldM'_ifoldM'_fold1M_fold1M'_sequence sequence_prescanl prescanl' postscanl postscanl'scanlscanl'scanl1scanl1'iscanliscanl'prescanr prescanr' postscanr postscanr'scanrscanr'scanr1scanr1'iscanriscanr'$fTraversableNonEmptyVector$fFoldableNonEmptyVector$fRead1NonEmptyVector$fReadNonEmptyVector$fShowNonEmptyVector$fEqNonEmptyVector$fOrdNonEmptyVector$fEq1NonEmptyVector$fOrd1NonEmptyVector$fShow1NonEmptyVector$fDataNonEmptyVector$fNFDataNonEmptyVector$fFunctorNonEmptyVector$fApplicativeNonEmptyVector$fMonadNonEmptyVector$fMonadZipNonEmptyVector$fSemigroupNonEmptyVectorNonEmptySTVectorNonEmptyIOVectorNonEmptyMVectoroverlaps fromMVector toMVectorunsafeFromMVectornewnew1 unsafeNewclonegrow unsafeGrowclearreadwriteswap unsafeRead unsafeWrite unsafeModify unsafeSwapsetcopy unsafeCopymove unsafeMovenextPermutationvctr-0.12.0.3-3f66289a Data.VectorVectorbase GHC.MaybeNothingJustprmtv-0.7.0.0-1675227eControl.Monad.Primitive PrimStateData.Vector.MutableMVector