module Data.Vector.Generic.Sized
( Vector
, length
, length'
, index
, index'
, unsafeIndex
, head
, last
, indexM
, indexM'
, unsafeIndexM
, headM
, lastM
, slice
, slice'
, init
, tail
, take
, take'
, drop
, drop'
, splitAt
, splitAt'
, empty
, singleton
, replicate
, replicate'
, generate
, generate'
, iterateN
, iterateN'
, replicateM
, replicateM'
, generateM
, generateM'
, unfoldrN
, unfoldrN'
, enumFromN
, enumFromN'
, enumFromStepN
, enumFromStepN'
, cons
, snoc
, (++)
, force
, (//)
, update
, update_
, unsafeUpd
, unsafeUpdate
, unsafeUpdate_
, accum
, accumulate
, accumulate_
, unsafeAccum
, unsafeAccumulate
, unsafeAccumulate_
, reverse
, backpermute
, unsafeBackpermute
, indexed
, map
, imap
, concatMap
, mapM
, imapM
, mapM_
, imapM_
, forM
, forM_
, zipWith
, zipWith3
, zipWith4
, zipWith5
, zipWith6
, izipWith
, izipWith3
, izipWith4
, izipWith5
, izipWith6
, zip
, zip3
, zip4
, zip5
, zip6
, zipWithM
, izipWithM
, zipWithM_
, izipWithM_
, unzip
, unzip3
, unzip4
, unzip5
, unzip6
, elem
, notElem
, find
, findIndex
, elemIndex
, foldl
, foldl1
, foldl'
, foldl1'
, foldr
, foldr1
, foldr'
, foldr1'
, ifoldl
, ifoldl'
, ifoldr
, ifoldr'
, all
, any
, and
, or
, sum
, product
, maximum
, maximumBy
, minimum
, minimumBy
, maxIndex
, maxIndexBy
, minIndex
, minIndexBy
, foldM
, ifoldM
, fold1M
, foldM'
, ifoldM'
, fold1M'
, foldM_
, ifoldM_
, fold1M_
, foldM'_
, ifoldM'_
, fold1M'_
, sequence
, sequence_
, prescanl
, prescanl'
, postscanl
, postscanl'
, scanl
, scanl'
, scanl1
, scanl1'
, prescanr
, prescanr'
, postscanr
, postscanr'
, scanr
, scanr'
, scanr1
, scanr1'
, toList
, fromList
, fromListN
, fromListN'
, convert
, toSized
, fromSized
, withVectorUnsafe
) where
import qualified Data.Vector.Generic as VG
import qualified Data.Vector as Boxed
import GHC.TypeLits
import Data.Proxy
import Control.DeepSeq (NFData)
import Foreign.Storable
import Foreign.Ptr (castPtr)
import Prelude hiding ( length, null,
replicate, (++), concat,
head, last,
init, tail, take, drop, splitAt, reverse,
map, concat, concatMap,
zipWith, zipWith3, zip, zip3, unzip, unzip3,
filter, takeWhile, dropWhile, span, break,
elem, notElem,
foldl, foldl1, foldr, foldr1,
all, any, and, or, sum, product, maximum, minimum,
scanl, scanl1, scanr, scanr1,
enumFromTo, enumFromThenTo,
mapM, mapM_, sequence, sequence_,
showsPrec )
newtype Vector v (n :: Nat) a = Vector (v a)
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, NFData)
instance (KnownNat n, Storable a, VG.Vector v a)
=> Storable (Vector v n a) where
sizeOf _ = sizeOf (undefined :: a) * fromInteger (natVal (Proxy :: Proxy n))
alignment _ = alignment (undefined :: a)
peek ptr = generateM (peekElemOff (castPtr ptr))
poke ptr = imapM_ (pokeElemOff (castPtr ptr))
instance KnownNat n => Applicative (Vector Boxed.Vector n) where
pure = replicate
(<*>) = zipWith ($)
instance (Monoid m, VG.Vector v m, KnownNat n) => Monoid (Vector v n m) where
mempty = replicate mempty
mappend = zipWith mappend
instance (VG.Vector v m) => Monoid (Vector v 0 m) where
mempty = empty
_empty1 `mappend` _empty2 = empty
length :: forall v n a. (KnownNat n)
=> Vector v n a -> Int
length _ = fromInteger (natVal (Proxy :: Proxy n))
length' :: forall v n a. (KnownNat n)
=> Vector v n a -> Proxy n
length' _ = Proxy
index :: forall v n a. (KnownNat n, VG.Vector v a)
=> Vector v n a -> Int -> a
index (Vector v) i = v VG.! i
index' :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Vector v (n+m) a -> Proxy n -> a
index' (Vector v) p = v `VG.unsafeIndex` i
where i = fromInteger (natVal p)
unsafeIndex :: forall v n a. (KnownNat n, VG.Vector v a)
=> Vector v n a -> Int -> a
unsafeIndex (Vector v) i = v `VG.unsafeIndex` i
head :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> a
head (Vector v) = VG.unsafeHead v
last :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> a
last (Vector v) = VG.unsafeLast v
indexM :: forall v n a m. (KnownNat n, VG.Vector v a, Monad m)
=> Vector v n a -> Int -> m a
indexM (Vector v) i = v `VG.indexM` i
indexM' :: forall v n k a m. (KnownNat n, KnownNat k, VG.Vector v a, Monad m)
=> Vector v (n+k) a -> Proxy n -> m a
indexM' (Vector v) p = v `VG.indexM` i
where i = fromInteger (natVal p)
unsafeIndexM :: forall v n a m. (KnownNat n, VG.Vector v a, Monad m)
=> Vector v n a -> Int -> m a
unsafeIndexM (Vector v) i = v `VG.unsafeIndexM` i
headM :: forall v n a m. (KnownNat n, VG.Vector v a, Monad m)
=> Vector v (n+1) a -> m a
headM (Vector v) = VG.unsafeHeadM v
lastM :: forall v n a m. (KnownNat n, VG.Vector v a, Monad m)
=> Vector v (n+1) a -> m a
lastM (Vector v) = VG.unsafeLastM v
slice :: forall v i n a. (KnownNat i, KnownNat n, VG.Vector v a)
=> Proxy i
-> Vector v (i+n) a
-> Vector v n a
slice start (Vector v) = Vector (VG.unsafeSlice i n v)
where i = fromInteger (natVal start)
n = fromInteger (natVal (Proxy :: Proxy n))
slice' :: forall v i n a. (KnownNat i, KnownNat n, VG.Vector v a)
=> Proxy i
-> Proxy n
-> Vector v (i+n) a
-> Vector v n a
slice' start _ = slice start
init :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> Vector v n a
init (Vector v) = Vector (VG.unsafeInit v)
tail :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> Vector v n a
tail (Vector v) = Vector (VG.unsafeTail v)
take :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Vector v (m+n) a -> Vector v n a
take (Vector v) = Vector (VG.unsafeTake i v)
where i = fromInteger (natVal (Proxy :: Proxy n))
take' :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Proxy n -> Vector v (m+n) a -> Vector v n a
take' _ = take
drop :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Vector v (m+n) a -> Vector v m a
drop (Vector v) = Vector (VG.unsafeDrop i v)
where i = fromInteger (natVal (Proxy :: Proxy n))
drop' :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Proxy n -> Vector v (m+n) a -> Vector v m a
drop' _ = drop
splitAt :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Vector v (n+m) a -> (Vector v n a, Vector v m a)
splitAt (Vector v) = (Vector a, Vector b)
where i = fromInteger (natVal (Proxy :: Proxy n))
(a, b) = VG.splitAt i v
splitAt' :: forall v n m a. (KnownNat n, KnownNat m, VG.Vector v a)
=> Proxy n -> Vector v (n+m) a -> (Vector v n a, Vector v m a)
splitAt' _ = splitAt
empty :: forall v a. (VG.Vector v a)
=> Vector v 0 a
empty = Vector VG.empty
singleton :: forall v a. (VG.Vector v a)
=> a -> Vector v 1 a
singleton a = Vector (VG.singleton a)
replicate :: forall v n a. (KnownNat n, VG.Vector v a)
=> a -> Vector v n a
replicate a = Vector (VG.replicate i a)
where i = fromInteger (natVal (Proxy :: Proxy n))
replicate' :: forall v n a. (KnownNat n, VG.Vector v a)
=> Proxy n -> a -> Vector v n a
replicate' _ = replicate
generate :: forall v n a. (KnownNat n, VG.Vector v a)
=> (Int -> a) -> Vector v n a
generate f = Vector (VG.generate i f)
where i = fromInteger (natVal (Proxy :: Proxy n))
generate' :: forall v n a. (KnownNat n, VG.Vector v a)
=> Proxy n -> (Int -> a) -> Vector v n a
generate' _ = generate
iterateN :: forall v n a. (KnownNat n, VG.Vector v a)
=> (a -> a) -> a -> Vector v n a
iterateN f z = Vector (VG.iterateN i f z)
where i = fromInteger (natVal (Proxy :: Proxy n))
iterateN' :: forall v n a. (KnownNat n, VG.Vector v a)
=> Proxy n -> (a -> a) -> a -> Vector v n a
iterateN' _ = iterateN
replicateM :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> m a -> m (Vector v n a)
replicateM a = Vector <$> VG.replicateM i a
where i = fromInteger (natVal (Proxy :: Proxy n))
replicateM' :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> Proxy n -> m a -> m (Vector v n a)
replicateM' _ = replicateM
generateM :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> (Int -> m a) -> m (Vector v n a)
generateM f = Vector <$> VG.generateM i f
where i = fromInteger (natVal (Proxy :: Proxy n))
generateM' :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> Proxy n -> (Int -> m a) -> m (Vector v n a)
generateM' _ = generateM
unfoldrN :: forall v n a b. (KnownNat n, VG.Vector v a)
=> (b -> (a, b)) -> b -> Vector v n a
unfoldrN f z = Vector (VG.unfoldrN i (Just . f) z)
where i = fromInteger (natVal (Proxy :: Proxy n))
unfoldrN' :: forall v n a b. (KnownNat n, VG.Vector v a)
=> Proxy n -> (b -> (a, b)) -> b -> Vector v n a
unfoldrN' _ = unfoldrN
enumFromN :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> Vector v n a
enumFromN a = Vector (VG.enumFromN a i)
where i = fromInteger (natVal (Proxy :: Proxy n))
enumFromN' :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> Proxy n -> Vector v n a
enumFromN' a _ = enumFromN a
enumFromStepN :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> a -> Vector v n a
enumFromStepN a a' = Vector (VG.enumFromStepN a a' i)
where i = fromInteger (natVal (Proxy :: Proxy n))
enumFromStepN' :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> a -> Proxy n -> Vector v n a
enumFromStepN' a a' _ = enumFromStepN a a'
cons :: forall v n a. VG.Vector v a
=> a -> Vector v n a -> Vector v (n+1) a
cons x (Vector xs) = Vector (VG.cons x xs)
snoc :: forall v n a. VG.Vector v a
=> Vector v n a -> a -> Vector v (n+1) a
snoc (Vector xs) x = Vector (VG.snoc xs x)
(++) :: forall v n m a. VG.Vector v a
=> Vector v n a -> Vector v m a -> Vector v (n+m) a
Vector vn ++ Vector vm = Vector (vn VG.++ vm)
force :: VG.Vector v a => Vector v n a -> Vector v n a
force (Vector v) = Vector (VG.force v)
(//) :: (VG.Vector v a)
=> Vector v m a
-> [(Int, a)]
-> Vector v m a
Vector v // us = Vector (v VG.// us)
update :: (VG.Vector v a, VG.Vector v (Int, a))
=> Vector v m a
-> Vector v n (Int, a)
-> Vector v m a
update (Vector v) (Vector w) = Vector (VG.update v w)
update_ :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
-> Vector v m a
update_ (Vector v) (Vector is) (Vector w) = Vector (VG.update_ v is w)
unsafeUpd :: (VG.Vector v a)
=> Vector v m a
-> [(Int, a)]
-> Vector v m a
unsafeUpd (Vector v) us = Vector (VG.unsafeUpd v us)
unsafeUpdate :: (VG.Vector v a, VG.Vector v (Int, a))
=> Vector v m a
-> Vector v n (Int, a)
-> Vector v m a
unsafeUpdate (Vector v) (Vector w) = Vector (VG.unsafeUpdate v w)
unsafeUpdate_ :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
-> Vector v m a
unsafeUpdate_ (Vector v) (Vector is) (Vector w) =
Vector (VG.unsafeUpdate_ v is w)
accum :: VG.Vector v a
=> (a -> b -> a)
-> Vector v m a
-> [(Int,b)]
-> Vector v m a
accum f (Vector v) us = Vector (VG.accum f v us)
accumulate :: (VG.Vector v a, VG.Vector v (Int, b))
=> (a -> b -> a)
-> Vector v m a
-> Vector v n (Int,b)
-> Vector v m a
accumulate f (Vector v) (Vector us) = Vector (VG.accumulate f v us)
accumulate_ :: (VG.Vector v a, VG.Vector v Int, VG.Vector v b)
=> (a -> b -> a)
-> Vector v m a
-> Vector v n Int
-> Vector v n b
-> Vector v m a
accumulate_ f (Vector v) (Vector is) (Vector xs) = Vector (VG.accumulate_ f v is xs)
unsafeAccum :: VG.Vector v a
=> (a -> b -> a)
-> Vector v m a
-> [(Int,b)]
-> Vector v m a
unsafeAccum f (Vector v) us = Vector (VG.unsafeAccum f v us)
unsafeAccumulate :: (VG.Vector v a, VG.Vector v (Int, b))
=> (a -> b -> a)
-> Vector v m a
-> Vector v n (Int,b)
-> Vector v m a
unsafeAccumulate f (Vector v) (Vector us) = Vector (VG.unsafeAccumulate f v us)
unsafeAccumulate_ :: (VG.Vector v a, VG.Vector v Int, VG.Vector v b)
=> (a -> b -> a)
-> Vector v m a
-> Vector v n Int
-> Vector v n b
-> Vector v m a
unsafeAccumulate_ f (Vector v) (Vector is) (Vector xs) = Vector (VG.unsafeAccumulate_ f v is xs)
reverse :: (VG.Vector v a) => Vector v n a -> Vector v n a
reverse (Vector v) = Vector (VG.reverse v)
backpermute :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
backpermute (Vector v) (Vector is) = Vector (VG.backpermute v is)
unsafeBackpermute :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
unsafeBackpermute (Vector v) (Vector is) = Vector (VG.unsafeBackpermute v is)
indexed :: (VG.Vector v a, VG.Vector v (Int,a))
=> Vector v n a -> Vector v n (Int,a)
indexed (Vector v) = Vector (VG.indexed v)
map :: (VG.Vector v a, VG.Vector v b)
=> (a -> b) -> Vector v n a -> Vector v n b
map f (Vector v) = Vector (VG.map f v)
imap :: (VG.Vector v a, VG.Vector v b)
=> (Int -> a -> b) -> Vector v n a -> Vector v n b
imap f (Vector v) = Vector (VG.imap f v)
concatMap :: (VG.Vector v a, VG.Vector v b)
=> (a -> Vector v m b) -> Vector v n a -> Vector v (n*m) b
concatMap f (Vector v) = Vector (VG.concatMap (fromSized . f) v)
mapM :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (a -> m b) -> Vector v n a -> m (Vector v n b)
mapM f (Vector v) = Vector <$> VG.mapM f v
imapM :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (Int -> a -> m b) -> Vector v n a -> m (Vector v n b)
imapM f (Vector v) = Vector <$> (VG.imapM f v)
mapM_ :: (Monad m, VG.Vector v a) => (a -> m b) -> Vector v n a -> m ()
mapM_ f (Vector v) = VG.mapM_ f v
imapM_ :: (Monad m, VG.Vector v a) => (Int -> a -> m b) -> Vector v n a -> m ()
imapM_ f (Vector v) = VG.imapM_ f v
forM :: (Monad m, VG.Vector v a, VG.Vector v b)
=> Vector v n a -> (a -> m b) -> m (Vector v n b)
forM (Vector v) f = Vector <$> VG.forM v f
forM_ :: (Monad m, VG.Vector v a) => Vector v n a -> (a -> m b) -> m ()
forM_ (Vector v) = VG.forM_ v
zipWith :: (VG.Vector v a, VG.Vector v b, VG.Vector v c)
=> (a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith f (Vector as) (Vector bs) = Vector (VG.zipWith f as bs)
zipWith3 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v d)
=> (a -> b -> c -> d) -> Vector v n a -> Vector v n b -> Vector v n c -> Vector v n d
zipWith3 f (Vector as) (Vector bs) (Vector cs) = Vector (VG.zipWith3 f as bs cs)
zipWith4 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e)
=> (a -> b -> c -> d -> e)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
zipWith4 f (Vector as) (Vector bs) (Vector cs) (Vector ds)
= Vector (VG.zipWith4 f as bs cs ds)
zipWith5 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v f)
=> (a -> b -> c -> d -> e -> f)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n f
zipWith5 f (Vector as) (Vector bs) (Vector cs) (Vector ds) (Vector es)
= Vector (VG.zipWith5 f as bs cs ds es)
zipWith6 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v f,VG.Vector v g)
=> (a -> b -> c -> d -> e -> f -> g)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n f
-> Vector v n g
zipWith6 f (Vector as) (Vector bs) (Vector cs) (Vector ds) (Vector es) (Vector fs)
= Vector (VG.zipWith6 f as bs cs ds es fs)
izipWith :: (VG.Vector v a,VG.Vector v b,VG.Vector v c)
=> (Int -> a -> b -> c)
-> Vector v n a
-> Vector v n b
-> Vector v n c
izipWith f (Vector xs) (Vector ys)
= Vector (VG.izipWith f xs ys)
izipWith3 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d)
=> (Int -> a -> b -> c -> d)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
izipWith3 f (Vector as) (Vector bs) (Vector cs)
= Vector (VG.izipWith3 f as bs cs)
izipWith4 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e)
=> (Int -> a -> b -> c -> d -> e)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
izipWith4 f (Vector as) (Vector bs) (Vector cs) (Vector ds)
= Vector (VG.izipWith4 f as bs cs ds)
izipWith5 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v f)
=> (Int -> a -> b -> c -> d -> e -> f)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n f
izipWith5 f (Vector as) (Vector bs) (Vector cs) (Vector ds) (Vector es)
= Vector (VG.izipWith5 f as bs cs ds es)
izipWith6 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v f,VG.Vector v g)
=> (Int -> a -> b -> c -> d -> e -> f -> g)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n f
-> Vector v n g
izipWith6 f (Vector as) (Vector bs) (Vector cs) (Vector ds) (Vector es) (Vector fs)
= Vector (VG.izipWith6 f as bs cs ds es fs)
zip :: (VG.Vector v a, VG.Vector v b, VG.Vector v (a,b))
=> Vector v n a -> Vector v n b -> Vector v n (a, b)
zip = zipWith (,)
zip3 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v (a, b, c))
=> Vector v n a -> Vector v n b -> Vector v n c -> Vector v n (a, b, c)
zip3 = zipWith3 (,,)
zip4 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v (a,b,c,d))
=> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n (a,b,c,d)
zip4 = zipWith4 (,,,)
zip5 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v (a,b,c,d,e))
=> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n (a,b,c,d,e)
zip5 = zipWith5 (,,,,)
zip6 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e,VG.Vector v f,VG.Vector v (a,b,c,d,e,f))
=> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n e
-> Vector v n f
-> Vector v n (a,b,c,d,e,f)
zip6 = zipWith6 (,,,,,)
zipWithM :: (Monad m, VG.Vector v a, VG.Vector v b, VG.Vector v c)
=> (a -> b -> m c) -> Vector v n a -> Vector v n b -> m (Vector v n c)
zipWithM f (Vector as) (Vector bs) = Vector <$> VG.zipWithM f as bs
izipWithM :: (Monad m, VG.Vector v a, VG.Vector v b, VG.Vector v c)
=> (Int -> a -> b -> m c) -> Vector v n a -> Vector v n b -> m (Vector v n c)
izipWithM m (Vector as) (Vector bs) = Vector <$> VG.izipWithM m as bs
zipWithM_ :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (a -> b -> m c) -> Vector v n a -> Vector v n b -> m ()
zipWithM_ f (Vector as) (Vector bs) = VG.zipWithM_ f as bs
izipWithM_ :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (Int -> a -> b -> m c) -> Vector v n a -> Vector v n b -> m ()
izipWithM_ m (Vector as) (Vector bs) = VG.izipWithM_ m as bs
unzip :: (VG.Vector v a, VG.Vector v b, VG.Vector v (a,b))
=> Vector v n (a, b) -> (Vector v n a, Vector v n b)
unzip xs = (map fst xs, map snd xs)
unzip3 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v (a, b, c))
=> Vector v n (a, b, c) -> (Vector v n a, Vector v n b, Vector v n c)
unzip3 xs = (map (\(a, _, _) -> a) xs,
map (\(_, b, _) -> b) xs,
map (\(_, _, c) -> c) xs)
unzip4 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v d,
VG.Vector v (a, b, c, d))
=> Vector v n (a, b, c, d) -> (Vector v n a, Vector v n b, Vector v n c, Vector v n d)
unzip4 xs = (map (\(a, _, _, _) -> a) xs,
map (\(_, b, _, _) -> b) xs,
map (\(_, _, c, _) -> c) xs,
map (\(_, _, _, d) -> d) xs)
unzip5 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v d, VG.Vector v e,
VG.Vector v (a, b, c, d, e))
=> Vector v n (a, b, c, d, e) -> (Vector v n a, Vector v n b, Vector v n c, Vector v n d, Vector v n e)
unzip5 xs = (map (\(a, _, _, _, _) -> a) xs,
map (\(_, b, _, _, _) -> b) xs,
map (\(_, _, c, _, _) -> c) xs,
map (\(_, _, _, d, _) -> d) xs,
map (\(_, _, _, _, e) -> e) xs)
unzip6 :: (VG.Vector v a, VG.Vector v b, VG.Vector v c, VG.Vector v d, VG.Vector v e,
VG.Vector v f, VG.Vector v (a, b, c, d, e, f))
=> Vector v n (a, b, c, d, e, f) -> (Vector v n a, Vector v n b, Vector v n c, Vector v n d, Vector v n e, Vector v n f)
unzip6 xs = (map (\(a, _, _, _, _, _) -> a) xs,
map (\(_, b, _, _, _, _) -> b) xs,
map (\(_, _, c, _, _, _) -> c) xs,
map (\(_, _, _, d, _, _) -> d) xs,
map (\(_, _, _, _, e, _) -> e) xs,
map (\(_, _, _, _, _, f) -> f) xs)
infix 4 `elem`
elem :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Bool
elem x (Vector v) = VG.elem x v
infix 4 `notElem`
notElem :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Bool
notElem x (Vector v) = VG.notElem x v
find :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Maybe a
find f (Vector v) = VG.find f v
findIndex :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Maybe Int
findIndex f (Vector v) = VG.findIndex f v
elemIndex :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Maybe Int
elemIndex x (Vector v) = VG.elemIndex x v
foldl :: VG.Vector v b => (a -> b -> a) -> a -> Vector v n b -> a
foldl f z = VG.foldl f z . fromSized
foldl1 :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> a
foldl1 f = VG.foldl1 f . fromSized
foldl' :: VG.Vector v b => (a -> b -> a) -> a -> Vector v n b -> a
foldl' f z = VG.foldl' f z . fromSized
foldl1' :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> a
foldl1' f = VG.foldl1' f . fromSized
foldr :: VG.Vector v a => (a -> b -> b) -> b -> Vector v n a -> b
foldr f z = VG.foldr f z . fromSized
foldr1 :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> a
foldr1 f = VG.foldr1 f . fromSized
foldr' :: VG.Vector v a => (a -> b -> b) -> b -> Vector v n a -> b
foldr' f z = VG.foldr' f z . fromSized
foldr1' :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> a
foldr1' f = VG.foldr1' f . fromSized
ifoldl :: VG.Vector v b => (a -> Int -> b -> a) -> a -> Vector v n b -> a
ifoldl f z = VG.ifoldl f z . fromSized
ifoldl' :: VG.Vector v b => (a -> Int -> b -> a) -> a -> Vector v n b -> a
ifoldl' f z = VG.ifoldl' f z . fromSized
ifoldr :: VG.Vector v a => (Int -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr f z = VG.ifoldr f z . fromSized
ifoldr' :: VG.Vector v a => (Int -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr' f z = VG.ifoldr' f z . fromSized
all :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Bool
all f = VG.all f . fromSized
any :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Bool
any f = VG.any f . fromSized
and :: VG.Vector v Bool => Vector v n Bool -> Bool
and = VG.and . fromSized
or :: VG.Vector v Bool => Vector v n Bool -> Bool
or = VG.or . fromSized
sum :: (VG.Vector v a, Num a) => Vector v n a -> a
sum = VG.sum . fromSized
product :: (VG.Vector v a, Num a) => Vector v n a -> a
product = VG.product . fromSized
maximum :: (VG.Vector v a, Ord a, KnownNat n) => Vector v (n+1) a -> a
maximum = VG.maximum . fromSized
maximumBy :: (VG.Vector v a, KnownNat n)
=> (a -> a -> Ordering) -> Vector v (n+1) a -> a
maximumBy cmpr = VG.maximumBy cmpr . fromSized
minimum :: (VG.Vector v a, Ord a, KnownNat n) => Vector v (n+1) a -> a
minimum = VG.minimum . fromSized
minimumBy :: (VG.Vector v a, KnownNat n)
=> (a -> a -> Ordering) -> Vector v (n+1) a -> a
minimumBy cmpr = VG.minimumBy cmpr . fromSized
maxIndex :: (VG.Vector v a, Ord a, KnownNat n) => Vector v (n+1) a -> Int
maxIndex = VG.maxIndex . fromSized
maxIndexBy :: (VG.Vector v a, KnownNat n)
=> (a -> a -> Ordering) -> Vector v (n+1) a -> Int
maxIndexBy cmpr = VG.maxIndexBy cmpr . fromSized
minIndex :: (VG.Vector v a, Ord a, KnownNat n) => Vector v (n+1) a -> Int
minIndex = VG.minIndex . fromSized
minIndexBy :: (VG.Vector v a, KnownNat n)
=> (a -> a -> Ordering) -> Vector v (n+1) a -> Int
minIndexBy cmpr = VG.minIndexBy cmpr . fromSized
foldM :: (Monad m, VG.Vector v b) => (a -> b -> m a) -> a -> Vector v n b -> m a
foldM m z = VG.foldM m z . fromSized
ifoldM :: (Monad m, VG.Vector v b) => (a -> Int -> b -> m a) -> a -> Vector v n b -> m a
ifoldM m z = VG.ifoldM m z . fromSized
fold1M :: (Monad m, VG.Vector v a, KnownNat n)
=> (a -> a -> m a) -> Vector v (n+1) a -> m a
fold1M m = VG.fold1M m . fromSized
foldM' :: (Monad m, VG.Vector v b) => (a -> b -> m a) -> a -> Vector v n b -> m a
foldM' m z = VG.foldM' m z . fromSized
ifoldM' :: (Monad m, VG.Vector v b)
=> (a -> Int -> b -> m a) -> a -> Vector v n b -> m a
ifoldM' m z = VG.ifoldM' m z . fromSized
fold1M' :: (Monad m, VG.Vector v a, KnownNat n)
=> (a -> a -> m a) -> Vector v (n+1) a -> m a
fold1M' m = VG.fold1M' m . fromSized
foldM_ :: (Monad m, VG.Vector v b)
=> (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM_ m z = VG.foldM_ m z . fromSized
ifoldM_ :: (Monad m, VG.Vector v b)
=> (a -> Int -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM_ m z = VG.ifoldM_ m z . fromSized
fold1M_ :: (Monad m, VG.Vector v a, KnownNat n)
=> (a -> a -> m a) -> Vector v (n+1) a -> m ()
fold1M_ m = VG.fold1M_ m . fromSized
foldM'_ :: (Monad m, VG.Vector v b)
=> (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM'_ m z = VG.foldM'_ m z . fromSized
ifoldM'_ :: (Monad m, VG.Vector v b)
=> (a -> Int -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM'_ m z = VG.ifoldM'_ m z . fromSized
fold1M'_ :: (Monad m, VG.Vector v a, KnownNat n)
=> (a -> a -> m a) -> Vector v (n+1) a -> m ()
fold1M'_ m = VG.fold1M'_ m . fromSized
sequence :: (Monad m, VG.Vector v a, VG.Vector v (m a))
=> Vector v n (m a) -> m (Vector v n a)
sequence (Vector v) = Vector <$> VG.sequence v
sequence_ :: (Monad m, VG.Vector v (m a)) => Vector v n (m a) -> m ()
sequence_ (Vector v) = VG.sequence_ v
prescanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl f z = withVectorUnsafe (VG.prescanl f z )
prescanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl' f z = withVectorUnsafe (VG.prescanl' f z )
postscanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl f z = withVectorUnsafe (VG.postscanl f z )
postscanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl' f z = withVectorUnsafe (VG.postscanl' f z )
scanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
scanl f z = withVectorUnsafe (VG.scanl f z )
scanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
scanl' f z = withVectorUnsafe (VG.scanl' f z )
scanl1 :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+1) a
scanl1 f = withVectorUnsafe (VG.scanl1 f )
scanl1' :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+1) a
scanl1' f = withVectorUnsafe (VG.scanl1' f )
prescanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr f z = withVectorUnsafe (VG.prescanr f z )
prescanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr' f z = withVectorUnsafe (VG.prescanr' f z )
postscanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr f z = withVectorUnsafe (VG.postscanr f z )
postscanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr' f z = withVectorUnsafe (VG.postscanr' f z )
scanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
scanr f z = withVectorUnsafe (VG.scanr f z )
scanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
scanr' f z = withVectorUnsafe (VG.scanr' f z )
scanr1 :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+1) a
scanr1 f = withVectorUnsafe (VG.scanr1 f )
scanr1' :: (VG.Vector v a, KnownNat n) => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+1) a
scanr1' f = withVectorUnsafe (VG.scanr1' f )
toList :: VG.Vector v a => Vector v n a -> [a]
toList = VG.toList . fromSized
fromList :: (VG.Vector v a, KnownNat n) => [a] -> Maybe (Vector v n a)
fromList = toSized . VG.fromList
fromListN :: forall v n a. (VG.Vector v a, KnownNat n)
=> [a] -> Maybe (Vector v n a)
fromListN = toSized . VG.fromListN i
where i = fromInteger (natVal (Proxy :: Proxy n))
fromListN' :: forall v n a. (VG.Vector v a, KnownNat n)
=> Proxy n -> [a] -> Maybe (Vector v n a)
fromListN' _ = fromListN
convert :: (VG.Vector v a, VG.Vector w a) => Vector v n a -> Vector w n a
convert = withVectorUnsafe VG.convert
toSized :: forall v n a. (VG.Vector v a, KnownNat n)
=> v a -> Maybe (Vector v n a)
toSized v
| n' == fromIntegral (VG.length v) = Just (Vector v)
| otherwise = Nothing
where n' = natVal (Proxy :: Proxy n)
fromSized :: Vector v n a -> v a
fromSized (Vector v) = v
withVectorUnsafe :: forall a b v w (n :: Nat). (VG.Vector v a, VG.Vector w b)
=> (v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe f (Vector v) = Vector (f v)