{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
#if MIN_VERSION_base(4,12,0)
{-# LANGUAGE NoStarIsType #-}
#endif
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.Vector.Generic.Sized
( Vector(SomeSized)
, MVector
, length
, length'
, knownLength
, knownLength'
, index
, index'
, unsafeIndex
, head
, last
, indexM
, indexM'
, unsafeIndexM
, headM
, lastM
, slice
, slice'
, init
, tail
, take
, take'
, drop
, drop'
, splitAt
, splitAt'
, empty
, singleton
, fromTuple
, 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
, ix
, ix'
, _head
, _last
, 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'
, withSizedList
, convert
, freeze
, thaw
, copy
, unsafeFreeze
, unsafeThaw
, toSized
, withSized
, fromSized
, withVectorUnsafe
, zipVectorsUnsafe
) where
import Data.Vector.Generic.Sized.Internal
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Vector as Boxed
import qualified Data.Vector.Storable as Storable
import qualified Data.Vector.Unboxed as Unboxed
import qualified Data.Vector.Generic.Mutable.Sized as SVGM
import Data.Vector.Generic.Mutable.Sized.Internal
import Data.Binary
import Data.Bits
import Data.Bifunctor
import Data.Foldable (for_)
import Data.Coerce
import Data.Finite hiding (shift)
import Data.Finite.Internal
import Data.Proxy
import qualified Control.Exception as Exception
import Control.Monad (mzero)
import Control.Monad.Primitive
import Control.Monad.ST
import Foreign.Storable
import Data.Data
import Control.Comonad
import Foreign.Ptr (castPtr)
import Data.Semigroup
import Text.Read.Lex
import Text.ParserCombinators.ReadPrec
import GHC.Read
import GHC.TypeLits
import Unsafe.Coerce
import qualified Data.Functor.Rep as Rep
import Data.Distributive
import Prelude
hiding (length, replicate, (++), head, last, init, tail, take,
drop, splitAt, reverse, map, concatMap, zipWith, zipWith3, zip,
zip3, unzip, unzip3, elem, notElem, foldl, foldl1, foldr, foldr1,
all, any, and, or, sum, product, maximum, minimum, scanl, scanl1,
scanr, scanr1, mapM, mapM_, sequence, sequence_)
import Data.IndexedListLiterals hiding (toList, fromList)
import Data.Hashable (Hashable(..))
import qualified Data.IndexedListLiterals as ILL
import Data.Vector.Unboxed (Unbox)
instance (KnownNat n, VG.Vector v a, Read (v a)) => Read (Vector v n a) where
readPrec :: ReadPrec (Vector v n a)
readPrec = ReadPrec (Vector v n a) -> ReadPrec (Vector v n a)
forall a. ReadPrec a -> ReadPrec a
parens (ReadPrec (Vector v n a) -> ReadPrec (Vector v n a))
-> ReadPrec (Vector v n a) -> ReadPrec (Vector v n a)
forall a b. (a -> b) -> a -> b
$ Int -> ReadPrec (Vector v n a) -> ReadPrec (Vector v n a)
forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
10 (ReadPrec (Vector v n a) -> ReadPrec (Vector v n a))
-> ReadPrec (Vector v n a) -> ReadPrec (Vector v n a)
forall a b. (a -> b) -> a -> b
$ do
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Ident String
"Vector")
v a
vec <- ReadPrec (v a)
forall a. Read a => ReadPrec a
readPrec
if v a -> Int
forall (v :: Type -> Type) a. Vector v a => v a -> Int
VG.length v a
vec Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n)) then Vector v n a -> ReadPrec (Vector v n a)
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Vector v n a -> ReadPrec (Vector v n a))
-> Vector v n a -> ReadPrec (Vector v n a)
forall a b. (a -> b) -> a -> b
$ v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
vec else ReadPrec (Vector v n a)
forall a. ReadPrec a
pfail
type instance VG.Mutable (Vector v n) = MVector (VG.Mutable v) n
instance (KnownNat n, Storable a, VG.Vector v a)
=> Storable (Vector v n a) where
sizeOf :: Vector v n a -> Int
sizeOf Vector v n a
_ = a -> Int
forall a. Storable a => a -> Int
sizeOf (a
forall a. HasCallStack => a
undefined :: a) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
alignment :: Vector v n a -> Int
alignment Vector v n a
_ = a -> Int
forall a. Storable a => a -> Int
alignment (a
forall a. HasCallStack => a
undefined :: a)
peek :: Ptr (Vector v n a) -> IO (Vector v n a)
peek Ptr (Vector v n a)
ptr = (Finite n -> IO a) -> IO (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) (m :: Type -> Type) a.
(KnownNat n, Vector v a, Monad m) =>
(Finite n -> m a) -> m (Vector v n a)
generateM (Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff (Ptr (Vector v n a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Vector v n a)
ptr) (Int -> IO a) -> (Finite n -> Int) -> Finite n -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finite n -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
poke :: Ptr (Vector v n a) -> Vector v n a -> IO ()
poke Ptr (Vector v n a)
ptr = (Finite n -> a -> IO ()) -> Vector v n a -> IO ()
forall (m :: Type -> Type) (v :: Type -> Type) a (n :: Nat) b.
(Monad m, Vector v a) =>
(Finite n -> a -> m b) -> Vector v n a -> m ()
imapM_ (Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff (Ptr (Vector v n a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Vector v n a)
ptr) (Int -> a -> IO ()) -> (Finite n -> Int) -> Finite n -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finite n -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
instance KnownNat n => Applicative (Vector Boxed.Vector n) where
pure :: a -> Vector Vector n a
pure = a -> Vector Vector n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate
<*> :: Vector Vector n (a -> b) -> Vector Vector n a -> Vector Vector n b
(<*>) = ((a -> b) -> a -> b)
-> Vector Vector n (a -> b)
-> Vector Vector n a
-> Vector Vector n b
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
($)
*> :: Vector Vector n a -> Vector Vector n b -> Vector Vector n b
(*>) = Vector Vector n a -> Vector Vector n b -> Vector Vector n b
seq
<* :: Vector Vector n a -> Vector Vector n b -> Vector Vector n a
(<*) = (Vector Vector n b -> Vector Vector n a -> Vector Vector n a)
-> Vector Vector n a -> Vector Vector n b -> Vector Vector n a
forall a b c. (a -> b -> c) -> b -> a -> c
flip Vector Vector n b -> Vector Vector n a -> Vector Vector n a
seq
instance KnownNat n => Monad (Vector Boxed.Vector n) where
return :: a -> Vector Vector n a
return = a -> Vector Vector n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate
Vector Vector n a
xs >>= :: Vector Vector n a -> (a -> Vector Vector n b) -> Vector Vector n b
>>= a -> Vector Vector n b
f = (Finite n -> a -> b) -> Vector Vector n a -> Vector Vector n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(Finite n -> a -> b) -> Vector v n a -> Vector v n b
imap (\Finite n
i a
x -> a -> Vector Vector n b
f a
x Vector Vector n b -> Finite n -> b
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v n a -> Finite n -> a
`index` Finite n
i) Vector Vector n a
xs
>> :: Vector Vector n a -> Vector Vector n b -> Vector Vector n b
(>>) = Vector Vector n a -> Vector Vector n b -> Vector Vector n b
seq
instance (KnownNat n, n ~ (1 + m)) => Comonad (Vector Boxed.Vector n) where
extract :: Vector Vector n a -> a
extract = Vector Vector n a -> a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v (1 + n) a -> a
head
extend :: (Vector Vector n a -> b) -> Vector Vector n a -> Vector Vector n b
extend Vector Vector n a -> b
f r :: Vector Vector n a
r@(Vector Vector a
v) = Vector b -> Vector Vector n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Vector b -> Vector Vector n b) -> Vector b -> Vector Vector n b
forall a b. (a -> b) -> a -> b
$ Int -> (Int -> b) -> Vector b
forall (v :: Type -> Type) a.
Vector v a =>
Int -> (Int -> a) -> v a
VG.generate Int
l (\Int
i -> Vector Vector n a -> b
f (Vector a -> Vector Vector n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> Int -> Vector a -> Vector a
forall (v :: Type -> Type) a.
Vector v a =>
Int -> Int -> v a -> v a
VG.slice Int
i Int
l Vector a
v')))
where
v' :: Vector a
v' = Vector a
v Vector a -> Vector a -> Vector a
forall (v :: Type -> Type) a. Vector v a => v a -> v a -> v a
VG.++ Vector a -> Vector a
forall (v :: Type -> Type) a. Vector v a => v a -> v a
VG.init Vector a
v
l :: Int
l = Vector Vector n a -> Int
forall (v :: Type -> Type) (n :: Nat) a.
KnownNat n =>
Vector v n a -> Int
length Vector Vector n a
r
instance (KnownNat n, n ~ (1 + m)) => ComonadApply (Vector Boxed.Vector n) where
<@> :: Vector Vector n (a -> b) -> Vector Vector n a -> Vector Vector n b
(<@>) = Vector Vector n (a -> b) -> Vector Vector n a -> Vector Vector n b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
(<*>)
<@ :: Vector Vector n a -> Vector Vector n b -> Vector Vector n a
(<@) = Vector Vector n a -> Vector Vector n b -> Vector Vector n a
forall (f :: Type -> Type) a b. Applicative f => f a -> f b -> f a
(<*)
@> :: Vector Vector n a -> Vector Vector n b -> Vector Vector n b
(@>) = Vector Vector n a -> Vector Vector n b -> Vector Vector n b
forall (f :: Type -> Type) a b. Applicative f => f a -> f b -> f b
(*>)
instance (Semigroup g, VG.Vector v g) => Semigroup (Vector v n g) where
<> :: Vector v n g -> Vector v n g -> Vector v n g
(<>) = (g -> g -> g) -> Vector v n g -> Vector v n g -> Vector v n g
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith g -> g -> g
forall a. Semigroup a => a -> a -> a
(<>)
stimes :: b -> Vector v n g -> Vector v n g
stimes = (g -> g) -> Vector v n g -> Vector v n g
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map ((g -> g) -> Vector v n g -> Vector v n g)
-> (b -> g -> g) -> b -> Vector v n g -> Vector v n g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> g -> g
forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes
instance (Monoid m, VG.Vector v m, KnownNat n) => Monoid (Vector v n m) where
mempty :: Vector v n m
mempty = m -> Vector v n m
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate m
forall a. Monoid a => a
mempty
#if MIN_VERSION_base(4,11,0)
#else
mappend = zipWith mappend
#endif
mconcat :: [Vector v n m] -> Vector v n m
mconcat [Vector v n m]
vs = (Finite n -> m) -> Vector v n m
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
(Finite n -> a) -> Vector v n a
generate ((Finite n -> m) -> Vector v n m)
-> (Finite n -> m) -> Vector v n m
forall a b. (a -> b) -> a -> b
$ [m] -> m
forall a. Monoid a => [a] -> a
mconcat ([m] -> m) -> (Finite n -> [m]) -> Finite n -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Vector v n m -> m) -> [Vector v n m] -> [m])
-> [Vector v n m] -> (Vector v n m -> m) -> [m]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Vector v n m -> m) -> [Vector v n m] -> [m]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap [Vector v n m]
vs ((Vector v n m -> m) -> [m])
-> (Finite n -> Vector v n m -> m) -> Finite n -> [m]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector v n m -> Finite n -> m) -> Finite n -> Vector v n m -> m
forall a b c. (a -> b -> c) -> b -> a -> c
flip Vector v n m -> Finite n -> m
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v n a -> Finite n -> a
index
instance KnownNat n => Distributive (Vector Boxed.Vector n) where
distribute :: f (Vector Vector n a) -> Vector Vector n (f a)
distribute = f (Vector Vector n a) -> Vector Vector n (f a)
forall (f :: Type -> Type) (w :: Type -> Type) a.
(Representable f, Functor w) =>
w (f a) -> f (w a)
Rep.distributeRep
{-# inline distribute #-}
instance KnownNat n => Rep.Representable (Vector Boxed.Vector n) where
type Rep (Vector Boxed.Vector n) = Finite n
tabulate :: (Rep (Vector Vector n) -> a) -> Vector Vector n a
tabulate = (Rep (Vector Vector n) -> a) -> Vector Vector n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
(Finite n -> a) -> Vector v n a
generate
{-# inline tabulate #-}
index :: Vector Vector n a -> Rep (Vector Vector n) -> a
index = Vector Vector n a -> Rep (Vector Vector n) -> a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v n a -> Finite n -> a
Data.Vector.Generic.Sized.index
{-# inline index #-}
instance (Eq a, Hashable a) => Hashable (Vector Boxed.Vector n a) where
{-# INLINE hashWithSalt #-}
hashWithSalt :: Int -> Vector Vector n a -> Int
hashWithSalt Int
salt = Int -> [a] -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt ([a] -> Int)
-> (Vector Vector n a -> [a]) -> Vector Vector n a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector Vector n a -> [a]
forall (v :: Type -> Type) a (n :: Nat).
Vector v a =>
Vector v n a -> [a]
toList
instance (Eq a, Hashable a, Storable a) => Hashable (Vector Storable.Vector n a) where
{-# INLINE hashWithSalt #-}
hashWithSalt :: Int -> Vector Vector n a -> Int
hashWithSalt Int
salt = Int -> [a] -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt ([a] -> Int)
-> (Vector Vector n a -> [a]) -> Vector Vector n a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector Vector n a -> [a]
forall (v :: Type -> Type) a (n :: Nat).
Vector v a =>
Vector v n a -> [a]
toList
instance (Eq a, Hashable a, Unbox a) => Hashable (Vector Unboxed.Vector n a) where
{-# INLINE hashWithSalt #-}
hashWithSalt :: Int -> Vector Vector n a -> Int
hashWithSalt Int
salt = Int -> [a] -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt ([a] -> Int)
-> (Vector Vector n a -> [a]) -> Vector Vector n a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector Vector n a -> [a]
forall (v :: Type -> Type) a (n :: Nat).
Vector v a =>
Vector v n a -> [a]
toList
length :: forall v n a. KnownNat n
=> Vector v n a -> Int
length :: Vector v n a -> Int
length Vector v n a
_ = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline length #-}
length' :: forall v n a.
Vector v n a -> Proxy n
length' :: Vector v n a -> Proxy n
length' Vector v n a
_ = Proxy n
forall k (t :: k). Proxy t
Proxy
{-# inline length' #-}
knownLength :: forall v n a r. VG.Vector v a
=> Vector v n a
-> (KnownNat n => r)
-> r
knownLength :: Vector v n a -> (KnownNat n => r) -> r
knownLength Vector v n a
v KnownNat n => r
x = Vector v n a -> (KnownNat n => Proxy n -> r) -> r
forall (v :: Type -> Type) (n :: Nat) a r.
Vector v a =>
Vector v n a -> (KnownNat n => Proxy n -> r) -> r
knownLength' Vector v n a
v ((KnownNat n => Proxy n -> r) -> r)
-> (KnownNat n => Proxy n -> r) -> r
forall a b. (a -> b) -> a -> b
$ r -> Proxy n -> r
forall a b. a -> b -> a
const r
KnownNat n => r
x
knownLength' :: forall v n a r. VG.Vector v a
=> Vector v n a
-> (KnownNat n => Proxy n -> r)
-> r
knownLength' :: Vector v n a -> (KnownNat n => Proxy n -> r) -> r
knownLength' (Vector v a
v) KnownNat n => Proxy n -> r
x = case Integer -> Maybe SomeNat
someNatVal (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (v a -> Int
forall (v :: Type -> Type) a. Vector v a => v a -> Int
VG.length v a
v)) of
Just (SomeNat (Proxy n
Proxy :: Proxy n')) -> case (Any :~: Any) -> n :~: n
forall a b. a -> b
unsafeCoerce Any :~: Any
forall k (a :: k). a :~: a
Refl :: n' :~: n of n :~: n
Refl -> KnownNat n => Proxy n -> r
Proxy n -> r
x Proxy n
forall k (t :: k). Proxy t
Proxy
Maybe SomeNat
Nothing -> String -> r
forall a. HasCallStack => String -> a
error String
"impossible: Vector has negative length"
index :: forall v n a. VG.Vector v a
=> Vector v n a -> Finite n -> a
index :: Vector v n a -> Finite n -> a
index (Vector v a
v) (Finite Integer
i) = v a
v v a -> Int -> a
forall (v :: Type -> Type) a. Vector v a => v a -> Int -> a
`VG.unsafeIndex` Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
i
{-# inline index #-}
index' :: forall v n m a p. (KnownNat n, VG.Vector v a)
=> Vector v (n+m+1) a -> p n -> a
index' :: Vector v ((n + m) + 1) a -> p n -> a
index' (Vector v a
v) p n
p = v a
v v a -> Int -> a
forall (v :: Type -> Type) a. Vector v a => v a -> Int -> a
`VG.unsafeIndex` Int
i
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (p n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal p n
p)
{-# inline index' #-}
unsafeIndex :: forall v n a. VG.Vector v a
=> Vector v n a -> Int -> a
unsafeIndex :: Vector v n a -> Int -> a
unsafeIndex (Vector v a
v) Int
i = v a
v v a -> Int -> a
forall (v :: Type -> Type) a. Vector v a => v a -> Int -> a
`VG.unsafeIndex` Int
i
{-# inline unsafeIndex #-}
head :: forall v n a. VG.Vector v a
=> Vector v (1+n) a -> a
head :: Vector v (1 + n) a -> a
head (Vector v a
v) = v a -> a
forall (v :: Type -> Type) a. Vector v a => v a -> a
VG.unsafeHead v a
v
{-# inline head #-}
last :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> a
last :: Vector v (n + 1) a -> a
last (Vector v a
v) = v a -> a
forall (v :: Type -> Type) a. Vector v a => v a -> a
VG.unsafeLast v a
v
{-# inline last #-}
ix :: forall v n a f. (VG.Vector v a, Functor f)
=> Finite n -> (a -> f a) -> Vector v n a -> f (Vector v n a)
ix :: Finite n -> (a -> f a) -> Vector v n a -> f (Vector v n a)
ix Finite n
n a -> f a
f Vector v n a
vector = (\a
x -> Vector v n a
vector Vector v n a -> [(Finite n, a)] -> Vector v n a
forall (v :: Type -> Type) a (m :: Nat).
Vector v a =>
Vector v m a -> [(Finite m, a)] -> Vector v m a
// [(Finite n
n, a
x)]) (a -> Vector v n a) -> f a -> f (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f (Vector v n a -> Finite n -> a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v n a -> Finite n -> a
index Vector v n a
vector Finite n
n)
{-# inline ix #-}
ix' :: forall i v n a f. (VG.Vector v a, Functor f,
KnownNat i, KnownNat n, i+1 <= n)
=> (a -> f a) -> Vector v n a -> f (Vector v n a)
ix' :: (a -> f a) -> Vector v n a -> f (Vector v n a)
ix' = Finite n -> (a -> f a) -> Vector v n a -> f (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) a (f :: Type -> Type).
(Vector v a, Functor f) =>
Finite n -> (a -> f a) -> Vector v n a -> f (Vector v n a)
ix (Proxy i -> Finite n
forall (n :: Nat) (m :: Nat) (proxy :: Nat -> Type).
(KnownNat n, KnownNat m, (n + 1) <= m) =>
proxy n -> Finite m
natToFinite (Proxy i
forall k (t :: k). Proxy t
Proxy::Proxy i))
{-# inline ix' #-}
_head :: forall v n a f. (VG.Vector v a, Functor f)
=> (a -> f a) -> Vector v (1+n) a -> f (Vector v (1+n) a)
_head :: (a -> f a) -> Vector v (1 + n) a -> f (Vector v (1 + n) a)
_head a -> f a
f Vector v (1 + n) a
vector = (\a
x -> a -> Vector v n a -> Vector v (1 + n) a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
a -> Vector v n a -> Vector v (1 + n) a
cons a
x (Vector v n a -> Vector v (1 + n) a)
-> Vector v n a -> Vector v (1 + n) a
forall a b. (a -> b) -> a -> b
$ Vector v (1 + n) a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v (1 + n) a -> Vector v n a
tail Vector v (1 + n) a
vector) (a -> Vector v (1 + n) a) -> f a -> f (Vector v (1 + n) a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f (Vector v (1 + n) a -> a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v (1 + n) a -> a
head Vector v (1 + n) a
vector)
{-# inline _head #-}
_last :: forall v n a f. (VG.Vector v a, Functor f)
=> (a -> f a) -> Vector v (n+1) a -> f (Vector v (n+1) a)
_last :: (a -> f a) -> Vector v (n + 1) a -> f (Vector v (n + 1) a)
_last a -> f a
f Vector v (n + 1) a
vector = Vector v n a -> a -> Vector v (n + 1) a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v n a -> a -> Vector v (n + 1) a
snoc (Vector v (n + 1) a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v (n + 1) a -> Vector v n a
init Vector v (n + 1) a
vector) (a -> Vector v (n + 1) a) -> f a -> f (Vector v (n + 1) a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f (Vector v (n + 1) a -> a
forall (v :: Type -> Type) (n :: Nat) a.
Vector v a =>
Vector v (n + 1) a -> a
last Vector v (n + 1) a
vector)
{-# inline _last #-}
indexM :: forall v n a m. (VG.Vector v a, Monad m)
=> Vector v n a -> Finite n -> m a
indexM :: Vector v n a -> Finite n -> m a
indexM (Vector v a
v) (Finite Integer
i) = v a
v v a -> Int -> m a
forall (v :: Type -> Type) a (m :: Type -> Type).
(Vector v a, Monad m) =>
v a -> Int -> m a
`VG.indexM` Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
i
{-# inline indexM #-}
indexM' :: forall v n k a m p. (KnownNat n, VG.Vector v a, Monad m)
=> Vector v (n+k) a -> p n -> m a
indexM' :: Vector v (n + k) a -> p n -> m a
indexM' (Vector v a
v) p n
p = v a
v v a -> Int -> m a
forall (v :: Type -> Type) a (m :: Type -> Type).
(Vector v a, Monad m) =>
v a -> Int -> m a
`VG.indexM` Int
i
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (p n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal p n
p)
{-# inline indexM' #-}
unsafeIndexM :: forall v n a m. (VG.Vector v a, Monad m)
=> Vector v n a -> Int -> m a
unsafeIndexM :: Vector v n a -> Int -> m a
unsafeIndexM (Vector v a
v) Int
i = v a
v v a -> Int -> m a
forall (v :: Type -> Type) a (m :: Type -> Type).
(Vector v a, Monad m) =>
v a -> Int -> m a
`VG.unsafeIndexM` Int
i
{-# inline unsafeIndexM #-}
headM :: forall v n a m. (VG.Vector v a, Monad m)
=> Vector v (1+n) a -> m a
headM :: Vector v (1 + n) a -> m a
headM (Vector v a
v) = v a -> m a
forall (v :: Type -> Type) a (m :: Type -> Type).
(Vector v a, Monad m) =>
v a -> m a
VG.unsafeHeadM v a
v
{-# inline headM #-}
lastM :: forall v n a m. (VG.Vector v a, Monad m)
=> Vector v (n+1) a -> m a
lastM :: Vector v (n + 1) a -> m a
lastM (Vector v a
v) = v a -> m a
forall (v :: Type -> Type) a (m :: Type -> Type).
(Vector v a, Monad m) =>
v a -> m a
VG.unsafeLastM v a
v
{-# inline lastM #-}
slice :: forall v i n m a p. (KnownNat i, KnownNat n, VG.Vector v a)
=> p i
-> Vector v (i+n+m) a
-> Vector v n a
slice :: p i -> Vector v ((i + n) + m) a -> Vector v n a
slice p i
start (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> Int -> v a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
Int -> Int -> v a -> v a
VG.unsafeSlice Int
i Int
n v a
v)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (p i -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal p i
start)
n :: Int
n = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline slice #-}
slice' :: forall v i n m a p
. (KnownNat i, KnownNat n, VG.Vector v a)
=> p i
-> p n
-> Vector v (i+n+m) a
-> Vector v n a
slice' :: p i -> p n -> Vector v ((i + n) + m) a -> Vector v n a
slice' p i
start p n
_ = p i -> Vector v ((i + n) + m) a -> Vector v n a
forall (v :: Type -> Type) (i :: Nat) (n :: Nat) (m :: Nat) a
(p :: Nat -> Type).
(KnownNat i, KnownNat n, Vector v a) =>
p i -> Vector v ((i + n) + m) a -> Vector v n a
slice p i
start
{-# inline slice' #-}
init :: forall v n a. (VG.Vector v a)
=> Vector v (n+1) a -> Vector v n a
init :: Vector v (n + 1) a -> Vector v n a
init (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> v a
VG.unsafeInit v a
v)
{-# inline init #-}
tail :: forall v n a. (VG.Vector v a)
=> Vector v (1+n) a -> Vector v n a
tail :: Vector v (1 + n) a -> Vector v n a
tail (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> v a
VG.unsafeTail v a
v)
{-# inline tail #-}
take :: forall v n m a. (KnownNat n, VG.Vector v a)
=> Vector v (n+m) a -> Vector v n a
take :: Vector v (n + m) a -> Vector v n a
take (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> v a -> v a
VG.unsafeTake Int
i v a
v)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline take #-}
take' :: forall v n m a p. (KnownNat n, VG.Vector v a)
=> p n -> Vector v (n+m) a -> Vector v n a
take' :: p n -> Vector v (n + m) a -> Vector v n a
take' p n
_ = Vector v (n + m) a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) (m :: Nat) a.
(KnownNat n, Vector v a) =>
Vector v (n + m) a -> Vector v n a
take
{-# inline take' #-}
drop :: forall v n m a. (KnownNat n, VG.Vector v a)
=> Vector v (n+m) a -> Vector v m a
drop :: Vector v (n + m) a -> Vector v m a
drop (Vector v a
v) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> v a -> v a
VG.unsafeDrop Int
i v a
v)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline drop #-}
drop' :: forall v n m a p. (KnownNat n, VG.Vector v a)
=> p n -> Vector v (n+m) a -> Vector v m a
drop' :: p n -> Vector v (n + m) a -> Vector v m a
drop' p n
_ = Vector v (n + m) a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) (m :: Nat) a.
(KnownNat n, Vector v a) =>
Vector v (n + m) a -> Vector v m a
drop
{-# inline drop' #-}
splitAt :: forall v n m a. (KnownNat n, VG.Vector v a)
=> Vector v (n+m) a -> (Vector v n a, Vector v m a)
splitAt :: Vector v (n + m) a -> (Vector v n a, Vector v m a)
splitAt (Vector v a
v) = (v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
a, v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
b)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
(v a
a, v a
b) = Int -> v a -> (v a, v a)
forall (v :: Type -> Type) a.
Vector v a =>
Int -> v a -> (v a, v a)
VG.splitAt Int
i v a
v
{-# inline splitAt #-}
splitAt' :: forall v n m a p. (KnownNat n, VG.Vector v a)
=> p n -> Vector v (n+m) a -> (Vector v n a, Vector v m a)
splitAt' :: p n -> Vector v (n + m) a -> (Vector v n a, Vector v m a)
splitAt' p n
_ = Vector v (n + m) a -> (Vector v n a, Vector v m a)
forall (v :: Type -> Type) (n :: Nat) (m :: Nat) a.
(KnownNat n, Vector v a) =>
Vector v (n + m) a -> (Vector v n a, Vector v m a)
splitAt
{-# inline splitAt' #-}
empty :: forall v a. (VG.Vector v a)
=> Vector v 0 a
empty :: Vector v 0 a
empty = v a -> Vector v 0 a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
forall (v :: Type -> Type) a. Vector v a => v a
VG.empty
{-# inline empty #-}
singleton :: forall v a. (VG.Vector v a)
=> a -> Vector v 1 a
singleton :: a -> Vector v 1 a
singleton a
a = v a -> Vector v 1 a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (a -> v a
forall (v :: Type -> Type) a. Vector v a => a -> v a
VG.singleton a
a)
{-# inline singleton #-}
fromTuple :: forall v a input length.
(VG.Vector v a, IndexedListLiterals input length a, KnownNat length)
=> input -> Vector v length a
fromTuple :: input -> Vector v length a
fromTuple = v a -> Vector v length a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v length a)
-> (input -> v a) -> input -> Vector v length a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [a] -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> [a] -> v a
VG.fromListN (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Int) -> Integer -> Int
forall a b. (a -> b) -> a -> b
$ Proxy length -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy length -> Integer) -> Proxy length -> Integer
forall a b. (a -> b) -> a -> b
$ Proxy length
forall k (t :: k). Proxy t
Proxy @length) ([a] -> v a) -> (input -> [a]) -> input -> v a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. input -> [a]
forall input (length :: Nat) output.
IndexedListLiterals input length output =>
input -> [output]
ILL.toList
replicate :: forall v n a. (KnownNat n, VG.Vector v a)
=> a -> Vector v n a
replicate :: a -> Vector v n a
replicate a
a = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> a -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> a -> v a
VG.replicate Int
i a
a)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline replicate #-}
replicate' :: forall v n a p. (KnownNat n, VG.Vector v a)
=> p n -> a -> Vector v n a
replicate' :: p n -> a -> Vector v n a
replicate' p n
_ = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate
{-# inline replicate' #-}
generate :: forall v n a. (KnownNat n, VG.Vector v a)
=> (Finite n -> a) -> Vector v n a
generate :: (Finite n -> a) -> Vector v n a
generate Finite n -> a
f = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> (Int -> a) -> v a
forall (v :: Type -> Type) a.
Vector v a =>
Int -> (Int -> a) -> v a
VG.generate Int
i (Finite n -> a
f (Finite n -> a) -> (Int -> Finite n) -> Int -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral))
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline generate #-}
generate' :: forall v n a p. (KnownNat n, VG.Vector v a)
=> p n -> (Finite n -> a) -> Vector v n a
generate' :: p n -> (Finite n -> a) -> Vector v n a
generate' p n
_ = (Finite n -> a) -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
(Finite n -> a) -> Vector v n a
generate
{-# inline generate' #-}
iterateN :: forall v n a. (KnownNat n, VG.Vector v a)
=> (a -> a) -> a -> Vector v n a
iterateN :: (a -> a) -> a -> Vector v n a
iterateN a -> a
f a
z = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> (a -> a) -> a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
Int -> (a -> a) -> a -> v a
VG.iterateN Int
i a -> a
f a
z)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline iterateN #-}
iterateN' :: forall v n a p. (KnownNat n, VG.Vector v a)
=> p n -> (a -> a) -> a -> Vector v n a
iterateN' :: p n -> (a -> a) -> a -> Vector v n a
iterateN' p n
_ = (a -> a) -> a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
(a -> a) -> a -> Vector v n a
iterateN
{-# inline iterateN' #-}
replicateM :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> m a -> m (Vector v n a)
replicateM :: m a -> m (Vector v n a)
replicateM m a
a = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> m (v a) -> m (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> m a -> m (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
Int -> m a -> m (v a)
VG.replicateM Int
i m a
a
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline replicateM #-}
replicateM' :: forall v n m a p. (KnownNat n, VG.Vector v a, Monad m)
=> p n -> m a -> m (Vector v n a)
replicateM' :: p n -> m a -> m (Vector v n a)
replicateM' p n
_ = m a -> m (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) (m :: Type -> Type) a.
(KnownNat n, Vector v a, Monad m) =>
m a -> m (Vector v n a)
replicateM
{-# inline replicateM' #-}
generateM :: forall v n m a. (KnownNat n, VG.Vector v a, Monad m)
=> (Finite n -> m a) -> m (Vector v n a)
generateM :: (Finite n -> m a) -> m (Vector v n a)
generateM Finite n -> m a
f = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> m (v a) -> m (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> (Int -> m a) -> m (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
Int -> (Int -> m a) -> m (v a)
VG.generateM Int
i (Finite n -> m a
f (Finite n -> m a) -> (Int -> Finite n) -> Int -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline generateM #-}
generateM' :: forall v n m a p. (KnownNat n, VG.Vector v a, Monad m)
=> p n -> (Finite n -> m a) -> m (Vector v n a)
generateM' :: p n -> (Finite n -> m a) -> m (Vector v n a)
generateM' p n
_ = (Finite n -> m a) -> m (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) (m :: Type -> Type) a.
(KnownNat n, Vector v a, Monad m) =>
(Finite n -> m a) -> m (Vector v n a)
generateM
{-# inline generateM' #-}
unfoldrN :: forall v n a b. (KnownNat n, VG.Vector v a)
=> (b -> (a, b)) -> b -> Vector v n a
unfoldrN :: (b -> (a, b)) -> b -> Vector v n a
unfoldrN b -> (a, b)
f b
z = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (Int -> (b -> Maybe (a, b)) -> b -> v a
forall (v :: Type -> Type) a b.
Vector v a =>
Int -> (b -> Maybe (a, b)) -> b -> v a
VG.unfoldrN Int
i ((a, b) -> Maybe (a, b)
forall a. a -> Maybe a
Just ((a, b) -> Maybe (a, b)) -> (b -> (a, b)) -> b -> Maybe (a, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> (a, b)
f) b
z)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline unfoldrN #-}
unfoldrN' :: forall v n a b p. (KnownNat n, VG.Vector v a)
=> p n -> (b -> (a, b)) -> b -> Vector v n a
unfoldrN' :: p n -> (b -> (a, b)) -> b -> Vector v n a
unfoldrN' p n
_ = (b -> (a, b)) -> b -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a b.
(KnownNat n, Vector v a) =>
(b -> (a, b)) -> b -> Vector v n a
unfoldrN
{-# inline unfoldrN' #-}
enumFromN :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> Vector v n a
enumFromN :: a -> Vector v n a
enumFromN a
a = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (a -> Int -> v a
forall (v :: Type -> Type) a.
(Vector v a, Num a) =>
a -> Int -> v a
VG.enumFromN a
a Int
i)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline enumFromN #-}
enumFromN' :: forall v n a p. (KnownNat n, VG.Vector v a, Num a)
=> a -> p n -> Vector v n a
enumFromN' :: a -> p n -> Vector v n a
enumFromN' a
a p n
_ = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a, Num a) =>
a -> Vector v n a
enumFromN a
a
{-# inline enumFromN' #-}
enumFromStepN :: forall v n a. (KnownNat n, VG.Vector v a, Num a)
=> a -> a -> Vector v n a
enumFromStepN :: a -> a -> Vector v n a
enumFromStepN a
a a
a' = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (a -> a -> Int -> v a
forall (v :: Type -> Type) a.
(Vector v a, Num a) =>
a -> a -> Int -> v a
VG.enumFromStepN a
a a
a' Int
i)
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline enumFromStepN #-}
enumFromStepN' :: forall v n a p. (KnownNat n, VG.Vector v a, Num a)
=> a -> a -> p n -> Vector v n a
enumFromStepN' :: a -> a -> p n -> Vector v n a
enumFromStepN' a
a a
a' p n
_ = a -> a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a, Num a) =>
a -> a -> Vector v n a
enumFromStepN a
a a
a'
{-# inline enumFromStepN' #-}
cons :: forall v n a. VG.Vector v a
=> a -> Vector v n a -> Vector v (1+n) a
cons :: a -> Vector v n a -> Vector v (1 + n) a
cons a
x (Vector v a
xs) = v a -> Vector v (1 + n) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (a -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => a -> v a -> v a
VG.cons a
x v a
xs)
{-# inline cons #-}
snoc :: forall v n a. VG.Vector v a
=> Vector v n a -> a -> Vector v (n+1) a
snoc :: Vector v n a -> a -> Vector v (n + 1) a
snoc (Vector v a
xs) a
x = v a -> Vector v (n + 1) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> a -> v a
VG.snoc v a
xs a
x)
{-# inline snoc #-}
(++) :: forall v n m a. VG.Vector v a
=> Vector v n a -> Vector v m a -> Vector v (n+m) a
Vector v a
vn ++ :: Vector v n a -> Vector v m a -> Vector v (n + m) a
++ Vector v a
vm = v a -> Vector v (n + m) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a
vn v a -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> v a -> v a
VG.++ v a
vm)
{-# inline (++) #-}
force :: VG.Vector v a => Vector v n a -> Vector v n a
force :: Vector v n a -> Vector v n a
force (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> v a
VG.force v a
v)
{-# inline force #-}
(//) :: VG.Vector v a
=> Vector v m a
-> [(Finite m, a)]
-> Vector v m a
Vector v a
v // :: Vector v m a -> [(Finite m, a)] -> Vector v m a
// [(Finite m, a)]
us = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a
v v a -> [(Int, a)] -> v a
forall (v :: Type -> Type) a.
Vector v a =>
v a -> [(Int, a)] -> v a
VG.// (((Finite m, a) -> (Int, a)) -> [(Finite m, a)] -> [(Int, a)]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Finite m, a) -> (Int, a)) -> [(Finite m, a)] -> [(Int, a)])
-> ((Finite m -> Int) -> (Finite m, a) -> (Int, a))
-> (Finite m -> Int)
-> [(Finite m, a)]
-> [(Int, a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Finite m -> Int) -> (Finite m, a) -> (Int, a)
forall (p :: Type -> Type -> Type) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first) (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Int) -> (Finite m -> Integer) -> Finite m -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finite m -> Integer
forall (n :: Nat). Finite n -> Integer
getFinite) [(Finite m, a)]
us)
{-# inline (//) #-}
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 m a -> Vector v n (Int, a) -> Vector v m a
update (Vector v a
v) (Vector v (Int, a)
w) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v (Int, a) -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v (Int, a)) =>
v a -> v (Int, a) -> v a
VG.update v a
v v (Int, a)
w)
{-# inline update #-}
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 m a -> Vector v n Int -> Vector v n a -> Vector v m a
update_ (Vector v a
v) (Vector v Int
is) (Vector v a
w) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v Int -> v a -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v Int) =>
v a -> v Int -> v a -> v a
VG.update_ v a
v v Int
is v a
w)
{-# inline update_ #-}
unsafeUpd :: (VG.Vector v a)
=> Vector v m a
-> [(Int, a)]
-> Vector v m a
unsafeUpd :: Vector v m a -> [(Int, a)] -> Vector v m a
unsafeUpd (Vector v a
v) [(Int, a)]
us = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> [(Int, a)] -> v a
forall (v :: Type -> Type) a.
Vector v a =>
v a -> [(Int, a)] -> v a
VG.unsafeUpd v a
v [(Int, a)]
us)
{-# inline unsafeUpd #-}
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 m a -> Vector v n (Int, a) -> Vector v m a
unsafeUpdate (Vector v a
v) (Vector v (Int, a)
w) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v (Int, a) -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v (Int, a)) =>
v a -> v (Int, a) -> v a
VG.unsafeUpdate v a
v v (Int, a)
w)
{-# inline unsafeUpdate #-}
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 m a -> Vector v n Int -> Vector v n a -> Vector v m a
unsafeUpdate_ (Vector v a
v) (Vector v Int
is) (Vector v a
w) =
v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v Int -> v a -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v Int) =>
v a -> v Int -> v a -> v a
VG.unsafeUpdate_ v a
v v Int
is v a
w)
{-# inline unsafeUpdate_ #-}
accum :: VG.Vector v a
=> (a -> b -> a)
-> Vector v m a
-> [(Finite m,b)]
-> Vector v m a
accum :: (a -> b -> a) -> Vector v m a -> [(Finite m, b)] -> Vector v m a
accum a -> b -> a
f (Vector v a
v) [(Finite m, b)]
us =
v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> [(Int, b)] -> v a
forall (v :: Type -> Type) a b.
Vector v a =>
(a -> b -> a) -> v a -> [(Int, b)] -> v a
VG.accum a -> b -> a
f v a
v ([(Int, b)] -> v a) -> [(Int, b)] -> v a
forall a b. (a -> b) -> a -> b
$ (((Finite m, b) -> (Int, b)) -> [(Finite m, b)] -> [(Int, b)]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Finite m, b) -> (Int, b)) -> [(Finite m, b)] -> [(Int, b)])
-> ((Finite m -> Int) -> (Finite m, b) -> (Int, b))
-> (Finite m -> Int)
-> [(Finite m, b)]
-> [(Int, b)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Finite m -> Int) -> (Finite m, b) -> (Int, b)
forall (p :: Type -> Type -> Type) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first) (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Int) -> (Finite m -> Integer) -> Finite m -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finite m -> Integer
forall (n :: Nat). Finite n -> Integer
getFinite) [(Finite m, b)]
us)
{-# inline accum #-}
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 :: (a -> b -> a)
-> Vector v m a -> Vector v n (Int, b) -> Vector v m a
accumulate a -> b -> a
f (Vector v a
v) (Vector v (Int, b)
us) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> v (Int, b) -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v (Int, b)) =>
(a -> b -> a) -> v a -> v (Int, b) -> v a
VG.accumulate a -> b -> a
f v a
v v (Int, b)
us)
{-# inline accumulate #-}
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_ :: (a -> b -> a)
-> Vector v m a -> Vector v n Int -> Vector v n b -> Vector v m a
accumulate_ a -> b -> a
f (Vector v a
v) (Vector v Int
is) (Vector v b
xs) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> v Int -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v Int, Vector v b) =>
(a -> b -> a) -> v a -> v Int -> v b -> v a
VG.accumulate_ a -> b -> a
f v a
v v Int
is v b
xs)
{-# inline accumulate_ #-}
unsafeAccum :: VG.Vector v a
=> (a -> b -> a)
-> Vector v m a
-> [(Int,b)]
-> Vector v m a
unsafeAccum :: (a -> b -> a) -> Vector v m a -> [(Int, b)] -> Vector v m a
unsafeAccum a -> b -> a
f (Vector v a
v) [(Int, b)]
us = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> [(Int, b)] -> v a
forall (v :: Type -> Type) a b.
Vector v a =>
(a -> b -> a) -> v a -> [(Int, b)] -> v a
VG.unsafeAccum a -> b -> a
f v a
v [(Int, b)]
us)
{-# inline unsafeAccum #-}
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 :: (a -> b -> a)
-> Vector v m a -> Vector v n (Int, b) -> Vector v m a
unsafeAccumulate a -> b -> a
f (Vector v a
v) (Vector v (Int, b)
us) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> v (Int, b) -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v (Int, b)) =>
(a -> b -> a) -> v a -> v (Int, b) -> v a
VG.unsafeAccumulate a -> b -> a
f v a
v v (Int, b)
us)
{-# inline unsafeAccumulate #-}
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_ :: (a -> b -> a)
-> Vector v m a -> Vector v n Int -> Vector v n b -> Vector v m a
unsafeAccumulate_ a -> b -> a
f (Vector v a
v) (Vector v Int
is) (Vector v b
xs) = v a -> Vector v m a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> v a -> v Int -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v Int, Vector v b) =>
(a -> b -> a) -> v a -> v Int -> v b -> v a
VG.unsafeAccumulate_ a -> b -> a
f v a
v v Int
is v b
xs)
{-# inline unsafeAccumulate_ #-}
reverse :: (VG.Vector v a) => Vector v n a -> Vector v n a
reverse :: Vector v n a -> Vector v n a
reverse (Vector v a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v a
forall (v :: Type -> Type) a. Vector v a => v a -> v a
VG.reverse v a
v)
{-# inline reverse #-}
backpermute :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
backpermute :: Vector v m a -> Vector v n Int -> Vector v n a
backpermute (Vector v a
v) (Vector v Int
is) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v Int -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v Int) =>
v a -> v Int -> v a
VG.backpermute v a
v v Int
is)
{-# inline backpermute #-}
unsafeBackpermute :: (VG.Vector v a, VG.Vector v Int)
=> Vector v m a
-> Vector v n Int
-> Vector v n a
unsafeBackpermute :: Vector v m a -> Vector v n Int -> Vector v n a
unsafeBackpermute (Vector v a
v) (Vector v Int
is) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> v Int -> v a
forall (v :: Type -> Type) a.
(Vector v a, Vector v Int) =>
v a -> v Int -> v a
VG.unsafeBackpermute v a
v v Int
is)
{-# inline unsafeBackpermute #-}
indexed :: (VG.Vector v a, VG.Vector v (Int, a), VG.Vector v (Finite n,a))
=> Vector v n a -> Vector v n (Finite n,a)
indexed :: Vector v n a -> Vector v n (Finite n, a)
indexed (Vector v a
v) = v (Finite n, a) -> Vector v n (Finite n, a)
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((((Int, a) -> (Finite n, a)) -> v (Int, a) -> v (Finite n, a)
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b) -> v a -> v b
VG.map (((Int, a) -> (Finite n, a)) -> v (Int, a) -> v (Finite n, a))
-> ((Int -> Finite n) -> (Int, a) -> (Finite n, a))
-> (Int -> Finite n)
-> v (Int, a)
-> v (Finite n, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Finite n) -> (Int, a) -> (Finite n, a)
forall (p :: Type -> Type -> Type) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first) (Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (v (Int, a) -> v (Finite n, a)) -> v (Int, a) -> v (Finite n, a)
forall a b. (a -> b) -> a -> b
$ v a -> v (Int, a)
forall (v :: Type -> Type) a.
(Vector v a, Vector v (Int, a)) =>
v a -> v (Int, a)
VG.indexed v a
v)
{-# inline indexed #-}
map :: (VG.Vector v a, VG.Vector v b)
=> (a -> b) -> Vector v n a -> Vector v n b
map :: (a -> b) -> Vector v n a -> Vector v n b
map a -> b
f (Vector v a
v) = v b -> Vector v n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b) -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b) -> v a -> v b
VG.map a -> b
f v a
v)
{-# inline map #-}
imap :: (VG.Vector v a, VG.Vector v b)
=> (Finite n -> a -> b) -> Vector v n a -> Vector v n b
imap :: (Finite n -> a -> b) -> Vector v n a -> Vector v n b
imap Finite n -> a -> b
f (Vector v a
v) = v b -> Vector v n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b) -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(Int -> a -> b) -> v a -> v b
VG.imap (Finite n -> a -> b
f (Finite n -> a -> b) -> (Int -> Finite n) -> Int -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
v)
{-# inline imap #-}
concatMap :: (VG.Vector v a, VG.Vector v' b)
=> (a -> Vector v' m b) -> Vector v n a -> Vector v' (n*m) b
concatMap :: (a -> Vector v' m b) -> Vector v n a -> Vector v' (n * m) b
concatMap a -> Vector v' m b
f (Vector v a
v) = v' b -> Vector v' (n * m) b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v' b -> Vector v' (n * m) b)
-> (v a -> v' b) -> v a -> Vector v' (n * m) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [v' b] -> v' b
forall (v :: Type -> Type) a. Vector v a => [v a] -> v a
VG.concat ([v' b] -> v' b) -> (v a -> [v' b]) -> v a -> v' b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> v' b) -> [a] -> [v' b]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap (Vector v' m b -> v' b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized (Vector v' m b -> v' b) -> (a -> Vector v' m b) -> a -> v' b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Vector v' m b
f) ([a] -> [v' b]) -> (v a -> [a]) -> v a -> [v' b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v a -> [a]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
VG.toList (v a -> Vector v' (n * m) b) -> v a -> Vector v' (n * m) b
forall a b. (a -> b) -> a -> b
$ v a
v
{-# inline concatMap #-}
mapM :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (a -> m b) -> Vector v n a -> m (Vector v n b)
mapM :: (a -> m b) -> Vector v n a -> m (Vector v n b)
mapM a -> m b
f (Vector v a
v) = v b -> Vector v n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v b -> Vector v n b) -> m (v b) -> m (Vector v n b)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> m b) -> v a -> m (v b)
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a, Vector v b) =>
(a -> m b) -> v a -> m (v b)
VG.mapM a -> m b
f v a
v
{-# inline mapM #-}
imapM :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (Finite n -> a -> m b) -> Vector v n a -> m (Vector v n b)
imapM :: (Finite n -> a -> m b) -> Vector v n a -> m (Vector v n b)
imapM Finite n -> a -> m b
f (Vector v a
v) = v b -> Vector v n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v b -> Vector v n b) -> m (v b) -> m (Vector v n b)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int -> a -> m b) -> v a -> m (v b)
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a, Vector v b) =>
(Int -> a -> m b) -> v a -> m (v b)
VG.imapM (Finite n -> a -> m b
f (Finite n -> a -> m b) -> (Int -> Finite n) -> Int -> a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
v
{-# inline imapM #-}
mapM_ :: (Monad m, VG.Vector v a) => (a -> m b) -> Vector v n a -> m ()
mapM_ :: (a -> m b) -> Vector v n a -> m ()
mapM_ a -> m b
f (Vector v a
v) = (a -> m b) -> v a -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a) =>
(a -> m b) -> v a -> m ()
VG.mapM_ a -> m b
f v a
v
{-# inline mapM_ #-}
imapM_ :: (Monad m, VG.Vector v a) => (Finite n -> a -> m b) -> Vector v n a -> m ()
imapM_ :: (Finite n -> a -> m b) -> Vector v n a -> m ()
imapM_ Finite n -> a -> m b
f (Vector v a
v) = (Int -> a -> m b) -> v a -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a) =>
(Int -> a -> m b) -> v a -> m ()
VG.imapM_ (Finite n -> a -> m b
f (Finite n -> a -> m b) -> (Int -> Finite n) -> Int -> a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
v
{-# inline imapM_ #-}
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 n a -> (a -> m b) -> m (Vector v n b)
forM (Vector v a
v) a -> m b
f = v b -> Vector v n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v b -> Vector v n b) -> m (v b) -> m (Vector v n b)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> v a -> (a -> m b) -> m (v b)
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a, Vector v b) =>
v a -> (a -> m b) -> m (v b)
VG.forM v a
v a -> m b
f
{-# inline forM #-}
forM_ :: (Monad m, VG.Vector v a) => Vector v n a -> (a -> m b) -> m ()
forM_ :: Vector v n a -> (a -> m b) -> m ()
forM_ (Vector v a
v) = v a -> (a -> m b) -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a b.
(Monad m, Vector v a) =>
v a -> (a -> m b) -> m ()
VG.forM_ v a
v
{-# inline forM_ #-}
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 :: (a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> b -> c
f (Vector v a
as) (Vector v b
bs) = v c -> Vector v n c
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> c) -> v a -> v b -> v c
forall (v :: Type -> Type) a b c.
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> v a -> v b -> v c
VG.zipWith a -> b -> c
f v a
as v b
bs)
{-# inline zipWith #-}
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 :: (a -> b -> c -> d)
-> Vector v n a -> Vector v n b -> Vector v n c -> Vector v n d
zipWith3 a -> b -> c -> d
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) = v d -> Vector v n d
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> c -> d) -> v a -> v b -> v c -> v d
forall (v :: Type -> Type) a b c d.
(Vector v a, Vector v b, Vector v c, Vector v d) =>
(a -> b -> c -> d) -> v a -> v b -> v c -> v d
VG.zipWith3 a -> b -> c -> d
f v a
as v b
bs v c
cs)
{-# inline zipWith3 #-}
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 :: (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 a -> b -> c -> d -> e
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds)
= v e -> Vector v n e
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
forall (v :: Type -> Type) a b c d e.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) =>
(a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
VG.zipWith4 a -> b -> c -> d -> e
f v a
as v b
bs v c
cs v d
ds)
{-# inline zipWith4 #-}
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 :: (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 a -> b -> c -> d -> e -> f
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds) (Vector v e
es)
= v f -> Vector v n f
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> c -> d -> e -> f)
-> v a -> v b -> v c -> v d -> v e -> v f
forall (v :: Type -> Type) a b c d e f.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
Vector v f) =>
(a -> b -> c -> d -> e -> f)
-> v a -> v b -> v c -> v d -> v e -> v f
VG.zipWith5 a -> b -> c -> d -> e -> f
f v a
as v b
bs v c
cs v d
ds v e
es)
{-# inline zipWith5 #-}
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 :: (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 a -> b -> c -> d -> e -> f -> g
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds) (Vector v e
es) (Vector v f
fs)
= v g -> Vector v n g
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> c -> d -> e -> f -> g)
-> v a -> v b -> v c -> v d -> v e -> v f -> v g
forall (v :: Type -> Type) a b c d e f g.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
Vector v f, Vector v g) =>
(a -> b -> c -> d -> e -> f -> g)
-> v a -> v b -> v c -> v d -> v e -> v f -> v g
VG.zipWith6 a -> b -> c -> d -> e -> f -> g
f v a
as v b
bs v c
cs v d
ds v e
es v f
fs)
{-# inline zipWith6 #-}
izipWith :: (VG.Vector v a,VG.Vector v b,VG.Vector v c)
=> (Finite n -> a -> b -> c)
-> Vector v n a
-> Vector v n b
-> Vector v n c
izipWith :: (Finite n -> a -> b -> c)
-> Vector v n a -> Vector v n b -> Vector v n c
izipWith Finite n -> a -> b -> c
f (Vector v a
xs) (Vector v b
ys)
= v c -> Vector v n c
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b -> c) -> v a -> v b -> v c
forall (v :: Type -> Type) a b c.
(Vector v a, Vector v b, Vector v c) =>
(Int -> a -> b -> c) -> v a -> v b -> v c
VG.izipWith (Finite n -> a -> b -> c
f (Finite n -> a -> b -> c)
-> (Int -> Finite n) -> Int -> a -> b -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
xs v b
ys)
{-# inline izipWith #-}
izipWith3 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d)
=> (Finite n -> a -> b -> c -> d)
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
izipWith3 :: (Finite n -> a -> b -> c -> d)
-> Vector v n a -> Vector v n b -> Vector v n c -> Vector v n d
izipWith3 Finite n -> a -> b -> c -> d
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs)
= v d -> Vector v n d
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d
forall (v :: Type -> Type) a b c d.
(Vector v a, Vector v b, Vector v c, Vector v d) =>
(Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d
VG.izipWith3 (Finite n -> a -> b -> c -> d
f (Finite n -> a -> b -> c -> d)
-> (Int -> Finite n) -> Int -> a -> b -> c -> d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs v c
cs)
{-# inline izipWith3 #-}
izipWith4 :: (VG.Vector v a,VG.Vector v b,VG.Vector v c,VG.Vector v d,VG.Vector v e)
=> (Finite 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
izipWith4 :: (Finite 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
izipWith4 Finite n -> a -> b -> c -> d -> e
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds)
= v e -> Vector v n e
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
forall (v :: Type -> Type) a b c d e.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) =>
(Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
VG.izipWith4 (Finite n -> a -> b -> c -> d -> e
f (Finite n -> a -> b -> c -> d -> e)
-> (Int -> Finite n) -> Int -> a -> b -> c -> d -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs v c
cs v d
ds)
{-# inline izipWith4 #-}
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)
=> (Finite 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
izipWith5 :: (Finite 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
izipWith5 Finite n -> a -> b -> c -> d -> e -> f
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds) (Vector v e
es)
= v f -> Vector v n f
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b -> c -> d -> e -> f)
-> v a -> v b -> v c -> v d -> v e -> v f
forall (v :: Type -> Type) a b c d e f.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
Vector v f) =>
(Int -> a -> b -> c -> d -> e -> f)
-> v a -> v b -> v c -> v d -> v e -> v f
VG.izipWith5 (Finite n -> a -> b -> c -> d -> e -> f
f (Finite n -> a -> b -> c -> d -> e -> f)
-> (Int -> Finite n) -> Int -> a -> b -> c -> d -> e -> f
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs v c
cs v d
ds v e
es)
{-# inline izipWith5 #-}
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)
=> (Finite n -> 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 :: (Finite n -> 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 Finite n -> a -> b -> c -> d -> e -> f -> g
f (Vector v a
as) (Vector v b
bs) (Vector v c
cs) (Vector v d
ds) (Vector v e
es) (Vector v f
fs)
= v g -> Vector v n g
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((Int -> a -> b -> c -> d -> e -> f -> g)
-> v a -> v b -> v c -> v d -> v e -> v f -> v g
forall (v :: Type -> Type) a b c d e f g.
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
Vector v f, Vector v g) =>
(Int -> a -> b -> c -> d -> e -> f -> g)
-> v a -> v b -> v c -> v d -> v e -> v f -> v g
VG.izipWith6 (Finite n -> a -> b -> c -> d -> e -> f -> g
f (Finite n -> a -> b -> c -> d -> e -> f -> g)
-> (Int -> Finite n) -> Int -> a -> b -> c -> d -> e -> f -> g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs v c
cs v d
ds v e
es v f
fs)
{-# inline izipWith6 #-}
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 :: Vector v n a -> Vector v n b -> Vector v n (a, b)
zip = (a -> b -> (a, b))
-> Vector v n a -> Vector v n b -> Vector v n (a, b)
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith (,)
{-# inline zip #-}
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 :: Vector v n a
-> Vector v n b -> Vector v n c -> Vector v n (a, b, c)
zip3 = (a -> b -> c -> (a, b, c))
-> Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n (a, b, c)
forall (v :: Type -> Type) a b c d (n :: Nat).
(Vector v a, Vector v b, Vector v c, Vector v d) =>
(a -> b -> c -> d)
-> Vector v n a -> Vector v n b -> Vector v n c -> Vector v n d
zipWith3 (,,)
{-# inline zip3 #-}
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 :: Vector v n a
-> Vector v n b
-> Vector v n c
-> Vector v n d
-> Vector v n (a, b, c, d)
zip4 = (a -> b -> c -> d -> (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)
forall (v :: Type -> Type) a b c d e (n :: Nat).
(Vector v a, Vector v b, Vector v c, Vector v d, 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 (,,,)
{-# inline zip4 #-}
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 :: 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 = (a -> b -> c -> d -> 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
-> Vector v n (a, b, c, d, e)
forall (v :: Type -> Type) a b c d e f (n :: Nat).
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
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 (,,,,)
{-# inline zip5 #-}
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 :: 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 = (a -> b -> c -> d -> e -> 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
-> Vector v n (a, b, c, d, e, f)
forall (v :: Type -> Type) a b c d e f g (n :: Nat).
(Vector v a, Vector v b, Vector v c, Vector v d, Vector v e,
Vector v f, 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 (,,,,,)
{-# inline zip6 #-}
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 :: (a -> b -> m c) -> Vector v n a -> Vector v n b -> m (Vector v n c)
zipWithM a -> b -> m c
f (Vector v a
as) (Vector v b
bs) = v c -> Vector v n c
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v c -> Vector v n c) -> m (v c) -> m (Vector v n c)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> b -> m c) -> v a -> v b -> m (v c)
forall (m :: Type -> Type) (v :: Type -> Type) a b c.
(Monad m, Vector v a, Vector v b, Vector v c) =>
(a -> b -> m c) -> v a -> v b -> m (v c)
VG.zipWithM a -> b -> m c
f v a
as v b
bs
{-# inline zipWithM #-}
izipWithM :: (Monad m, VG.Vector v a, VG.Vector v b, VG.Vector v c)
=> (Finite n -> a -> b -> m c) -> Vector v n a -> Vector v n b -> m (Vector v n c)
izipWithM :: (Finite n -> a -> b -> m c)
-> Vector v n a -> Vector v n b -> m (Vector v n c)
izipWithM Finite n -> a -> b -> m c
m (Vector v a
as) (Vector v b
bs) = v c -> Vector v n c
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v c -> Vector v n c) -> m (v c) -> m (Vector v n c)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int -> a -> b -> m c) -> v a -> v b -> m (v c)
forall (m :: Type -> Type) (v :: Type -> Type) a b c.
(Monad m, Vector v a, Vector v b, Vector v c) =>
(Int -> a -> b -> m c) -> v a -> v b -> m (v c)
VG.izipWithM (Finite n -> a -> b -> m c
m (Finite n -> a -> b -> m c)
-> (Int -> Finite n) -> Int -> a -> b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs
{-# inline izipWithM #-}
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_ :: (a -> b -> m c) -> Vector v n a -> Vector v n b -> m ()
zipWithM_ a -> b -> m c
f (Vector v a
as) (Vector v b
bs) = (a -> b -> m c) -> v a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a b c.
(Monad m, Vector v a, Vector v b) =>
(a -> b -> m c) -> v a -> v b -> m ()
VG.zipWithM_ a -> b -> m c
f v a
as v b
bs
{-# inline zipWithM_ #-}
izipWithM_ :: (Monad m, VG.Vector v a, VG.Vector v b)
=> (Finite n -> a -> b -> m c) -> Vector v n a -> Vector v n b -> m ()
izipWithM_ :: (Finite n -> a -> b -> m c) -> Vector v n a -> Vector v n b -> m ()
izipWithM_ Finite n -> a -> b -> m c
m (Vector v a
as) (Vector v b
bs) = (Int -> a -> b -> m c) -> v a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a b c.
(Monad m, Vector v a, Vector v b) =>
(Int -> a -> b -> m c) -> v a -> v b -> m ()
VG.izipWithM_ (Finite n -> a -> b -> m c
m (Finite n -> a -> b -> m c)
-> (Int -> Finite n) -> Int -> a -> b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) v a
as v b
bs
{-# inline izipWithM_ #-}
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 :: Vector v n (a, b) -> (Vector v n a, Vector v n b)
unzip Vector v n (a, b)
xs = (((a, b) -> a) -> Vector v n (a, b) -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (a, b) -> a
forall a b. (a, b) -> a
fst Vector v n (a, b)
xs, ((a, b) -> b) -> Vector v n (a, b) -> Vector v n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (a, b) -> b
forall a b. (a, b) -> b
snd Vector v n (a, b)
xs)
{-# inline unzip #-}
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 :: Vector v n (a, b, c) -> (Vector v n a, Vector v n b, Vector v n c)
unzip3 Vector v n (a, b, c)
xs = (((a, b, c) -> a) -> Vector v n (a, b, c) -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
a, b
_, c
_) -> a
a) Vector v n (a, b, c)
xs,
((a, b, c) -> b) -> Vector v n (a, b, c) -> Vector v n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
b, c
_) -> b
b) Vector v n (a, b, c)
xs,
((a, b, c) -> c) -> Vector v n (a, b, c) -> Vector v n c
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
c) -> c
c) Vector v n (a, b, c)
xs)
{-# inline unzip3 #-}
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 :: Vector v n (a, b, c, d)
-> (Vector v n a, Vector v n b, Vector v n c, Vector v n d)
unzip4 Vector v n (a, b, c, d)
xs = (((a, b, c, d) -> a) -> Vector v n (a, b, c, d) -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
a, b
_, c
_, d
_) -> a
a) Vector v n (a, b, c, d)
xs,
((a, b, c, d) -> b) -> Vector v n (a, b, c, d) -> Vector v n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
b, c
_, d
_) -> b
b) Vector v n (a, b, c, d)
xs,
((a, b, c, d) -> c) -> Vector v n (a, b, c, d) -> Vector v n c
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
c, d
_) -> c
c) Vector v n (a, b, c, d)
xs,
((a, b, c, d) -> d) -> Vector v n (a, b, c, d) -> Vector v n d
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
d) -> d
d) Vector v n (a, b, c, d)
xs)
{-# inline unzip4 #-}
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 :: 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 Vector v n (a, b, c, d, e)
xs = (((a, b, c, d, e) -> a)
-> Vector v n (a, b, c, d, e) -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
a, b
_, c
_, d
_, e
_) -> a
a) Vector v n (a, b, c, d, e)
xs,
((a, b, c, d, e) -> b)
-> Vector v n (a, b, c, d, e) -> Vector v n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
b, c
_, d
_, e
_) -> b
b) Vector v n (a, b, c, d, e)
xs,
((a, b, c, d, e) -> c)
-> Vector v n (a, b, c, d, e) -> Vector v n c
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
c, d
_, e
_) -> c
c) Vector v n (a, b, c, d, e)
xs,
((a, b, c, d, e) -> d)
-> Vector v n (a, b, c, d, e) -> Vector v n d
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
d, e
_) -> d
d) Vector v n (a, b, c, d, e)
xs,
((a, b, c, d, e) -> e)
-> Vector v n (a, b, c, d, e) -> Vector v n e
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
_, e
e) -> e
e) Vector v n (a, b, c, d, e)
xs)
{-# inline unzip5 #-}
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 :: 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 Vector v n (a, b, c, d, e, f)
xs = (((a, b, c, d, e, f) -> a)
-> Vector v n (a, b, c, d, e, f) -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
a, b
_, c
_, d
_, e
_, f
_) -> a
a) Vector v n (a, b, c, d, e, f)
xs,
((a, b, c, d, e, f) -> b)
-> Vector v n (a, b, c, d, e, f) -> Vector v n b
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
b, c
_, d
_, e
_, f
_) -> b
b) Vector v n (a, b, c, d, e, f)
xs,
((a, b, c, d, e, f) -> c)
-> Vector v n (a, b, c, d, e, f) -> Vector v n c
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
c, d
_, e
_, f
_) -> c
c) Vector v n (a, b, c, d, e, f)
xs,
((a, b, c, d, e, f) -> d)
-> Vector v n (a, b, c, d, e, f) -> Vector v n d
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
d, e
_, f
_) -> d
d) Vector v n (a, b, c, d, e, f)
xs,
((a, b, c, d, e, f) -> e)
-> Vector v n (a, b, c, d, e, f) -> Vector v n e
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
_, e
e, f
_) -> e
e) Vector v n (a, b, c, d, e, f)
xs,
((a, b, c, d, e, f) -> f)
-> Vector v n (a, b, c, d, e, f) -> Vector v n f
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map (\(a
_, b
_, c
_, d
_, e
_, f
f) -> f
f) Vector v n (a, b, c, d, e, f)
xs)
{-# inline unzip6 #-}
infix 4 `elem`
elem :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Bool
elem :: a -> Vector v n a -> Bool
elem a
x (Vector v a
v) = a -> v a -> Bool
forall (v :: Type -> Type) a.
(Vector v a, Eq a) =>
a -> v a -> Bool
VG.elem a
x v a
v
{-# inline elem #-}
infix 4 `notElem`
notElem :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Bool
notElem :: a -> Vector v n a -> Bool
notElem a
x (Vector v a
v) = a -> v a -> Bool
forall (v :: Type -> Type) a.
(Vector v a, Eq a) =>
a -> v a -> Bool
VG.notElem a
x v a
v
{-# inline notElem #-}
find :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Maybe a
find :: (a -> Bool) -> Vector v n a -> Maybe a
find a -> Bool
f (Vector v a
v) = (a -> Bool) -> v a -> Maybe a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> Bool) -> v a -> Maybe a
VG.find a -> Bool
f v a
v
{-# inline find #-}
findIndex :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Maybe (Finite n)
findIndex :: (a -> Bool) -> Vector v n a -> Maybe (Finite n)
findIndex a -> Bool
f (Vector v a
v) = Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Finite n) -> Maybe Int -> Maybe (Finite n)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> Bool) -> v a -> Maybe Int
forall (v :: Type -> Type) a.
Vector v a =>
(a -> Bool) -> v a -> Maybe Int
VG.findIndex a -> Bool
f v a
v
{-# inline findIndex #-}
elemIndex :: (VG.Vector v a, Eq a) => a -> Vector v n a -> Maybe (Finite n)
elemIndex :: a -> Vector v n a -> Maybe (Finite n)
elemIndex a
x (Vector v a
v) = Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Finite n) -> Maybe Int -> Maybe (Finite n)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> v a -> Maybe Int
forall (v :: Type -> Type) a.
(Vector v a, Eq a) =>
a -> v a -> Maybe Int
VG.elemIndex a
x v a
v
{-# inline elemIndex #-}
foldl :: VG.Vector v b => (a -> b -> a) -> a -> Vector v n b -> a
foldl :: (a -> b -> a) -> a -> Vector v n b -> a
foldl a -> b -> a
f a
z = (a -> b -> a) -> a -> v b -> a
forall (v :: Type -> Type) b a.
Vector v b =>
(a -> b -> a) -> a -> v b -> a
VG.foldl a -> b -> a
f a
z (v b -> a) -> (Vector v n b -> v b) -> Vector v n b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldl #-}
foldl1 :: VG.Vector v a => (a -> a -> a) -> Vector v (1+n) a -> a
foldl1 :: (a -> a -> a) -> Vector v (1 + n) a -> a
foldl1 a -> a -> a
f = (a -> a -> a) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> a
VG.foldl1 a -> a -> a
f (v a -> a)
-> (Vector v (1 + n) a -> v a) -> Vector v (1 + n) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (1 + n) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldl1 #-}
foldl' :: VG.Vector v b => (a -> b -> a) -> a -> Vector v n b -> a
foldl' :: (a -> b -> a) -> a -> Vector v n b -> a
foldl' a -> b -> a
f a
z = (a -> b -> a) -> a -> v b -> a
forall (v :: Type -> Type) b a.
Vector v b =>
(a -> b -> a) -> a -> v b -> a
VG.foldl' a -> b -> a
f a
z (v b -> a) -> (Vector v n b -> v b) -> Vector v n b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldl' #-}
foldl1' :: VG.Vector v a => (a -> a -> a) -> Vector v (1+n) a -> a
foldl1' :: (a -> a -> a) -> Vector v (1 + n) a -> a
foldl1' a -> a -> a
f = (a -> a -> a) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> a
VG.foldl1' a -> a -> a
f (v a -> a)
-> (Vector v (1 + n) a -> v a) -> Vector v (1 + n) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (1 + n) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldl1' #-}
foldr :: VG.Vector v a => (a -> b -> b) -> b -> Vector v n a -> b
foldr :: (a -> b -> b) -> b -> Vector v n a -> b
foldr a -> b -> b
f b
z = (a -> b -> b) -> b -> v a -> b
forall (v :: Type -> Type) a b.
Vector v a =>
(a -> b -> b) -> b -> v a -> b
VG.foldr a -> b -> b
f b
z (v a -> b) -> (Vector v n a -> v a) -> Vector v n a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldr #-}
foldr1 :: VG.Vector v a => (a -> a -> a) -> Vector v (n+1) a -> a
foldr1 :: (a -> a -> a) -> Vector v (n + 1) a -> a
foldr1 a -> a -> a
f = (a -> a -> a) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> a
VG.foldr1 a -> a -> a
f (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldr1 #-}
foldr' :: VG.Vector v a => (a -> b -> b) -> b -> Vector v n a -> b
foldr' :: (a -> b -> b) -> b -> Vector v n a -> b
foldr' a -> b -> b
f b
z = (a -> b -> b) -> b -> v a -> b
forall (v :: Type -> Type) a b.
Vector v a =>
(a -> b -> b) -> b -> v a -> b
VG.foldr' a -> b -> b
f b
z (v a -> b) -> (Vector v n a -> v a) -> Vector v n a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldr' #-}
foldr1' :: VG.Vector v a => (a -> a -> a) -> Vector v (n+1) a -> a
foldr1' :: (a -> a -> a) -> Vector v (n + 1) a -> a
foldr1' a -> a -> a
f = (a -> a -> a) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> a
VG.foldr1' a -> a -> a
f (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldr1' #-}
ifoldl :: VG.Vector v b => (a -> Finite n -> b -> a) -> a -> Vector v n b -> a
ifoldl :: (a -> Finite n -> b -> a) -> a -> Vector v n b -> a
ifoldl a -> Finite n -> b -> a
f a
z = (a -> Int -> b -> a) -> a -> v b -> a
forall (v :: Type -> Type) b a.
Vector v b =>
(a -> Int -> b -> a) -> a -> v b -> a
VG.ifoldl (\a
x -> a -> Finite n -> b -> a
f a
x (Finite n -> b -> a) -> (Int -> Finite n) -> Int -> b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> a) -> (Vector v n b -> v b) -> Vector v n b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldl #-}
ifoldl' :: VG.Vector v b => (a -> Finite n -> b -> a) -> a -> Vector v n b -> a
ifoldl' :: (a -> Finite n -> b -> a) -> a -> Vector v n b -> a
ifoldl' a -> Finite n -> b -> a
f a
z = (a -> Int -> b -> a) -> a -> v b -> a
forall (v :: Type -> Type) b a.
Vector v b =>
(a -> Int -> b -> a) -> a -> v b -> a
VG.ifoldl' (\a
x -> a -> Finite n -> b -> a
f a
x (Finite n -> b -> a) -> (Int -> Finite n) -> Int -> b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> a) -> (Vector v n b -> v b) -> Vector v n b -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldl' #-}
ifoldr :: VG.Vector v a => (Finite n -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr :: (Finite n -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr Finite n -> a -> b -> b
f b
z = (Int -> a -> b -> b) -> b -> v a -> b
forall (v :: Type -> Type) a b.
Vector v a =>
(Int -> a -> b -> b) -> b -> v a -> b
VG.ifoldr (Finite n -> a -> b -> b
f (Finite n -> a -> b -> b)
-> (Int -> Finite n) -> Int -> a -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) b
z (v a -> b) -> (Vector v n a -> v a) -> Vector v n a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldr #-}
ifoldr' :: VG.Vector v a => (Finite n -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr' :: (Finite n -> a -> b -> b) -> b -> Vector v n a -> b
ifoldr' Finite n -> a -> b -> b
f b
z = (Int -> a -> b -> b) -> b -> v a -> b
forall (v :: Type -> Type) a b.
Vector v a =>
(Int -> a -> b -> b) -> b -> v a -> b
VG.ifoldr' (Finite n -> a -> b -> b
f (Finite n -> a -> b -> b)
-> (Int -> Finite n) -> Int -> a -> b -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) b
z (v a -> b) -> (Vector v n a -> v a) -> Vector v n a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldr' #-}
all :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Bool
all :: (a -> Bool) -> Vector v n a -> Bool
all a -> Bool
f = (a -> Bool) -> v a -> Bool
forall (v :: Type -> Type) a.
Vector v a =>
(a -> Bool) -> v a -> Bool
VG.all a -> Bool
f (v a -> Bool) -> (Vector v n a -> v a) -> Vector v n a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline all #-}
any :: VG.Vector v a => (a -> Bool) -> Vector v n a -> Bool
any :: (a -> Bool) -> Vector v n a -> Bool
any a -> Bool
f = (a -> Bool) -> v a -> Bool
forall (v :: Type -> Type) a.
Vector v a =>
(a -> Bool) -> v a -> Bool
VG.any a -> Bool
f (v a -> Bool) -> (Vector v n a -> v a) -> Vector v n a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline any #-}
and :: VG.Vector v Bool => Vector v n Bool -> Bool
and :: Vector v n Bool -> Bool
and = v Bool -> Bool
forall (v :: Type -> Type). Vector v Bool => v Bool -> Bool
VG.and (v Bool -> Bool)
-> (Vector v n Bool -> v Bool) -> Vector v n Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n Bool -> v Bool
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline and #-}
or :: VG.Vector v Bool => Vector v n Bool -> Bool
or :: Vector v n Bool -> Bool
or = v Bool -> Bool
forall (v :: Type -> Type). Vector v Bool => v Bool -> Bool
VG.or (v Bool -> Bool)
-> (Vector v n Bool -> v Bool) -> Vector v n Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n Bool -> v Bool
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline or #-}
sum :: (VG.Vector v a, Num a) => Vector v n a -> a
sum :: Vector v n a -> a
sum = v a -> a
forall (v :: Type -> Type) a. (Vector v a, Num a) => v a -> a
VG.sum (v a -> a) -> (Vector v n a -> v a) -> Vector v n a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline sum #-}
product :: (VG.Vector v a, Num a) => Vector v n a -> a
product :: Vector v n a -> a
product = v a -> a
forall (v :: Type -> Type) a. (Vector v a, Num a) => v a -> a
VG.product (v a -> a) -> (Vector v n a -> v a) -> Vector v n a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline product #-}
maximum :: (VG.Vector v a, Ord a) => Vector v (n+1) a -> a
maximum :: Vector v (n + 1) a -> a
maximum = v a -> a
forall (v :: Type -> Type) a. (Vector v a, Ord a) => v a -> a
VG.maximum (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline maximum #-}
maximumBy :: VG.Vector v a
=> (a -> a -> Ordering) -> Vector v (n+1) a -> a
maximumBy :: (a -> a -> Ordering) -> Vector v (n + 1) a -> a
maximumBy a -> a -> Ordering
cmpr = (a -> a -> Ordering) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> Ordering) -> v a -> a
VG.maximumBy a -> a -> Ordering
cmpr (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline maximumBy #-}
minimum :: (VG.Vector v a, Ord a) => Vector v (n+1) a -> a
minimum :: Vector v (n + 1) a -> a
minimum = v a -> a
forall (v :: Type -> Type) a. (Vector v a, Ord a) => v a -> a
VG.minimum (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline minimum #-}
minimumBy :: VG.Vector v a
=> (a -> a -> Ordering) -> Vector v (n+1) a -> a
minimumBy :: (a -> a -> Ordering) -> Vector v (n + 1) a -> a
minimumBy a -> a -> Ordering
cmpr = (a -> a -> Ordering) -> v a -> a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> Ordering) -> v a -> a
VG.minimumBy a -> a -> Ordering
cmpr (v a -> a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline minimumBy #-}
maxIndex :: (VG.Vector v a, Ord a) => Vector v (n+1) a -> Finite (n+1)
maxIndex :: Vector v (n + 1) a -> Finite (n + 1)
maxIndex = Integer -> Finite (n + 1)
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite (n + 1))
-> (Vector v (n + 1) a -> Integer)
-> Vector v (n + 1) a
-> Finite (n + 1)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer)
-> (Vector v (n + 1) a -> Int) -> Vector v (n + 1) a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v a -> Int
forall (v :: Type -> Type) a. (Vector v a, Ord a) => v a -> Int
VG.maxIndex (v a -> Int)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline maxIndex #-}
maxIndexBy :: VG.Vector v a
=> (a -> a -> Ordering) -> Vector v (n+1) a -> Finite (n + 1)
maxIndexBy :: (a -> a -> Ordering) -> Vector v (n + 1) a -> Finite (n + 1)
maxIndexBy a -> a -> Ordering
cmpr = Integer -> Finite (n + 1)
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite (n + 1))
-> (Vector v (n + 1) a -> Integer)
-> Vector v (n + 1) a
-> Finite (n + 1)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer)
-> (Vector v (n + 1) a -> Int) -> Vector v (n + 1) a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Ordering) -> v a -> Int
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> Ordering) -> v a -> Int
VG.maxIndexBy a -> a -> Ordering
cmpr (v a -> Int)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline maxIndexBy #-}
minIndex :: (VG.Vector v a, Ord a) => Vector v (n+1) a -> Finite (n+1)
minIndex :: Vector v (n + 1) a -> Finite (n + 1)
minIndex = Integer -> Finite (n + 1)
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite (n + 1))
-> (Vector v (n + 1) a -> Integer)
-> Vector v (n + 1) a
-> Finite (n + 1)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer)
-> (Vector v (n + 1) a -> Int) -> Vector v (n + 1) a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v a -> Int
forall (v :: Type -> Type) a. (Vector v a, Ord a) => v a -> Int
VG.minIndex (v a -> Int)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline minIndex #-}
minIndexBy :: VG.Vector v a
=> (a -> a -> Ordering) -> Vector v (n+1) a -> Finite (n + 1)
minIndexBy :: (a -> a -> Ordering) -> Vector v (n + 1) a -> Finite (n + 1)
minIndexBy a -> a -> Ordering
cmpr = Integer -> Finite (n + 1)
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite (n + 1))
-> (Vector v (n + 1) a -> Integer)
-> Vector v (n + 1) a
-> Finite (n + 1)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer)
-> (Vector v (n + 1) a -> Int) -> Vector v (n + 1) a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Ordering) -> v a -> Int
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> Ordering) -> v a -> Int
VG.minIndexBy a -> a -> Ordering
cmpr (v a -> Int)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline minIndexBy #-}
foldM :: (Monad m, VG.Vector v b) => (a -> b -> m a) -> a -> Vector v n b -> m a
foldM :: (a -> b -> m a) -> a -> Vector v n b -> m a
foldM a -> b -> m a
m a
z = (a -> b -> m a) -> a -> v b -> m a
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> b -> m a) -> a -> v b -> m a
VG.foldM a -> b -> m a
m a
z (v b -> m a) -> (Vector v n b -> v b) -> Vector v n b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldM #-}
ifoldM :: (Monad m, VG.Vector v b) => (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m a
ifoldM :: (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m a
ifoldM a -> Finite n -> b -> m a
m a
z = (a -> Int -> b -> m a) -> a -> v b -> m a
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> Int -> b -> m a) -> a -> v b -> m a
VG.ifoldM (\a
x -> a -> Finite n -> b -> m a
m a
x (Finite n -> b -> m a) -> (Int -> Finite n) -> Int -> b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> m a) -> (Vector v n b -> v b) -> Vector v n b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldM #-}
fold1M :: (Monad m, VG.Vector v a)
=> (a -> a -> m a) -> Vector v (1+n) a -> m a
fold1M :: (a -> a -> m a) -> Vector v (1 + n) a -> m a
fold1M a -> a -> m a
m = (a -> a -> m a) -> v a -> m a
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
(a -> a -> m a) -> v a -> m a
VG.fold1M a -> a -> m a
m (v a -> m a)
-> (Vector v (1 + n) a -> v a) -> Vector v (1 + n) a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (1 + n) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline fold1M #-}
foldM' :: (Monad m, VG.Vector v b) => (a -> b -> m a) -> a -> Vector v n b -> m a
foldM' :: (a -> b -> m a) -> a -> Vector v n b -> m a
foldM' a -> b -> m a
m a
z = (a -> b -> m a) -> a -> v b -> m a
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> b -> m a) -> a -> v b -> m a
VG.foldM' a -> b -> m a
m a
z (v b -> m a) -> (Vector v n b -> v b) -> Vector v n b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldM' #-}
ifoldM' :: (Monad m, VG.Vector v b)
=> (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m a
ifoldM' :: (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m a
ifoldM' a -> Finite n -> b -> m a
m a
z = (a -> Int -> b -> m a) -> a -> v b -> m a
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> Int -> b -> m a) -> a -> v b -> m a
VG.ifoldM' (\a
x -> a -> Finite n -> b -> m a
m a
x (Finite n -> b -> m a) -> (Int -> Finite n) -> Int -> b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> m a) -> (Vector v n b -> v b) -> Vector v n b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldM' #-}
fold1M' :: (Monad m, VG.Vector v a)
=> (a -> a -> m a) -> Vector v (n+1) a -> m a
fold1M' :: (a -> a -> m a) -> Vector v (n + 1) a -> m a
fold1M' a -> a -> m a
m = (a -> a -> m a) -> v a -> m a
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
(a -> a -> m a) -> v a -> m a
VG.fold1M' a -> a -> m a
m (v a -> m a)
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline fold1M' #-}
foldM_ :: (Monad m, VG.Vector v b)
=> (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM_ :: (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM_ a -> b -> m a
m a
z = (a -> b -> m a) -> a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> b -> m a) -> a -> v b -> m ()
VG.foldM_ a -> b -> m a
m a
z (v b -> m ()) -> (Vector v n b -> v b) -> Vector v n b -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldM_ #-}
ifoldM_ :: (Monad m, VG.Vector v b)
=> (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM_ :: (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM_ a -> Finite n -> b -> m a
m a
z = (a -> Int -> b -> m a) -> a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> Int -> b -> m a) -> a -> v b -> m ()
VG.ifoldM_ (\a
x -> a -> Finite n -> b -> m a
m a
x (Finite n -> b -> m a) -> (Int -> Finite n) -> Int -> b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> m ()) -> (Vector v n b -> v b) -> Vector v n b -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldM_ #-}
fold1M_ :: (Monad m, VG.Vector v a)
=> (a -> a -> m a) -> Vector v (n+1) a -> m ()
fold1M_ :: (a -> a -> m a) -> Vector v (n + 1) a -> m ()
fold1M_ a -> a -> m a
m = (a -> a -> m a) -> v a -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
(a -> a -> m a) -> v a -> m ()
VG.fold1M_ a -> a -> m a
m (v a -> m ())
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline fold1M_ #-}
foldM'_ :: (Monad m, VG.Vector v b)
=> (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM'_ :: (a -> b -> m a) -> a -> Vector v n b -> m ()
foldM'_ a -> b -> m a
m a
z = (a -> b -> m a) -> a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> b -> m a) -> a -> v b -> m ()
VG.foldM'_ a -> b -> m a
m a
z (v b -> m ()) -> (Vector v n b -> v b) -> Vector v n b -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline foldM'_ #-}
ifoldM'_ :: (Monad m, VG.Vector v b)
=> (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM'_ :: (a -> Finite n -> b -> m a) -> a -> Vector v n b -> m ()
ifoldM'_ a -> Finite n -> b -> m a
m a
z = (a -> Int -> b -> m a) -> a -> v b -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) b a.
(Monad m, Vector v b) =>
(a -> Int -> b -> m a) -> a -> v b -> m ()
VG.ifoldM'_ (\a
x -> a -> Finite n -> b -> m a
m a
x (Finite n -> b -> m a) -> (Int -> Finite n) -> Int -> b -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Finite n
forall (n :: Nat). Integer -> Finite n
Finite (Integer -> Finite n) -> (Int -> Integer) -> Int -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral) a
z (v b -> m ()) -> (Vector v n b -> v b) -> Vector v n b -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n b -> v b
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline ifoldM'_ #-}
fold1M'_ :: (Monad m, VG.Vector v a)
=> (a -> a -> m a) -> Vector v (n+1) a -> m ()
fold1M'_ :: (a -> a -> m a) -> Vector v (n + 1) a -> m ()
fold1M'_ a -> a -> m a
m = (a -> a -> m a) -> v a -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a) =>
(a -> a -> m a) -> v a -> m ()
VG.fold1M'_ a -> a -> m a
m (v a -> m ())
-> (Vector v (n + 1) a -> v a) -> Vector v (n + 1) a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v (n + 1) a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline fold1M'_ #-}
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 n (m a) -> m (Vector v n a)
sequence (Vector v (m a)
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> m (v a) -> m (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> v (m a) -> m (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v a, Vector v (m a)) =>
v (m a) -> m (v a)
VG.sequence v (m a)
v
{-# inline sequence #-}
sequence_ :: (Monad m, VG.Vector v (m a)) => Vector v n (m a) -> m ()
sequence_ :: Vector v n (m a) -> m ()
sequence_ (Vector v (m a)
v) = v (m a) -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(Monad m, Vector v (m a)) =>
v (m a) -> m ()
VG.sequence_ v (m a)
v
{-# inline sequence_ #-}
prescanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl :: (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl a -> b -> a
f a
z = (v b -> v a) -> Vector v n b -> Vector v n a
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.prescanl a -> b -> a
f a
z )
{-# inline prescanl #-}
prescanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl' :: (a -> b -> a) -> a -> Vector v n b -> Vector v n a
prescanl' a -> b -> a
f a
z = (v b -> v a) -> Vector v n b -> Vector v n a
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.prescanl' a -> b -> a
f a
z )
{-# inline prescanl' #-}
postscanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl :: (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl a -> b -> a
f a
z = (v b -> v a) -> Vector v n b -> Vector v n a
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.postscanl a -> b -> a
f a
z )
{-# inline postscanl #-}
postscanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl' :: (a -> b -> a) -> a -> Vector v n b -> Vector v n a
postscanl' a -> b -> a
f a
z = (v b -> v a) -> Vector v n b -> Vector v n a
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.postscanl' a -> b -> a
f a
z )
{-# inline postscanl' #-}
scanl :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v (1+n) a
scanl :: (a -> b -> a) -> a -> Vector v n b -> Vector v (1 + n) a
scanl a -> b -> a
f a
z (Vector v b
v) = v a -> Vector v (1 + n) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.scanl a -> b -> a
f a
z v b
v)
{-# inline scanl #-}
scanl' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> a) -> a -> Vector v n b -> Vector v (1+n) a
scanl' :: (a -> b -> a) -> a -> Vector v n b -> Vector v (1 + n) a
scanl' a -> b -> a
f a
z (Vector v b
v) = v a -> Vector v (1 + n) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> a) -> a -> v b -> v a
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> a) -> a -> v b -> v a
VG.scanl' a -> b -> a
f a
z v b
v)
{-# inline scanl' #-}
scanl1 :: VG.Vector v a => (a -> a -> a) -> Vector v (1+n) a -> Vector v (2+n) a
scanl1 :: (a -> a -> a) -> Vector v (1 + n) a -> Vector v (2 + n) a
scanl1 a -> a -> a
f (Vector v a
v) = v a -> Vector v (2 + n) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> a -> a) -> v a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> v a
VG.scanl1 a -> a -> a
f v a
v)
{-# inline scanl1 #-}
scanl1' :: VG.Vector v a => (a -> a -> a) -> Vector v (1+n) a -> Vector v (2+n) a
scanl1' :: (a -> a -> a) -> Vector v (1 + n) a -> Vector v (2 + n) a
scanl1' a -> a -> a
f (Vector v a
v) = v a -> Vector v (2 + n) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> a -> a) -> v a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> v a
VG.scanl1' a -> a -> a
f v a
v)
{-# inline scanl1' #-}
prescanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr :: (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr a -> b -> b
f b
z = (v a -> v b) -> Vector v n a -> Vector v n b
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.prescanr a -> b -> b
f b
z )
{-# inline prescanr #-}
prescanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr' :: (a -> b -> b) -> b -> Vector v n a -> Vector v n b
prescanr' a -> b -> b
f b
z = (v a -> v b) -> Vector v n a -> Vector v n b
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.prescanr' a -> b -> b
f b
z )
{-# inline prescanr' #-}
postscanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr :: (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr a -> b -> b
f b
z = (v a -> v b) -> Vector v n a -> Vector v n b
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.postscanr a -> b -> b
f b
z )
{-# inline postscanr #-}
postscanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr' :: (a -> b -> b) -> b -> Vector v n a -> Vector v n b
postscanr' a -> b -> b
f b
z = (v a -> v b) -> Vector v n a -> Vector v n b
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.postscanr' a -> b -> b
f b
z )
{-# inline postscanr' #-}
scanr :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v (n+1) b
scanr :: (a -> b -> b) -> b -> Vector v n a -> Vector v (n + 1) b
scanr a -> b -> b
f b
z (Vector v a
v) = v b -> Vector v (n + 1) b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.scanr a -> b -> b
f b
z v a
v)
{-# inline scanr #-}
scanr' :: (VG.Vector v a, VG.Vector v b) => (a -> b -> b) -> b -> Vector v n a -> Vector v (n+1) b
scanr' :: (a -> b -> b) -> b -> Vector v n a -> Vector v (n + 1) b
scanr' a -> b -> b
f b
z (Vector v a
v) = v b -> Vector v (n + 1) b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> b -> b) -> b -> v a -> v b
forall (v :: Type -> Type) a b.
(Vector v a, Vector v b) =>
(a -> b -> b) -> b -> v a -> v b
VG.scanr' a -> b -> b
f b
z v a
v)
{-# inline scanr' #-}
scanr1 :: VG.Vector v a => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+2) a
scanr1 :: (a -> a -> a) -> Vector v (n + 1) a -> Vector v (n + 2) a
scanr1 a -> a -> a
f (Vector v a
v) = v a -> Vector v (n + 2) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> a -> a) -> v a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> v a
VG.scanr1 a -> a -> a
f v a
v)
{-# inline scanr1 #-}
scanr1' :: VG.Vector v a => (a -> a -> a) -> Vector v (n+1) a -> Vector v (n+2) a
scanr1' :: (a -> a -> a) -> Vector v (n + 1) a -> Vector v (n + 2) a
scanr1' a -> a -> a
f (Vector v a
v) = v a -> Vector v (n + 2) a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector ((a -> a -> a) -> v a -> v a
forall (v :: Type -> Type) a.
Vector v a =>
(a -> a -> a) -> v a -> v a
VG.scanr1' a -> a -> a
f v a
v)
{-# inline scanr1' #-}
toList :: VG.Vector v a => Vector v n a -> [a]
toList :: Vector v n a -> [a]
toList = v a -> [a]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
VG.toList (v a -> [a]) -> (Vector v n a -> v a) -> Vector v n a -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized
{-# inline toList #-}
fromList :: (VG.Vector v a, KnownNat n) => [a] -> Maybe (Vector v n a)
fromList :: [a] -> Maybe (Vector v n a)
fromList = v a -> Maybe (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) a.
(Vector v a, KnownNat n) =>
v a -> Maybe (Vector v n a)
toSized (v a -> Maybe (Vector v n a))
-> ([a] -> v a) -> [a] -> Maybe (Vector v n a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> v a
forall (v :: Type -> Type) a. Vector v a => [a] -> v a
VG.fromList
{-# inline fromList #-}
fromListN :: forall v n a. (VG.Vector v a, KnownNat n)
=> [a] -> Maybe (Vector v n a)
fromListN :: [a] -> Maybe (Vector v n a)
fromListN = v a -> Maybe (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) a.
(Vector v a, KnownNat n) =>
v a -> Maybe (Vector v n a)
toSized (v a -> Maybe (Vector v n a))
-> ([a] -> v a) -> [a] -> Maybe (Vector v n a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [a] -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> [a] -> v a
VG.fromListN Int
i
where i :: Int
i = Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n))
{-# inline fromListN #-}
fromListN' :: forall v n a p. (VG.Vector v a, KnownNat n)
=> p n -> [a] -> Maybe (Vector v n a)
fromListN' :: p n -> [a] -> Maybe (Vector v n a)
fromListN' p n
_ = [a] -> Maybe (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) a.
(Vector v a, KnownNat n) =>
[a] -> Maybe (Vector v n a)
fromListN
{-# inline fromListN' #-}
withSizedList :: forall v a r. VG.Vector v a
=> [a] -> (forall n. KnownNat n => Vector v n a -> r) -> r
withSizedList :: [a] -> (forall (n :: Nat). KnownNat n => Vector v n a -> r) -> r
withSizedList [a]
xs = v a -> (forall (n :: Nat). KnownNat n => Vector v n a -> r) -> r
forall (v :: Type -> Type) a r.
Vector v a =>
v a -> (forall (n :: Nat). KnownNat n => Vector v n a -> r) -> r
withSized ([a] -> v a
forall (v :: Type -> Type) a. Vector v a => [a] -> v a
VG.fromList [a]
xs)
convert :: (VG.Vector v a, VG.Vector w a) => Vector v n a -> Vector w n a
convert :: Vector v n a -> Vector w n a
convert = (v a -> w a) -> Vector v n a -> Vector w n a
forall (v :: Type -> Type) a (w :: Type -> Type) b (n :: Nat).
(v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe v a -> w a
forall (v :: Type -> Type) a (w :: Type -> Type).
(Vector v a, Vector w a) =>
v a -> w a
VG.convert
{-# inline convert #-}
freeze :: (PrimMonad m, VG.Vector v a)
=> SVGM.MVector (VG.Mutable v) n (PrimState m) a
-> m (Vector v n a)
freeze :: MVector (Mutable v) n (PrimState m) a -> m (Vector v n a)
freeze (MVector Mutable v (PrimState m) a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> m (v a) -> m (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable v (PrimState m) a -> m (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> m (v a)
VG.freeze Mutable v (PrimState m) a
v
unsafeFreeze :: (PrimMonad m, VG.Vector v a)
=> SVGM.MVector (VG.Mutable v) n (PrimState m) a
-> m (Vector v n a)
unsafeFreeze :: MVector (Mutable v) n (PrimState m) a -> m (Vector v n a)
unsafeFreeze (MVector Mutable v (PrimState m) a
v) = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> m (v a) -> m (Vector v n a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable v (PrimState m) a -> m (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> m (v a)
VG.unsafeFreeze Mutable v (PrimState m) a
v
thaw :: (PrimMonad m, VG.Vector v a)
=> Vector v n a
-> m (SVGM.MVector (VG.Mutable v) n (PrimState m) a)
thaw :: Vector v n a -> m (MVector (Mutable v) n (PrimState m) a)
thaw (Vector v a
v) = Mutable v (PrimState m) a -> MVector (Mutable v) n (PrimState m) a
forall (v :: Type -> Type -> Type) (n :: Nat) s a.
v s a -> MVector v n s a
MVector (Mutable v (PrimState m) a
-> MVector (Mutable v) n (PrimState m) a)
-> m (Mutable v (PrimState m) a)
-> m (MVector (Mutable v) n (PrimState m) a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> v a -> m (Mutable v (PrimState m) a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
v a -> m (Mutable v (PrimState m) a)
VG.thaw v a
v
unsafeThaw :: (PrimMonad m, VG.Vector v a)
=> Vector v n a
-> m (SVGM.MVector (VG.Mutable v) n (PrimState m) a)
unsafeThaw :: Vector v n a -> m (MVector (Mutable v) n (PrimState m) a)
unsafeThaw (Vector v a
v) = Mutable v (PrimState m) a -> MVector (Mutable v) n (PrimState m) a
forall (v :: Type -> Type -> Type) (n :: Nat) s a.
v s a -> MVector v n s a
MVector (Mutable v (PrimState m) a
-> MVector (Mutable v) n (PrimState m) a)
-> m (Mutable v (PrimState m) a)
-> m (MVector (Mutable v) n (PrimState m) a)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> v a -> m (Mutable v (PrimState m) a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
v a -> m (Mutable v (PrimState m) a)
VG.unsafeThaw v a
v
copy :: (PrimMonad m, VG.Vector v a)
=> SVGM.MVector (VG.Mutable v) n (PrimState m) a
-> Vector v n a
-> m ()
copy :: MVector (Mutable v) n (PrimState m) a -> Vector v n a -> m ()
copy (MVector Mutable v (PrimState m) a
v) (Vector v a
u) = Mutable v (PrimState m) a -> v a -> m ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> v a -> m ()
VG.unsafeCopy Mutable v (PrimState m) a
v v a
u
toSized :: forall v n a. (VG.Vector v a, KnownNat n)
=> v a -> Maybe (Vector v n a)
toSized :: v a -> Maybe (Vector v n a)
toSized v a
v
| Integer
n' Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (v a -> Int
forall (v :: Type -> Type) a. Vector v a => v a -> Int
VG.length v a
v) = Vector v n a -> Maybe (Vector v n a)
forall a. a -> Maybe a
Just (v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
v)
| Bool
otherwise = Maybe (Vector v n a)
forall a. Maybe a
Nothing
where n' :: Integer
n' = Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n)
{-# inline toSized #-}
withSized :: forall v a r. VG.Vector v a
=> v a
-> (forall n. KnownNat n => Vector v n a -> r) -> r
withSized :: v a -> (forall (n :: Nat). KnownNat n => Vector v n a -> r) -> r
withSized v a
v forall (n :: Nat). KnownNat n => Vector v n a -> r
f = case Integer -> Maybe SomeNat
someNatVal (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (v a -> Int
forall (v :: Type -> Type) a. Vector v a => v a -> Int
VG.length v a
v)) of
Just (SomeNat (Proxy n
Proxy :: Proxy n)) -> Vector v n a -> r
forall (n :: Nat). KnownNat n => Vector v n a -> r
f (v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
v :: Vector v n a)
Maybe SomeNat
Nothing -> String -> r
forall a. HasCallStack => String -> a
error String
"impossible: Vector has negative length"
fromSized :: Vector v n a -> v a
fromSized :: Vector v n a -> v a
fromSized (Vector v a
v) = v a
v
{-# inline fromSized #-}
withVectorUnsafe :: (v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe :: (v a -> w b) -> Vector v n a -> Vector w n b
withVectorUnsafe v a -> w b
f (Vector v a
v) = w b -> Vector w n b
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> w b
f v a
v)
{-# inline withVectorUnsafe #-}
zipVectorsUnsafe :: (u a -> v b -> w c) -> Vector u n a -> Vector v n b -> Vector w n c
zipVectorsUnsafe :: (u a -> v b -> w c) -> Vector u n a -> Vector v n b -> Vector w n c
zipVectorsUnsafe u a -> v b -> w c
f (Vector u a
u) (Vector v b
v) = w c -> Vector w n c
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (u a -> v b -> w c
f u a
u v b
v)
{-# inline zipVectorsUnsafe #-}
data SV_ v a = forall n. KnownNat n => SV_ (Vector v n a)
pattern SomeSized
:: VG.Vector v a
=> forall n. KnownNat n
=> Vector v n a
-> v a
pattern $bSomeSized :: Vector v n a -> v a
$mSomeSized :: forall r (v :: Type -> Type) a.
Vector v a =>
v a
-> (forall (n :: Nat). KnownNat n => Vector v n a -> r)
-> (Void# -> r)
-> r
SomeSized v <- ((`withSized` SV_) -> SV_ v)
where
SomeSized Vector v n a
v = Vector v n a -> v a
forall (v :: Type -> Type) (n :: Nat) a. Vector v n a -> v a
fromSized Vector v n a
v
{-# complete SomeSized :: Boxed.Vector #-}
{-# complete SomeSized :: Unboxed.Vector #-}
{-# complete SomeSized :: Storable.Vector #-}
instance (VG.Vector v a, Num a, KnownNat n) => Num (Vector v n a) where
+ :: Vector v n a -> Vector v n a -> Vector v n a
(+) = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> a -> a
forall a. Num a => a -> a -> a
(+)
(-) = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith (-)
* :: Vector v n a -> Vector v n a -> Vector v n a
(*) = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> a -> a
forall a. Num a => a -> a -> a
(*)
negate :: Vector v n a -> Vector v n a
negate = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Num a => a -> a
negate
abs :: Vector v n a -> Vector v n a
abs = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Num a => a -> a
abs
signum :: Vector v n a -> Vector v n a
signum = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Num a => a -> a
signum
fromInteger :: Integer -> Vector v n a
fromInteger = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate (a -> Vector v n a) -> (Integer -> a) -> Integer -> Vector v n a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger
instance (VG.Vector v a, Fractional a, KnownNat n) => Fractional (Vector v n a) where
/ :: Vector v n a -> Vector v n a -> Vector v n a
(/) = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> a -> a
forall a. Fractional a => a -> a -> a
(/)
recip :: Vector v n a -> Vector v n a
recip = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Fractional a => a -> a
recip
fromRational :: Rational -> Vector v n a
fromRational = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate (a -> Vector v n a) -> (Rational -> a) -> Rational -> Vector v n a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> a
forall a. Fractional a => Rational -> a
fromRational
instance (VG.Vector v a, Floating a, KnownNat n) => Floating (Vector v n a) where
pi :: Vector v n a
pi = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate a
forall a. Floating a => a
pi
exp :: Vector v n a -> Vector v n a
exp = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
exp
log :: Vector v n a -> Vector v n a
log = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
log
sqrt :: Vector v n a -> Vector v n a
sqrt = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
sqrt
** :: Vector v n a -> Vector v n a -> Vector v n a
(**) = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> a -> a
forall a. Floating a => a -> a -> a
(**)
logBase :: Vector v n a -> Vector v n a -> Vector v n a
logBase = (a -> a -> a) -> Vector v n a -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b c (n :: Nat).
(Vector v a, Vector v b, Vector v c) =>
(a -> b -> c) -> Vector v n a -> Vector v n b -> Vector v n c
zipWith a -> a -> a
forall a. Floating a => a -> a -> a
logBase
sin :: Vector v n a -> Vector v n a
sin = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
sin
cos :: Vector v n a -> Vector v n a
cos = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
cos
tan :: Vector v n a -> Vector v n a
tan = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
tan
asin :: Vector v n a -> Vector v n a
asin = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
asin
acos :: Vector v n a -> Vector v n a
acos = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
acos
atan :: Vector v n a -> Vector v n a
atan = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
atan
sinh :: Vector v n a -> Vector v n a
sinh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
sinh
cosh :: Vector v n a -> Vector v n a
cosh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
cosh
tanh :: Vector v n a -> Vector v n a
tanh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
tanh
asinh :: Vector v n a -> Vector v n a
asinh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
asinh
acosh :: Vector v n a -> Vector v n a
acosh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
acosh
atanh :: Vector v n a -> Vector v n a
atanh = (a -> a) -> Vector v n a -> Vector v n a
forall (v :: Type -> Type) a b (n :: Nat).
(Vector v a, Vector v b) =>
(a -> b) -> Vector v n a -> Vector v n b
map a -> a
forall a. Floating a => a -> a
atanh
instance (VG.Vector v a, Binary a, KnownNat n) => Binary (Vector v n a) where
get :: Get (Vector v n a)
get = Get a -> Get (Vector v n a)
forall (v :: Type -> Type) (n :: Nat) (m :: Type -> Type) a.
(KnownNat n, Vector v a, Monad m) =>
m a -> m (Vector v n a)
replicateM Get a
forall t. Binary t => Get t
Data.Binary.get
put :: Vector v n a -> Put
put = (a -> Put) -> Vector v n a -> Put
forall (m :: Type -> Type) (v :: Type -> Type) a b (n :: Nat).
(Monad m, Vector v a) =>
(a -> m b) -> Vector v n a -> m ()
mapM_ a -> Put
forall t. Binary t => t -> Put
put
instance (VG.Vector v a, Bits (v a), Bits a, KnownNat n) => Bits (Vector v n a) where
.&. :: Vector v n a -> Vector v n a -> Vector v n a
(.&.) = (v a -> v a -> v a) -> Vector v n a -> Vector v n a -> Vector v n a
coerce (Bits (v a) => v a -> v a -> v a
forall a. Bits a => a -> a -> a
(.&.) @(v a))
.|. :: Vector v n a -> Vector v n a -> Vector v n a
(.|.) = (v a -> v a -> v a) -> Vector v n a -> Vector v n a -> Vector v n a
coerce (Bits (v a) => v a -> v a -> v a
forall a. Bits a => a -> a -> a
(.|.) @(v a))
xor :: Vector v n a -> Vector v n a -> Vector v n a
xor = (v a -> v a -> v a) -> Vector v n a -> Vector v n a -> Vector v n a
coerce (Bits (v a) => v a -> v a -> v a
forall a. Bits a => a -> a -> a
xor @(v a))
complement :: Vector v n a -> Vector v n a
complement = (v a -> v a) -> Vector v n a -> Vector v n a
coerce (Bits (v a) => v a -> v a
forall a. Bits a => a -> a
complement @(v a))
rotate :: Vector v n a -> Int -> Vector v n a
rotate = (v a -> Int -> v a) -> Vector v n a -> Int -> Vector v n a
coerce (Bits (v a) => v a -> Int -> v a
forall a. Bits a => a -> Int -> a
rotate @(v a))
rotateL :: Vector v n a -> Int -> Vector v n a
rotateL = (v a -> Int -> v a) -> Vector v n a -> Int -> Vector v n a
coerce (Bits (v a) => v a -> Int -> v a
forall a. Bits a => a -> Int -> a
rotateL @(v a))
rotateR :: Vector v n a -> Int -> Vector v n a
rotateR = (v a -> Int -> v a) -> Vector v n a -> Int -> Vector v n a
coerce (Bits (v a) => v a -> Int -> v a
forall a. Bits a => a -> Int -> a
rotateR @(v a))
bitSize :: Vector v n a -> Int
bitSize Vector v n a
x = case Vector v n a -> Maybe Int
forall a. Bits a => a -> Maybe Int
bitSizeMaybe Vector v n a
x of
Maybe Int
Nothing -> String -> Int
forall a. HasCallStack => String -> a
error String
"Vector v n a: bitSize"
Just Int
c -> Int
c
bitSizeMaybe :: Vector v n a -> Maybe Int
bitSizeMaybe Vector v n a
_ = (Int -> Int -> Int
forall a. Num a => a -> a -> a
* Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n))) (Int -> Int) -> Maybe Int -> Maybe Int
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> Maybe Int
forall a. Bits a => a -> Maybe Int
bitSizeMaybe @a a
forall a. HasCallStack => a
undefined
isSigned :: Vector v n a -> Bool
isSigned Vector v n a
_ = Bool
False
testBit :: Vector v n a -> Int -> Bool
testBit = (v a -> Int -> Bool) -> Vector v n a -> Int -> Bool
coerce (Bits (v a) => v a -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit @(v a))
popCount :: Vector v n a -> Int
popCount = (v a -> Int) -> Vector v n a -> Int
coerce (Bits (v a) => v a -> Int
forall a. Bits a => a -> Int
popCount @(v a))
setBit :: Vector v n a -> Int -> Vector v n a
setBit = (v a -> Int -> v a) -> Vector v n a -> Int -> Vector v n a
coerce (Bits (v a) => v a -> Int -> v a
forall a. Bits a => a -> Int -> a
setBit @(v a))
complementBit :: Vector v n a -> Int -> Vector v n a
complementBit = (v a -> Int -> v a) -> Vector v n a -> Int -> Vector v n a
coerce (Bits (v a) => v a -> Int -> v a
forall a. Bits a => a -> Int -> a
complementBit @(v a))
bit :: Int -> Vector v n a
bit Int
n = (forall s. ST s (Vector v n a)) -> Vector v n a
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s (Vector v n a)) -> Vector v n a)
-> (forall s. ST s (Vector v n a)) -> Vector v n a
forall a b. (a -> b) -> a -> b
$ do
MVector (Mutable v) n s a
v <- a -> ST s (MVector (Mutable v) n (PrimState (ST s)) a)
forall (v :: Type -> Type -> Type) (n :: Nat) (m :: Type -> Type)
a.
(KnownNat n, PrimMonad m, MVector v a) =>
a -> m (MVector v n (PrimState m) a)
SVGM.replicate a
forall a. Bits a => a
zeroBits
Maybe (Finite n) -> (Finite n -> ST s ()) -> ST s ()
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ (Integer -> Maybe (Finite n)
forall (n :: Nat). KnownNat n => Integer -> Maybe (Finite n)
packFinite (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)) ((Finite n -> ST s ()) -> ST s ())
-> (Finite n -> ST s ()) -> ST s ()
forall a b. (a -> b) -> a -> b
$ \Finite n
i ->
MVector (Mutable v) n (PrimState (ST s)) a
-> Finite n -> a -> ST s ()
forall (v :: Type -> Type -> Type) (n :: Nat) (m :: Type -> Type)
a.
(PrimMonad m, MVector v a) =>
MVector v n (PrimState m) a -> Finite n -> a -> m ()
SVGM.write MVector (Mutable v) n s a
MVector (Mutable v) n (PrimState (ST s)) a
v Finite n
i (a -> a
forall a. Bits a => a -> a
complement a
forall a. Bits a => a
zeroBits)
MVector (Mutable v) n (PrimState (ST s)) a -> ST s (Vector v n a)
forall (m :: Type -> Type) (v :: Type -> Type) a (n :: Nat).
(PrimMonad m, Vector v a) =>
MVector (Mutable v) n (PrimState m) a -> m (Vector v n a)
freeze MVector (Mutable v) n s a
MVector (Mutable v) n (PrimState (ST s)) a
v
zeroBits :: Vector v n a
zeroBits = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate a
forall a. Bits a => a
zeroBits
shiftL :: Vector v n a -> Int -> Vector v n a
shiftL Vector v n a
xs Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = ArithException -> Vector v n a
forall a e. Exception e => e -> a
Exception.throw ArithException
Exception.Overflow
| Bool
otherwise = Vector v n a -> Int -> Vector v n a
forall a. Bits a => a -> Int -> a
unsafeShiftL Vector v n a
xs Int
i
unsafeShiftL :: Vector v n a -> Int -> Vector v n a
unsafeShiftL (Vector v a
xs) Int
i
| Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
xs
| Int
i' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
n = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate a
forall a. Bits a => a
zeroBits
| Bool
otherwise = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> v a -> Vector v n a
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (v a)) -> v a
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s (v a)) -> v a) -> (forall s. ST s (v a)) -> v a
forall a b. (a -> b) -> a -> b
$ do
Mutable v s a
u <- Int -> a -> ST s (Mutable v (PrimState (ST s)) a)
forall (m :: Type -> Type) (v :: Type -> Type -> Type) a.
(PrimMonad m, MVector v a) =>
Int -> a -> m (v (PrimState m) a)
VGM.replicate Int
n a
forall a. Bits a => a
zeroBits
Mutable v (PrimState (ST s)) a -> v a -> ST s ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> v a -> m ()
VG.unsafeCopy (Int -> Mutable v s a -> Mutable v s a
forall (v :: Type -> Type -> Type) a s.
MVector v a =>
Int -> v s a -> v s a
VGM.unsafeDrop Int
i' Mutable v s a
u) (Int -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> v a -> v a
VG.unsafeTake (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i') v a
xs)
Mutable v (PrimState (ST s)) a -> ST s (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> m (v a)
VG.unsafeFreeze Mutable v s a
Mutable v (PrimState (ST s)) a
u
where
n :: Int
n = Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Integer -> Int) -> Integer -> Int
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n)
i' :: Int
i' = Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
n Int
i
shiftR :: Vector v n a -> Int -> Vector v n a
shiftR Vector v n a
xs Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = ArithException -> Vector v n a
forall a e. Exception e => e -> a
Exception.throw ArithException
Exception.Overflow
| Bool
otherwise = Vector v n a -> Int -> Vector v n a
forall a. Bits a => a -> Int -> a
unsafeShiftR Vector v n a
xs Int
i
unsafeShiftR :: Vector v n a -> Int -> Vector v n a
unsafeShiftR (Vector v a
xs) Int
i
| Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector v a
xs
| Int
i' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
n = a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a.
(KnownNat n, Vector v a) =>
a -> Vector v n a
replicate a
forall a. Bits a => a
zeroBits
| Bool
otherwise = v a -> Vector v n a
forall (v :: Type -> Type) (n :: Nat) a. v a -> Vector v n a
Vector (v a -> Vector v n a) -> v a -> Vector v n a
forall a b. (a -> b) -> a -> b
$ (forall s. ST s (v a)) -> v a
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s (v a)) -> v a) -> (forall s. ST s (v a)) -> v a
forall a b. (a -> b) -> a -> b
$ do
Mutable v s a
u <- Int -> a -> ST s (Mutable v (PrimState (ST s)) a)
forall (m :: Type -> Type) (v :: Type -> Type -> Type) a.
(PrimMonad m, MVector v a) =>
Int -> a -> m (v (PrimState m) a)
VGM.replicate Int
n a
forall a. Bits a => a
zeroBits
Mutable v (PrimState (ST s)) a -> v a -> ST s ()
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> v a -> m ()
VG.unsafeCopy (Int -> Mutable v s a -> Mutable v s a
forall (v :: Type -> Type -> Type) a s.
MVector v a =>
Int -> v s a -> v s a
VGM.unsafeTake (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i') Mutable v s a
u) (Int -> v a -> v a
forall (v :: Type -> Type) a. Vector v a => Int -> v a -> v a
VG.unsafeDrop Int
i' v a
xs)
Mutable v (PrimState (ST s)) a -> ST s (v a)
forall (m :: Type -> Type) (v :: Type -> Type) a.
(PrimMonad m, Vector v a) =>
Mutable v (PrimState m) a -> m (v a)
VG.unsafeFreeze Mutable v s a
Mutable v (PrimState (ST s)) a
u
where
n :: Int
n = Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Integer -> Int) -> Integer -> Int
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n)
i' :: Int
i' = Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
n Int
i
instance (VG.Vector v a, Bits (v a), FiniteBits a, KnownNat n) => FiniteBits (Vector v n a) where
finiteBitSize :: Vector v n a -> Int
finiteBitSize Vector v n a
_ = a -> Int
forall b. FiniteBits b => b -> Int
finiteBitSize @a a
forall a. HasCallStack => a
undefined Int -> Int -> Int
forall a. Num a => a -> a -> a
* Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy @n))