-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Size-parameterized vector types and functions.
--
-- Size-parameterized vector types and functions using a data-type
-- promotion.
@package sized-vector
@version 1.4.1.0
-- | Size-parameterized vector types and functions.
module Data.Vector.Sized
-- | Fixed-length list.
data Vector (a :: *) (n :: Nat)
Nil :: Vector a Z
(:-) :: a -> Vector a n -> Vector a (S n)
-- | Type synonym for Ordinal.
type Index = Ordinal
-- | replicate n x is a vector of length n with
-- x the value of every element.
replicate :: SNat n -> a -> Vector a n
-- | replicate, with the length inferred.
replicate' :: SingI n => a -> Vector a n
-- | Construct a singleton vector.
singleton :: a -> Vector a (S Z)
-- | Uncons the non-empty list.
uncons :: Vector a (S n) -> (a, Vector a n)
-- | Convert a list into a vector. If a given list is shorter than the
-- length, it returns Nothing.
fromList :: SNat n -> [a] -> Maybe (Vector a n)
-- | Convert a list into vector, with length inferred.
fromList' :: SingI n => [a] -> Maybe (Vector a n)
-- | Unsafe version of fromList. If a given list is shorter than the
-- length, it aborts.
unsafeFromList :: SNat n -> [a] -> Vector a n
-- | Unsafe version of unsafeFromList.
unsafeFromList' :: SingI n => [a] -> Vector a n
-- | Convert a vector into a list.
toList :: Vector a n -> [a]
-- | Append two Vectors.
append :: Vector a n -> Vector a m -> Vector a (n :+: m)
-- | Extract the first element of a non-empty vector.
head :: Vector a (S n) -> a
-- | Extract the last element of a non-empty vector.
last :: Vector a (S n) -> a
-- | Extract the elements after the head of a non-empty list.
tail :: Vector a (S n) -> Vector a n
-- | Test whether a Vector is empty, though it's clear from the
-- type parameter.
null :: Vector a n -> Bool
-- | length returns the length of a finite list as an Int.
length :: Vector a n -> Int
-- | sLength returns the length of a finite list as a SNat
-- n.
sLength :: Vector a n -> SNat n
-- | map f xs is the vector obtained by applying f
-- to each element of xs.
map :: (a -> b) -> Vector a n -> Vector b n
-- | reverse xs returns the elements of xs in reverse
-- order. xs must be finite.
reverse :: Vector a n -> Vector a n
-- | The intersperse function takes an element and a vector and
-- `intersperses' that element between the elements of the vector.
intersperse :: a -> Vector a n -> Vector a ((Two :* n) :- One)
-- | The transpose function transposes the rows and columns of its
-- argument.
transpose :: SingI n => Vector (Vector a n) m -> Vector (Vector a m) n
-- | Left fold.
foldl :: (a -> b -> a) -> a -> Vector b n -> a
-- | A strict version of foldl.
foldl' :: (a -> b -> a) -> a -> Vector b n -> a
-- | Left fold for non-empty vector.
foldl1 :: (a -> a -> a) -> Vector a (S n) -> a
-- | A strict version of foldl1.
foldl1' :: (a -> a -> a) -> Vector a (S n) -> a
-- | Right fold.
foldr :: (a -> b -> b) -> b -> Vector a n -> b
-- | Right fold for non-empty vector.
foldr1 :: (a -> a -> a) -> Vector a (S n) -> a
-- | The function concat concatenates all vectors in th vector.
concat :: Vector (Vector a n) m -> Vector a (m :*: n)
-- | and returns the conjunction of a Boolean vector.
and :: Vector Bool m -> Bool
-- | or returns the disjunction of a Boolean vector.
or :: Vector Bool m -> Bool
-- | Applied to a predicate and a list, any determines if any
-- element of the vector satisfies the predicate.
any :: (a -> Bool) -> Vector a n -> Bool
-- | Applied to a predicate and a list, all determines if all
-- element of the vector satisfies the predicate.
all :: (a -> Bool) -> Vector a n -> Bool
sum :: Num a => Vector a n -> a
product :: Num a => Vector a n -> a
maximum :: Ord a => Vector a (S n) -> a
minimum :: Ord a => Vector a (S n) -> a
-- | take n xs returns the prefix of xs of length
-- n, with n less than or equal to the length of
-- xs.
take :: (n :<<= m) ~ True => SNat n -> Vector a m -> Vector a n
-- | A variant of take which returns entire xs if
-- n is greater than the length of xs.
takeAtMost :: SNat n -> Vector a m -> Vector a (Min n m)
-- | drop n xs returns the suffix of xs after the
-- first n elements, with n less than or equal to the
-- length of xs.
drop :: (n :<<= m) ~ True => SNat n -> Vector a m -> Vector a (m :-: n)
-- | splitAt n xs returns a tuple where first element is
-- xs prefix of length n and second element is the
-- remainder of the list. n should be less than or equal to the
-- length of xs.
splitAt :: (n :<<= m) ~ True => SNat n -> Vector a m -> (Vector a n, Vector a (m :-: n))
-- | A varian of splitAt which allows n to be greater than
-- the length of xs.
splitAtMost :: SNat n -> Vector a m -> (Vector a (Min n m), Vector a (m :-: n))
-- | The stripPrefix function drops the given prefix from a vector.
-- It returns Nothing if the vector did not start with the
-- prefix given or shorter than the prefix, or Just the vector after the
-- prefix, if it does.
stripPrefix :: Eq a => Vector a n -> Vector a m -> Maybe (Vector a (m :- n))
elem :: Eq a => a -> Vector a n -> Bool
notElem :: Eq a => a -> Vector a n -> Bool
find :: (a -> Bool) -> Vector a n -> Maybe a
-- | List index (subscript) operator, starting from sZero.
(!!) :: (n :<<= m) ~ True => Vector a (S m) -> SNat n -> a
-- | A Index version of !!.
(%!!) :: Vector a n -> Index n -> a
-- | Flipped version of !!.
index :: (n :<<= m) ~ True => SNat n -> Vector a (S m) -> a
-- | A Index version of index.
sIndex :: Index n -> Vector a n -> a
-- | The elemIndex function returns the index (as Int) of the
-- first element in the given list which is equal (by ==) to the
-- query element, or Nothing if there is no such element.
elemIndex :: Eq a => a -> Vector a n -> Maybe Int
-- | Index version of elemIndex.
sElemIndex :: Eq a => a -> Vector a n -> Maybe (Index n)
-- | The findIndex function takes a predicate and a vector and returns the
-- index of the first element in the vector satisfying the predicate, or
-- Nothing if there is no such element.
findIndex :: (a -> Bool) -> Vector a n -> Maybe Int
-- | Index version of findIndex.
sFindIndex :: (a -> Bool) -> Vector a n -> Maybe (Index n)
-- | The findIndices function extends findIndex, by returning
-- the indices of all elements satisfying the predicate, in ascending
-- order.
findIndices :: (a -> Bool) -> Vector a n -> [Int]
-- | Index version of findIndices.
sFindIndices :: (a -> Bool) -> Vector a n -> [Index n]
-- | The elemIndices function extends elemIndex, by returning
-- the indices of all elements equal to the query element, in ascending
-- order.
elemIndices :: Eq a => a -> Vector a n -> [Int]
-- | Index version of elemIndices.
sElemIndices :: Eq a => a -> Vector a n -> [Index n]
-- | zip takes two vectors and returns a vector of corresponding
-- pairs. If one input list is short, excess elements of the longer list
-- are discarded.
zip :: Vector a n -> Vector b m -> Vector (a, b) (Min n m)
-- | Same as zip, but the given vectors must have the same length.
zipSame :: Vector a n -> Vector b n -> Vector (a, b) n
-- | zipWith generalises zip by zipping with the function
-- given as the first argument, instead of a tupling function.
zipWith :: (a -> b -> c) -> Vector a n -> Vector b m -> Vector c (Min n m)
-- | Same as zipWith, but the given vectors must have the same
-- length.
zipWithSame :: (a -> b -> c) -> Vector a n -> Vector b n -> Vector c n
-- | Inverse of zipSame.
unzip :: Vector (a, b) n -> (Vector a n, Vector b n)
instance Show a => Show (Vector a n)
instance Hashable a => Hashable (Vector a n)
instance NFData a => NFData (Vector a n)
instance Eq a => Eq (Vector a n)
instance Monomorphicable Nat (Vector a)