{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
module Data.Massiv.Vector (
Vector,
MVector,
slength,
maxLinearSize,
size,
isNull,
isNotNull,
(!?),
(!),
index,
index',
head',
shead',
last',
indexM,
headM,
sheadM,
lastM,
unconsM,
unsnocM,
slice,
slice',
sliceM,
sslice,
sliceAt,
sliceAt',
sliceAtM,
init,
init',
initM,
tail,
tail',
tailM,
take,
take',
takeM,
takeWhile,
stake,
drop,
dropWhile,
drop',
dropM,
sdrop,
empty,
sempty,
singleton,
ssingleton,
cons,
snoc,
A.replicate,
sreplicate,
generate,
sgenerate,
siterate,
siterateN,
sreplicateM,
sgenerateM,
siterateNM,
sunfoldr,
sunfoldrM,
sunfoldrN,
sunfoldrNM,
sunfoldrExactN,
sunfoldrExactNM,
(...),
(..:),
enumFromN,
senumFromN,
enumFromStepN,
senumFromStepN,
sappend,
sconcat,
smap,
simap,
straverse,
sitraverse,
smapM,
smapM_,
simapM,
simapM_,
sforM,
sforM_,
siforM,
siforM_,
szip,
szip3,
szip4,
szip5,
szip6,
szipWith,
szipWith3,
szipWith4,
szipWith5,
szipWith6,
sizipWith,
sizipWith3,
sizipWith4,
sizipWith5,
sizipWith6,
szipWithM,
szipWith3M,
szipWith4M,
szipWith5M,
szipWith6M,
sizipWithM,
sizipWith3M,
sizipWith4M,
sizipWith5M,
sizipWith6M,
szipWithM_,
szipWith3M_,
szipWith4M_,
szipWith5M_,
szipWith6M_,
sizipWithM_,
sizipWith3M_,
sizipWith4M_,
sizipWith5M_,
sizipWith6M_,
sfilter,
sifilter,
sfilterM,
sifilterM,
smapMaybe,
smapMaybeM,
scatMaybes,
simapMaybe,
simapMaybeM,
findIndex,
sfoldl,
sfoldlM,
sfoldlM_,
sifoldl,
sifoldlM,
sifoldlM_,
sfoldl1',
sfoldl1M,
sfoldl1M_,
sor,
sand,
sall,
sany,
ssum,
sproduct,
smaximum',
smaximumM,
sminimum',
sminimumM,
sprescanl,
spostscanl,
spostscanlAcc,
sscanl,
sscanl1,
stoList,
fromList,
sfromList,
sfromListN,
compute,
computeS,
computeIO,
computePrimM,
computeAs,
computeProxy,
computeSource,
computeWithStride,
computeWithStrideAs,
clone,
convert,
convertAs,
convertProxy,
module Data.Massiv.Core,
module Data.Massiv.Array.Delayed,
module Data.Massiv.Array.Manifest,
module Data.Massiv.Array.Mutable,
) where
import Control.Monad hiding (filterM, replicateM)
import Data.Coerce
import Data.Massiv.Array.Delayed
import Data.Massiv.Array.Delayed.Pull
import Data.Massiv.Array.Delayed.Push
import Data.Massiv.Array.Delayed.Stream
import Data.Massiv.Array.Manifest
import Data.Massiv.Array.Manifest.Internal
import Data.Massiv.Array.Manifest.List (fromList)
import Data.Massiv.Array.Mutable
import Data.Massiv.Array.Ops.Construct
import qualified Data.Massiv.Array.Ops.Construct as A (replicate)
import Data.Massiv.Core
import Data.Massiv.Core.Common
import qualified Data.Massiv.Vector.Stream as S
import Data.Massiv.Vector.Unsafe
import Data.Maybe
import Prelude hiding (
drop,
dropWhile,
init,
length,
null,
replicate,
splitAt,
tail,
take,
takeWhile,
)
slength
:: forall r ix e
. Stream r ix e
=> Array r ix e
-> Maybe Sz1
slength :: forall r ix e. Stream r ix e => Array r ix e -> Maybe Sz1
slength Array r ix e
v =
case Steps Id e -> LengthHint
forall (m :: * -> *) e. Steps m e -> LengthHint
stepsSize (Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream Array r ix e
v) of
LengthExact Sz1
sz -> Sz1 -> Maybe Sz1
forall a. a -> Maybe a
Just Sz1
sz
LengthHint
_ -> Maybe Sz1
forall a. Maybe a
Nothing
{-# INLINE slength #-}
head'
:: forall r e
. (HasCallStack, Source r e)
=> Vector r e
-> e
head' :: forall r e. (HasCallStack, Source r e) => Vector r e -> e
head' = Either SomeException e -> e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException e -> e)
-> (Vector r e -> Either SomeException e) -> Vector r e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Either SomeException e
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m e
headM
{-# INLINE head' #-}
headM
:: forall r e m
. (Source r e, MonadThrow m)
=> Vector r e
-> m e
headM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m e
headM Vector r e
v
| Vector r e -> Int
forall ix r e. (Index ix, Size r) => Array r ix e -> Int
elemsCount Vector r e
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = SizeException -> m e
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m e) -> SizeException -> m e
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v)
| Bool
otherwise = e -> m e
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> m e) -> e -> m e
forall a b. (a -> b) -> a -> b
$ Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
v Int
0
{-# INLINE headM #-}
shead'
:: forall r e
. (HasCallStack, Stream r Ix1 e)
=> Vector r e
-> e
shead' :: forall r e. (HasCallStack, Stream r Int e) => Vector r e -> e
shead' = Either SomeException e -> e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException e -> e)
-> (Vector r e -> Either SomeException e) -> Vector r e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Either SomeException e
forall r e (m :: * -> *).
(Stream r Int e, MonadThrow m) =>
Vector r e -> m e
sheadM
{-# INLINE shead' #-}
sheadM
:: forall r e m
. (Stream r Ix1 e, MonadThrow m)
=> Vector r e
-> m e
sheadM :: forall r e (m :: * -> *).
(Stream r Int e, MonadThrow m) =>
Vector r e -> m e
sheadM Vector r e
v =
case Id (Maybe e) -> Maybe e
forall a. Id a -> a
S.unId (Steps Id e -> Id (Maybe e)
forall (m :: * -> *) a. Monad m => Steps m a -> m (Maybe a)
S.headMaybe (Vector r e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream Vector r e
v)) of
Maybe e
Nothing -> SizeException -> m e
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m e) -> SizeException -> m e
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Sz1
forall ix. Index ix => Sz ix
zeroSz :: Sz1)
Just e
e -> e -> m e
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure e
e
{-# INLINE sheadM #-}
unconsM
:: forall r e m
. (MonadThrow m, Source r e)
=> Vector r e
-> m (e, Vector r e)
unconsM :: forall r e (m :: * -> *).
(MonadThrow m, Source r e) =>
Vector r e -> m (e, Vector r e)
unconsM Vector r e
arr
| Int
0 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Sz1 -> Int
forall ix. Index ix => Sz ix -> Int
totalElem Sz1
sz = SizeException -> m (e, Vector r e)
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m (e, Vector r e))
-> SizeException -> m (e, Vector r e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException Sz1
sz
| Bool
otherwise = (e, Vector r e) -> m (e, Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
arr Int
0, Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
1 (Int -> Sz1
forall ix. ix -> Sz ix
SafeSz (Sz1 -> Int
forall ix. Sz ix -> ix
unSz Sz1
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)) Vector r e
arr)
where
!sz :: Sz1
sz = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
arr
{-# INLINE unconsM #-}
unsnocM
:: forall r e m
. (MonadThrow m, Source r e)
=> Vector r e
-> m (Vector r e, e)
unsnocM :: forall r e (m :: * -> *).
(MonadThrow m, Source r e) =>
Vector r e -> m (Vector r e, e)
unsnocM Vector r e
arr
| Int
0 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Sz1 -> Int
forall ix. Index ix => Sz ix -> Int
totalElem Sz1
sz = SizeException -> m (Vector r e, e)
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m (Vector r e, e))
-> SizeException -> m (Vector r e, e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException Sz1
sz
| Bool
otherwise = (Vector r e, e) -> m (Vector r e, e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
0 (Int -> Sz1
forall ix. ix -> Sz ix
SafeSz Int
k) Vector r e
arr, Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
arr Int
k)
where
!sz :: Sz1
sz = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
arr
!k :: Int
k = Sz1 -> Int
forall ix. Sz ix -> ix
unSz Sz1
sz Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
{-# INLINE unsnocM #-}
last' :: forall r e. (HasCallStack, Source r e) => Vector r e -> e
last' :: forall r e. (HasCallStack, Source r e) => Vector r e -> e
last' = Either SomeException e -> e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException e -> e)
-> (Vector r e -> Either SomeException e) -> Vector r e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Either SomeException e
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m e
lastM
{-# INLINE last' #-}
lastM :: forall r e m. (Source r e, MonadThrow m) => Vector r e -> m e
lastM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m e
lastM Vector r e
v
| Int
k Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = SizeException -> m e
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m e) -> SizeException -> m e
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v)
| Bool
otherwise = e -> m e
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> m e) -> e -> m e
forall a b. (a -> b) -> a -> b
$ Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
v (Int
k Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
where
k :: Int
k = Sz1 -> Int
forall ix. Sz ix -> ix
unSz (Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v)
{-# INLINE lastM #-}
slice :: forall r e. Source r e => Ix1 -> Sz1 -> Vector r e -> Vector r e
slice :: forall r e. Source r e => Int -> Sz1 -> Vector r e -> Vector r e
slice !Int
i (Sz Int
k) Vector r e
v = Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
i' Sz1
newSz Vector r e
v
where
!i' :: Int
i' = Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
n (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 Int
i)
!newSz :: Sz1
newSz = Int -> Sz1
forall ix. ix -> Sz ix
SafeSz (Int -> Int -> Int
forall a. Ord a => a -> a -> a
min (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i') Int
k)
Sz Int
n = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
{-# INLINE slice #-}
slice' :: forall r e. (HasCallStack, Source r e) => Ix1 -> Sz1 -> Vector r e -> Vector r e
slice' :: forall r e.
(HasCallStack, Source r e) =>
Int -> Sz1 -> Vector r e -> Vector r e
slice' Int
i Sz1
k = Either SomeException (Vector r e) -> Vector r e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e) -> Vector r e)
-> (Vector r e -> Either SomeException (Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Sz1 -> Vector r e -> Either SomeException (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Int -> Sz1 -> Vector r e -> m (Vector r e)
sliceM Int
i Sz1
k
{-# INLINE slice' #-}
sliceM
:: forall r e m
. (Source r e, MonadThrow m)
=> Ix1
-> Sz1
-> Vector r e
-> m (Vector r e)
sliceM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Int -> Sz1 -> Vector r e -> m (Vector r e)
sliceM Int
i newSz :: Sz1
newSz@(Sz Int
k) Vector r e
v
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0 Bool -> Bool -> Bool
&& Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i = Vector r e -> m (Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> m (Vector r e)) -> Vector r e -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
i Sz1
newSz Vector r e
v
| Bool
otherwise = SizeException -> m (Vector r e)
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m (Vector r e))
-> SizeException -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> Int -> Sz1 -> SizeException
forall ix. Index ix => Sz ix -> ix -> Sz ix -> SizeException
SizeSubregionException Sz1
sz Int
i Sz1
newSz
where
sz :: Sz1
sz@(Sz Int
n) = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
{-# INLINE sliceM #-}
sslice
:: forall r e
. Stream r Ix1 e
=> Ix1
-> Sz1
-> Vector r e
-> Vector DS e
sslice :: forall r e.
Stream r Int e =>
Int -> Sz1 -> Vector r e -> Vector DS e
sslice !Int
i !Sz1
k = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Sz1 -> Steps Id e -> Steps Id e
forall (m :: * -> *) a.
Monad m =>
Int -> Sz1 -> Steps m a -> Steps m a
S.slice Int
i Sz1
k (Steps Id e -> Steps Id e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Steps Id e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE sslice #-}
init :: forall r e. Source r e => Vector r e -> Vector r e
init :: forall r e. Source r e => Vector r e -> Vector r e
init Vector r e
v = Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
0 (Int -> Sz1
forall ix. Index ix => ix -> Sz ix
Sz (Sz1 -> Int
forall a b. Coercible a b => a -> b
coerce (Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)) Vector r e
v
{-# INLINE init #-}
init' :: forall r e. (HasCallStack, Source r e) => Vector r e -> Vector r e
init' :: forall r e. (HasCallStack, Source r e) => Vector r e -> Vector r e
init' = Either SomeException (Vector r e) -> Vector r e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e) -> Vector r e)
-> (Vector r e -> Either SomeException (Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Either SomeException (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m (Vector r e)
initM
{-# INLINE init' #-}
initM :: forall r e m. (Source r e, MonadThrow m) => Vector r e -> m (Vector r e)
initM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m (Vector r e)
initM Vector r e
v = do
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Vector r e -> Int
forall ix r e. (Index ix, Size r) => Array r ix e -> Int
elemsCount Vector r e
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ SizeException -> m ()
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m ()) -> SizeException -> m ()
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Sz1 -> SizeException) -> Sz1 -> SizeException
forall a b. (a -> b) -> a -> b
$ Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
Vector r e -> m (Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> m (Vector r e)) -> Vector r e -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Vector r e -> Vector r e
forall r e. Source r e => Vector r e -> Vector r e
unsafeInit Vector r e
v
{-# INLINE initM #-}
tail :: forall r e. Source r e => Vector r e -> Vector r e
tail :: forall r e. Source r e => Vector r e -> Vector r e
tail = Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
drop Sz1
forall ix. Index ix => Sz ix
oneSz
{-# INLINE tail #-}
tail' :: forall r e. (HasCallStack, Source r e) => Vector r e -> Vector r e
tail' :: forall r e. (HasCallStack, Source r e) => Vector r e -> Vector r e
tail' = Either SomeException (Vector r e) -> Vector r e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e) -> Vector r e)
-> (Vector r e -> Either SomeException (Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Either SomeException (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m (Vector r e)
tailM
{-# INLINE tail' #-}
tailM :: forall r e m. (Source r e, MonadThrow m) => Vector r e -> m (Vector r e)
tailM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Vector r e -> m (Vector r e)
tailM Vector r e
v = do
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Vector r e -> Int
forall ix r e. (Index ix, Size r) => Array r ix e -> Int
elemsCount Vector r e
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ SizeException -> m ()
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m ()) -> SizeException -> m ()
forall a b. (a -> b) -> a -> b
$ Sz1 -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Sz1 -> SizeException) -> Sz1 -> SizeException
forall a b. (a -> b) -> a -> b
$ Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
Vector r e -> m (Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> m (Vector r e)) -> Vector r e -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Vector r e -> Vector r e
forall r e. Source r e => Vector r e -> Vector r e
unsafeTail Vector r e
v
{-# INLINE tailM #-}
take :: Source r e => Sz1 -> Vector r e -> Vector r e
take :: forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
take Sz1
k = (Vector r e, Vector r e) -> Vector r e
forall a b. (a, b) -> a
fst ((Vector r e, Vector r e) -> Vector r e)
-> (Vector r e -> (Vector r e, Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Vector r e -> (Vector r e, Vector r e)
forall r e.
Source r e =>
Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt Sz1
k
{-# INLINE take #-}
takeWhile :: Manifest r e => (e -> Bool) -> Vector r e -> Vector r e
takeWhile :: forall r e. Manifest r e => (e -> Bool) -> Vector r e -> Vector r e
takeWhile e -> Bool
f Vector r e
v = Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
take (Int -> Sz1
go Int
0) Vector r e
v
where
!k :: Int
k = Vector r e -> Int
forall ix r e. (Index ix, Size r) => Array r ix e -> Int
elemsCount Vector r e
v
go :: Int -> Sz1
go !Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
k Bool -> Bool -> Bool
&& e -> Bool
f (Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
v Int
i) = Int -> Sz1
go (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
| Bool
otherwise = Int -> Sz1
forall ix. ix -> Sz ix
SafeSz Int
i
{-# INLINE takeWhile #-}
take' :: forall r e. (HasCallStack, Source r e) => Sz1 -> Vector r e -> Vector r e
take' :: forall r e.
(HasCallStack, Source r e) =>
Sz1 -> Vector r e -> Vector r e
take' Sz1
k = Either SomeException (Vector r e) -> Vector r e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e) -> Vector r e)
-> (Vector r e -> Either SomeException (Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Vector r e -> Either SomeException (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e)
takeM Sz1
k
{-# INLINE take' #-}
takeM :: forall r e m. (Source r e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e)
takeM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e)
takeM Sz1
k Vector r e
v = do
let sz :: Sz1
sz = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Sz1
k Sz1 -> Sz1 -> Bool
forall a. Ord a => a -> a -> Bool
> Sz1
sz) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ SizeException -> m ()
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m ()) -> SizeException -> m ()
forall a b. (a -> b) -> a -> b
$ Sz1 -> Int -> Sz1 -> SizeException
forall ix. Index ix => Sz ix -> ix -> Sz ix -> SizeException
SizeSubregionException Sz1
sz Int
0 Sz1
k
Vector r e -> m (Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> m (Vector r e)) -> Vector r e -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
unsafeTake Sz1
k Vector r e
v
{-# INLINE takeM #-}
stake :: forall r e. Stream r Ix1 e => Sz1 -> Vector r e -> Vector DS e
stake :: forall r e. Stream r Int e => Sz1 -> Vector r e -> Vector DS e
stake Sz1
n = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Steps Id e -> Steps Id e
forall (m :: * -> *) a. Monad m => Sz1 -> Steps m a -> Steps m a
S.take Sz1
n (Steps Id e -> Steps Id e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Steps Id e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE stake #-}
drop :: forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
drop :: forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
drop Sz1
k = (Vector r e, Vector r e) -> Vector r e
forall a b. (a, b) -> b
snd ((Vector r e, Vector r e) -> Vector r e)
-> (Vector r e -> (Vector r e, Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Vector r e -> (Vector r e, Vector r e)
forall r e.
Source r e =>
Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt Sz1
k
{-# INLINE drop #-}
dropWhile :: forall r e. Manifest r e => (e -> Bool) -> Vector r e -> Vector r e
dropWhile :: forall r e. Manifest r e => (e -> Bool) -> Vector r e -> Vector r e
dropWhile e -> Bool
f Vector r e
v = Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
drop (Int -> Sz1
go Int
0) Vector r e
v
where
!k :: Int
k = Vector r e -> Int
forall ix r e. (Index ix, Size r) => Array r ix e -> Int
elemsCount Vector r e
v
go :: Int -> Sz1
go !Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
k Bool -> Bool -> Bool
&& e -> Bool
f (Vector r e -> Int -> e
forall ix. Index ix => Array r ix e -> Int -> e
forall r e ix. (Source r e, Index ix) => Array r ix e -> Int -> e
unsafeLinearIndex Vector r e
v Int
i) = Int -> Sz1
go (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
| Bool
otherwise = Int -> Sz1
forall ix. ix -> Sz ix
SafeSz Int
i
{-# INLINE dropWhile #-}
sdrop :: forall r e. Stream r Ix1 e => Sz1 -> Vector r e -> Vector DS e
sdrop :: forall r e. Stream r Int e => Sz1 -> Vector r e -> Vector DS e
sdrop Sz1
n = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Steps Id e -> Steps Id e
forall (m :: * -> *) a. Monad m => Sz1 -> Steps m a -> Steps m a
S.drop Sz1
n (Steps Id e -> Steps Id e)
-> (Vector r e -> Steps Id e) -> Vector r e -> Steps Id e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector r e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE sdrop #-}
drop' :: forall r e. (HasCallStack, Source r e) => Sz1 -> Vector r e -> Vector r e
drop' :: forall r e.
(HasCallStack, Source r e) =>
Sz1 -> Vector r e -> Vector r e
drop' Sz1
k = Either SomeException (Vector r e) -> Vector r e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e) -> Vector r e)
-> (Vector r e -> Either SomeException (Vector r e))
-> Vector r e
-> Vector r e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Vector r e -> Either SomeException (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e)
dropM Sz1
k
{-# INLINE drop' #-}
dropM :: forall r e m. (Source r e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e)
dropM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e)
dropM k :: Sz1
k@(Sz Int
d) Vector r e
v = do
let sz :: Sz1
sz@(Sz Int
n) = Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Sz1
k Sz1 -> Sz1 -> Bool
forall a. Ord a => a -> a -> Bool
> Sz1
sz) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ SizeException -> m ()
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m ()) -> SizeException -> m ()
forall a b. (a -> b) -> a -> b
$ Sz1 -> Int -> Sz1 -> SizeException
forall ix. Index ix => Sz ix -> ix -> Sz ix -> SizeException
SizeSubregionException Sz1
sz Int
d (Int -> Sz1
forall ix. ix -> Sz ix
SafeSz (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
d))
Vector r e -> m (Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e -> m (Vector r e)) -> Vector r e -> m (Vector r e)
forall a b. (a -> b) -> a -> b
$ Int -> Sz1 -> Vector r e -> Vector r e
forall ix. Index ix => Int -> Sz1 -> Array r ix e -> Vector r e
forall r e ix.
(Source r e, Index ix) =>
Int -> Sz1 -> Array r ix e -> Array r Int e
unsafeLinearSlice Int
d (Int -> Sz1
forall ix. ix -> Sz ix
SafeSz (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
d)) Vector r e
v
{-# INLINE dropM #-}
sliceAt :: forall r e. Source r e => Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt :: forall r e.
Source r e =>
Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt (Sz Int
k) Vector r e
v = (Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
unsafeTake Sz1
d Vector r e
v, Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
unsafeDrop Sz1
d Vector r e
v)
where
!n :: Int
n = Sz1 -> Int
forall a b. Coercible a b => a -> b
coerce (Vector r e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array r ix e -> Sz ix
size Vector r e
v)
!d :: Sz1
d = Int -> Sz1
forall ix. ix -> Sz ix
SafeSz (Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
k Int
n)
{-# INLINE sliceAt #-}
sliceAt' :: (HasCallStack, Source r e) => Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt' :: forall r e.
(HasCallStack, Source r e) =>
Sz1 -> Vector r e -> (Vector r e, Vector r e)
sliceAt' Sz1
k = Either SomeException (Vector r e, Vector r e)
-> (Vector r e, Vector r e)
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException (Vector r e, Vector r e)
-> (Vector r e, Vector r e))
-> (Vector r e -> Either SomeException (Vector r e, Vector r e))
-> Vector r e
-> (Vector r e, Vector r e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> Vector r e -> Either SomeException (Vector r e, Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e, Vector r e)
sliceAtM Sz1
k
{-# INLINE sliceAt' #-}
sliceAtM :: forall r e m. (Source r e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e, Vector r e)
sliceAtM :: forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e, Vector r e)
sliceAtM Sz1
k Vector r e
v = do
Vector r e
l <- Sz1 -> Vector r e -> m (Vector r e)
forall r e (m :: * -> *).
(Source r e, MonadThrow m) =>
Sz1 -> Vector r e -> m (Vector r e)
takeM Sz1
k Vector r e
v
(Vector r e, Vector r e) -> m (Vector r e, Vector r e)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector r e
l, Sz1 -> Vector r e -> Vector r e
forall r e. Source r e => Sz1 -> Vector r e -> Vector r e
unsafeDrop Sz1
k Vector r e
v)
{-# INLINE sliceAtM #-}
sempty :: Vector DS e
sempty :: forall e. Vector DS e
sempty = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray Steps Id e
forall (m :: * -> *) e. Monad m => Steps m e
S.empty
{-# INLINE sempty #-}
ssingleton :: e -> Vector DS e
ssingleton :: forall e. e -> Vector DS e
ssingleton = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (e -> Steps Id e) -> e -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Steps Id e
forall (m :: * -> *) e. Monad m => e -> Steps m e
S.singleton
{-# INLINE ssingleton #-}
cons :: forall r e. (Size r, Load r Ix1 e) => e -> Vector r e -> Vector DL e
cons :: forall r e.
(Size r, Load r Int e) =>
e -> Vector r e -> Vector DL e
cons e
e Vector r e
v =
let dv :: Array DL Int e
dv = Vector r e -> Array DL Int e
forall r ix e.
(Size r, Load r ix e) =>
Array r ix e -> Array DL ix e
toLoadArray Vector r e
v
load :: Scheduler s ()
-> Int
-> (Int -> e -> ST s ())
-> (Int -> Sz1 -> e -> ST s ())
-> ST s ()
load Scheduler s ()
scheduler Int
startAt Int -> e -> ST s ()
uWrite Int -> Sz1 -> e -> ST s ()
uSet =
Int -> e -> ST s ()
uWrite Int
startAt e
e ST s () -> ST s () -> ST s ()
forall a b. ST s a -> ST s b -> ST s b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Array DL Int e -> Loader e
forall ix e. Array DL ix e -> Loader e
dlLoad Array DL Int e
dv Scheduler s ()
scheduler (Int
startAt Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int -> e -> ST s ()
uWrite Int -> Sz1 -> e -> ST s ()
uSet
{-# INLINE load #-}
in Array DL Int e
dv{dlSize = SafeSz (1 + unSz (dlSize dv)), dlLoad = load}
{-# INLINE cons #-}
snoc :: forall r e. (Size r, Load r Ix1 e) => Vector r e -> e -> Vector DL e
snoc :: forall r e.
(Size r, Load r Int e) =>
Vector r e -> e -> Vector DL e
snoc Vector r e
v e
e =
let dv :: Array DL Int e
dv = Vector r e -> Array DL Int e
forall r ix e.
(Size r, Load r ix e) =>
Array r ix e -> Array DL ix e
toLoadArray Vector r e
v
!k :: Int
k = Sz1 -> Int
forall ix. Sz ix -> ix
unSz (Array DL Int e -> Sz1
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array DL ix e -> Sz ix
size Array DL Int e
dv)
load :: Scheduler s ()
-> Int
-> (Int -> e -> ST s ())
-> (Int -> Sz1 -> e -> ST s ())
-> ST s ()
load Scheduler s ()
scheduler Int
startAt Int -> e -> ST s ()
uWrite Int -> Sz1 -> e -> ST s ()
uSet =
Array DL Int e -> Loader e
forall ix e. Array DL ix e -> Loader e
dlLoad Array DL Int e
dv Scheduler s ()
scheduler Int
startAt Int -> e -> ST s ()
uWrite Int -> Sz1 -> e -> ST s ()
uSet ST s () -> ST s () -> ST s ()
forall a b. ST s a -> ST s b -> ST s b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> e -> ST s ()
uWrite (Int
k Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
startAt) e
e
{-# INLINE load #-}
in Array DL Int e
dv{dlSize = SafeSz (1 + k), dlLoad = load}
{-# INLINE snoc #-}
sreplicate :: Sz1 -> e -> Vector DS e
sreplicate :: forall e. Sz1 -> e -> Vector DS e
sreplicate Sz1
n = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (e -> Steps Id e) -> e -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> e -> Steps Id e
forall (m :: * -> *) a. Monad m => Sz1 -> a -> Steps m a
S.replicate Sz1
n
{-# INLINE sreplicate #-}
generate :: Comp -> Sz1 -> (Ix1 -> e) -> Vector D e
generate :: forall e. Comp -> Sz1 -> (Int -> e) -> Vector D e
generate = Comp -> Sz1 -> (Int -> e) -> Array D Int e
forall r ix e.
Load r ix e =>
Comp -> Sz ix -> (Int -> e) -> Array r ix e
makeArrayLinear
{-# INLINE generate #-}
sgenerate :: Sz1 -> (Ix1 -> e) -> Vector DS e
sgenerate :: forall e. Sz1 -> (Int -> e) -> Vector DS e
sgenerate Sz1
n = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> ((Int -> e) -> Steps Id e) -> (Int -> e) -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> (Int -> e) -> Steps Id e
forall (m :: * -> *) e. Monad m => Sz1 -> (Int -> e) -> Steps m e
S.generate Sz1
n
{-# INLINE sgenerate #-}
siterate :: (e -> e) -> e -> Vector DS e
siterate :: forall e. (e -> e) -> e -> Vector DS e
siterate e -> e
f = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> (e -> Steps Id e) -> e -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Maybe (e, e)) -> e -> Steps Id e
forall (m :: * -> *) s e.
Monad m =>
(s -> Maybe (e, s)) -> s -> Steps m e
S.unfoldr (\e
a -> (e, e) -> Maybe (e, e)
forall a. a -> Maybe a
Just (e
a, e -> e
f e
a))
{-# INLINE siterate #-}
siterateN :: Sz1 -> (e -> e) -> e -> Vector DS e
siterateN :: forall e. Sz1 -> (e -> e) -> e -> Vector DS e
siterateN Sz1
n e -> e
f e
a = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e) -> Steps Id e -> Vector DS e
forall a b. (a -> b) -> a -> b
$ Sz1 -> (e -> e) -> e -> Steps Id e
forall (m :: * -> *) a.
Monad m =>
Sz1 -> (a -> a) -> a -> Steps m a
S.iterateN Sz1
n e -> e
f e
a
{-# INLINE siterateN #-}
sreplicateM :: forall e m. Monad m => Sz1 -> m e -> m (Vector DS e)
sreplicateM :: forall e (m :: * -> *). Monad m => Sz1 -> m e -> m (Vector DS e)
sreplicateM Sz1
n m e
f = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e)) -> Steps m e -> m (Vector DS e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> m e -> Steps m e
forall (m :: * -> *) a. Monad m => Sz1 -> m a -> Steps m a
S.replicateM Sz1
n m e
f
{-# INLINE sreplicateM #-}
sgenerateM :: forall e m. Monad m => Sz1 -> (Ix1 -> m e) -> m (Vector DS e)
sgenerateM :: forall e (m :: * -> *).
Monad m =>
Sz1 -> (Int -> m e) -> m (Vector DS e)
sgenerateM Sz1
n Int -> m e
f = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e)) -> Steps m e -> m (Vector DS e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> (Int -> m e) -> Steps m e
forall (m :: * -> *) a. Monad m => Sz1 -> (Int -> m a) -> Steps m a
S.generateM Sz1
n Int -> m e
f
{-# INLINE sgenerateM #-}
siterateNM :: forall e m. Monad m => Sz1 -> (e -> m e) -> e -> m (Vector DS e)
siterateNM :: forall e (m :: * -> *).
Monad m =>
Sz1 -> (e -> m e) -> e -> m (Vector DS e)
siterateNM Sz1
n e -> m e
f e
a = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e)) -> Steps m e -> m (Vector DS e)
forall a b. (a -> b) -> a -> b
$ Sz1 -> (e -> m e) -> e -> Steps m e
forall (m :: * -> *) a.
Monad m =>
Sz1 -> (a -> m a) -> a -> Steps m a
S.iterateNM Sz1
n e -> m e
f e
a
{-# INLINE siterateNM #-}
sunfoldr :: forall e s. (s -> Maybe (e, s)) -> s -> Vector DS e
sunfoldr :: forall e s. (s -> Maybe (e, s)) -> s -> Vector DS e
sunfoldr s -> Maybe (e, s)
f = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (s -> Steps Id e) -> s -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> Maybe (e, s)) -> s -> Steps Id e
forall (m :: * -> *) s e.
Monad m =>
(s -> Maybe (e, s)) -> s -> Steps m e
S.unfoldr s -> Maybe (e, s)
f
{-# INLINE sunfoldr #-}
sunfoldrN
:: forall e s
. Sz1
-> (s -> Maybe (e, s))
-> s
-> Vector DS e
sunfoldrN :: forall e s. Sz1 -> (s -> Maybe (e, s)) -> s -> Vector DS e
sunfoldrN Sz1
n s -> Maybe (e, s)
f = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (s -> Steps Id e) -> s -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> (s -> Maybe (e, s)) -> s -> Steps Id e
forall (m :: * -> *) s e.
Monad m =>
Sz1 -> (s -> Maybe (e, s)) -> s -> Steps m e
S.unfoldrN Sz1
n s -> Maybe (e, s)
f
{-# INLINE sunfoldrN #-}
sunfoldrM :: forall e s m. Monad m => (s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
sunfoldrM :: forall e s (m :: * -> *).
Monad m =>
(s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
sunfoldrM s -> m (Maybe (e, s))
f = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e))
-> (s -> Steps m e) -> s -> m (Vector DS e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> m (Maybe (e, s))) -> s -> Steps m e
forall (m :: * -> *) s e.
Monad m =>
(s -> m (Maybe (e, s))) -> s -> Steps m e
S.unfoldrM s -> m (Maybe (e, s))
f
{-# INLINE sunfoldrM #-}
sunfoldrNM :: forall e s m. Monad m => Sz1 -> (s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
sunfoldrNM :: forall e s (m :: * -> *).
Monad m =>
Sz1 -> (s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
sunfoldrNM (Sz Int
n) s -> m (Maybe (e, s))
f = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e))
-> (s -> Steps m e) -> s -> m (Vector DS e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> (s -> m (Maybe (e, s))) -> s -> Steps m e
forall (m :: * -> *) s e.
Monad m =>
Int -> (s -> m (Maybe (e, s))) -> s -> Steps m e
S.unfoldrNM Int
n s -> m (Maybe (e, s))
f
{-# INLINE sunfoldrNM #-}
sunfoldrExactN :: forall e s. Sz1 -> (s -> (e, s)) -> s -> Vector DS e
sunfoldrExactN :: forall e s. Sz1 -> (s -> (e, s)) -> s -> Vector DS e
sunfoldrExactN Sz1
n s -> (e, s)
f = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> (s -> Steps Id e) -> s -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> (s -> (e, s)) -> s -> Steps Id e
forall (m :: * -> *) s a.
Monad m =>
Sz1 -> (s -> (a, s)) -> s -> Steps m a
S.unfoldrExactN Sz1
n s -> (e, s)
f
{-# INLINE sunfoldrExactN #-}
sunfoldrExactNM :: forall e s m. Monad m => Sz1 -> (s -> m (e, s)) -> s -> m (Vector DS e)
sunfoldrExactNM :: forall e s (m :: * -> *).
Monad m =>
Sz1 -> (s -> m (e, s)) -> s -> m (Vector DS e)
sunfoldrExactNM Sz1
n s -> m (e, s)
f = Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e))
-> (s -> Steps m e) -> s -> m (Vector DS e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sz1 -> (s -> m (e, s)) -> s -> Steps m e
forall (m :: * -> *) s a.
Monad m =>
Sz1 -> (s -> m (a, s)) -> s -> Steps m a
S.unfoldrExactNM Sz1
n s -> m (e, s)
f
{-# INLINE sunfoldrExactNM #-}
senumFromN
:: Num e
=> e
-> Sz1
-> Vector DS e
senumFromN :: forall e. Num e => e -> Sz1 -> Vector DS e
senumFromN e
x Sz1
n = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e) -> Steps Id e -> Array DS Int e
forall a b. (a -> b) -> a -> b
$ e -> e -> Sz1 -> Steps Id e
forall a (m :: * -> *).
(Num a, Monad m) =>
a -> a -> Sz1 -> Steps m a
S.enumFromStepN e
x e
1 Sz1
n
{-# INLINE senumFromN #-}
senumFromStepN
:: Num e
=> e
-> e
-> Sz1
-> Vector DS e
senumFromStepN :: forall e. Num e => e -> e -> Sz1 -> Vector DS e
senumFromStepN e
x e
step Sz1
n = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e) -> Steps Id e -> Array DS Int e
forall a b. (a -> b) -> a -> b
$ e -> e -> Sz1 -> Steps Id e
forall a (m :: * -> *).
(Num a, Monad m) =>
a -> a -> Sz1 -> Steps m a
S.enumFromStepN e
x e
step Sz1
n
{-# INLINE senumFromStepN #-}
sappend
:: forall r1 r2 e
. (Stream r1 Ix1 e, Stream r2 Ix1 e)
=> Vector r1 e
-> Vector r2 e
-> Vector DS e
sappend :: forall r1 r2 e.
(Stream r1 Int e, Stream r2 Int e) =>
Vector r1 e -> Vector r2 e -> Vector DS e
sappend Vector r1 e
a1 Vector r2 e
a2 = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Vector r1 e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream Vector r1 e
a1 Steps Id e -> Steps Id e -> Steps Id e
forall (m :: * -> *) e.
Monad m =>
Steps m e -> Steps m e -> Steps m e
`S.append` Vector r2 e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream Vector r2 e
a2)
{-# INLINE sappend #-}
sconcat :: forall r e. Stream r Ix1 e => [Vector r e] -> Vector DS e
sconcat :: forall r e. Stream r Int e => [Vector r e] -> Vector DS e
sconcat = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> ([Vector r e] -> Steps Id e) -> [Vector r e] -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector r e -> Steps Id e) -> [Vector r e] -> Steps Id e
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Vector r e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sconcat #-}
sfromList :: [e] -> Vector DS e
sfromList :: forall e. [e] -> Vector DS e
sfromList = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> ([e] -> Steps Id e) -> [e] -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [e] -> Steps Id e
forall (m :: * -> *) e. Monad m => [e] -> Steps m e
S.fromList
{-# INLINE sfromList #-}
sfromListN :: Sz1 -> [e] -> Vector DS e
sfromListN :: forall e. Sz1 -> [e] -> Vector DS e
sfromListN (Sz Int
n) = Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e)
-> ([e] -> Steps Id e) -> [e] -> Vector DS e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [e] -> Steps Id e
forall (m :: * -> *) e. Monad m => Int -> [e] -> Steps m e
S.fromListN Int
n
{-# INLINE sfromListN #-}
stoList :: forall r ix e. Stream r ix e => Array r ix e -> [e]
stoList :: forall r ix e. Stream r ix e => Array r ix e -> [e]
stoList = Steps Id e -> [e]
forall e. Steps Id e -> [e]
S.toList (Steps Id e -> [e])
-> (Array r ix e -> Steps Id e) -> Array r ix e -> [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE stoList #-}
sfilter :: forall r ix e. S.Stream r ix e => (e -> Bool) -> Array r ix e -> Vector DS e
sfilter :: forall r ix e.
Stream r ix e =>
(e -> Bool) -> Array r ix e -> Vector DS e
sfilter e -> Bool
f = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Bool) -> Steps Id e -> Steps Id e
forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> Steps m a -> Steps m a
S.filter e -> Bool
f (Steps Id e -> Steps Id e)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE sfilter #-}
sifilter :: forall r ix e. Stream r ix e => (ix -> e -> Bool) -> Array r ix e -> Vector DS e
sifilter :: forall r ix e.
Stream r ix e =>
(ix -> e -> Bool) -> Array r ix e -> Vector DS e
sifilter ix -> e -> Bool
f =
(ix -> e -> Maybe e) -> Array r ix e -> Vector DS e
forall r ix a b.
Stream r ix a =>
(ix -> a -> Maybe b) -> Array r ix a -> Vector DS b
simapMaybe ((ix -> e -> Maybe e) -> Array r ix e -> Vector DS e)
-> (ix -> e -> Maybe e) -> Array r ix e -> Vector DS e
forall a b. (a -> b) -> a -> b
$ \ix
ix e
e ->
if ix -> e -> Bool
f ix
ix e
e
then e -> Maybe e
forall a. a -> Maybe a
Just e
e
else Maybe e
forall a. Maybe a
Nothing
{-# INLINE sifilter #-}
sfilterM
:: forall r ix e f
. (S.Stream r ix e, Applicative f)
=> (e -> f Bool)
-> Array r ix e
-> f (Vector DS e)
sfilterM :: forall r ix e (f :: * -> *).
(Stream r ix e, Applicative f) =>
(e -> f Bool) -> Array r ix e -> f (Vector DS e)
sfilterM e -> f Bool
f Array r ix e
arr = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> f (Steps Id e) -> f (Array DS Int e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (e -> f Bool) -> Steps Id e -> f (Steps Id e)
forall (m :: * -> *) (f :: * -> *) e.
(Monad m, Applicative f) =>
(e -> f Bool) -> Steps Id e -> f (Steps m e)
S.filterA e -> f Bool
f (Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Array r ix e
arr)
{-# INLINE sfilterM #-}
sifilterM
:: forall r ix e f
. (Stream r ix e, Applicative f)
=> (ix -> e -> f Bool)
-> Array r ix e
-> f (Vector DS e)
sifilterM :: forall r ix e (f :: * -> *).
(Stream r ix e, Applicative f) =>
(ix -> e -> f Bool) -> Array r ix e -> f (Vector DS e)
sifilterM ix -> e -> f Bool
f =
(ix -> e -> f (Maybe e)) -> Array r ix e -> f (Vector DS e)
forall r ix a b (f :: * -> *).
(Stream r ix a, Applicative f) =>
(ix -> a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
simapMaybeM ((ix -> e -> f (Maybe e)) -> Array r ix e -> f (Vector DS e))
-> (ix -> e -> f (Maybe e)) -> Array r ix e -> f (Vector DS e)
forall a b. (a -> b) -> a -> b
$ \ix
ix e
e ->
( \Bool
p ->
if Bool
p
then e -> Maybe e
forall a. a -> Maybe a
Just e
e
else Maybe e
forall a. Maybe a
Nothing
)
(Bool -> Maybe e) -> f Bool -> f (Maybe e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ix -> e -> f Bool
f ix
ix e
e
{-# INLINE sifilterM #-}
smapMaybe :: forall r ix a b. S.Stream r ix a => (a -> Maybe b) -> Array r ix a -> Vector DS b
smapMaybe :: forall r ix a b.
Stream r ix a =>
(a -> Maybe b) -> Array r ix a -> Vector DS b
smapMaybe a -> Maybe b
f = Steps Id b -> Array DS Int b
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id b -> Array DS Int b)
-> (Array r ix a -> Steps Id b) -> Array r ix a -> Array DS Int b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Maybe b) -> Steps Id a -> Steps Id b
forall (m :: * -> *) a e.
Monad m =>
(a -> Maybe e) -> Steps m a -> Steps m e
S.mapMaybe a -> Maybe b
f (Steps Id a -> Steps Id b)
-> (Array r ix a -> Steps Id a) -> Array r ix a -> Steps Id b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE smapMaybe #-}
simapMaybe
:: forall r ix a b
. Stream r ix a
=> (ix -> a -> Maybe b)
-> Array r ix a
-> Vector DS b
simapMaybe :: forall r ix a b.
Stream r ix a =>
(ix -> a -> Maybe b) -> Array r ix a -> Vector DS b
simapMaybe ix -> a -> Maybe b
f = Steps Id b -> Array DS Int b
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id b -> Array DS Int b)
-> (Array r ix a -> Steps Id b) -> Array r ix a -> Array DS Int b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ix, a) -> Maybe b) -> Steps Id (ix, a) -> Steps Id b
forall (m :: * -> *) a e.
Monad m =>
(a -> Maybe e) -> Steps m a -> Steps m e
S.mapMaybe ((ix -> a -> Maybe b) -> (ix, a) -> Maybe b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> Maybe b
f) (Steps Id (ix, a) -> Steps Id b)
-> (Array r ix a -> Steps Id (ix, a)) -> Array r ix a -> Steps Id b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
toStreamIx
{-# INLINE simapMaybe #-}
simapMaybeM
:: forall r ix a b f
. (Stream r ix a, Applicative f)
=> (ix -> a -> f (Maybe b))
-> Array r ix a
-> f (Vector DS b)
simapMaybeM :: forall r ix a b (f :: * -> *).
(Stream r ix a, Applicative f) =>
(ix -> a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
simapMaybeM ix -> a -> f (Maybe b)
f = (Steps Id b -> Vector DS b) -> f (Steps Id b) -> f (Vector DS b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
DSArray (f (Steps Id b) -> f (Vector DS b))
-> (Array r ix a -> f (Steps Id b))
-> Array r ix a
-> f (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ix, a) -> f (Maybe b)) -> Steps Id (ix, a) -> f (Steps Id b)
forall (m :: * -> *) (f :: * -> *) a e.
(Monad m, Applicative f) =>
(a -> f (Maybe e)) -> Steps Id a -> f (Steps m e)
S.mapMaybeA ((ix -> a -> f (Maybe b)) -> (ix, a) -> f (Maybe b)
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> f (Maybe b)
f) (Steps Id (ix, a) -> f (Steps Id b))
-> (Array r ix a -> Steps Id (ix, a))
-> Array r ix a
-> f (Steps Id b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
toStreamIx
{-# INLINE simapMaybeM #-}
scatMaybes :: forall r ix a. S.Stream r ix (Maybe a) => Array r ix (Maybe a) -> Vector DS a
scatMaybes :: forall r ix a.
Stream r ix (Maybe a) =>
Array r ix (Maybe a) -> Vector DS a
scatMaybes = (Maybe a -> Maybe a) -> Array r ix (Maybe a) -> Vector DS a
forall r ix a b.
Stream r ix a =>
(a -> Maybe b) -> Array r ix a -> Vector DS b
smapMaybe Maybe a -> Maybe a
forall a. a -> a
id
{-# INLINE scatMaybes #-}
smapMaybeM
:: forall r ix a b f
. (S.Stream r ix a, Applicative f)
=> (a -> f (Maybe b))
-> Array r ix a
-> f (Vector DS b)
smapMaybeM :: forall r ix a b (f :: * -> *).
(Stream r ix a, Applicative f) =>
(a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
smapMaybeM a -> f (Maybe b)
f = (Steps Id b -> Vector DS b) -> f (Steps Id b) -> f (Vector DS b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
DSArray (f (Steps Id b) -> f (Vector DS b))
-> (Array r ix a -> f (Steps Id b))
-> Array r ix a
-> f (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f (Maybe b)) -> Steps Id a -> f (Steps Id b)
forall (m :: * -> *) (f :: * -> *) a e.
(Monad m, Applicative f) =>
(a -> f (Maybe e)) -> Steps Id a -> f (Steps m e)
S.mapMaybeA a -> f (Maybe b)
f (Steps Id a -> f (Steps Id b))
-> (Array r ix a -> Steps Id a) -> Array r ix a -> f (Steps Id b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE smapMaybeM #-}
smap
:: forall r ix a b
. S.Stream r ix a
=> (a -> b)
-> Array r ix a
-> Vector DS b
smap :: forall r ix a b.
Stream r ix a =>
(a -> b) -> Array r ix a -> Vector DS b
smap a -> b
f = Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id b -> Vector DS b)
-> (Array r ix a -> Steps Id b) -> Array r ix a -> Vector DS b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> Steps Id a -> Steps Id b
forall (m :: * -> *) e a.
Monad m =>
(e -> a) -> Steps m e -> Steps m a
S.map a -> b
f (Steps Id a -> Steps Id b)
-> (Array r ix a -> Steps Id a) -> Array r ix a -> Steps Id b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE smap #-}
simap
:: forall r ix a b
. S.Stream r ix a
=> (ix -> a -> b)
-> Array r ix a
-> Vector DS b
simap :: forall r ix a b.
Stream r ix a =>
(ix -> a -> b) -> Array r ix a -> Vector DS b
simap ix -> a -> b
f = Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id b -> Vector DS b)
-> (Array r ix a -> Steps Id b) -> Array r ix a -> Vector DS b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ix, a) -> b) -> Steps Id (ix, a) -> Steps Id b
forall (m :: * -> *) e a.
Monad m =>
(e -> a) -> Steps m e -> Steps m a
S.map ((ix -> a -> b) -> (ix, a) -> b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> b
f) (Steps Id (ix, a) -> Steps Id b)
-> (Array r ix a -> Steps Id (ix, a)) -> Array r ix a -> Steps Id b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx
{-# INLINE simap #-}
straverse
:: forall r ix a b f
. (S.Stream r ix a, Applicative f)
=> (a -> f b)
-> Array r ix a
-> f (Vector DS b)
straverse :: forall r ix a b (f :: * -> *).
(Stream r ix a, Applicative f) =>
(a -> f b) -> Array r ix a -> f (Vector DS b)
straverse a -> f b
f = (Steps Id b -> Vector DS b) -> f (Steps Id b) -> f (Vector DS b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
fromSteps (f (Steps Id b) -> f (Vector DS b))
-> (Array r ix a -> f (Steps Id b))
-> Array r ix a
-> f (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f b) -> Steps Id a -> f (Steps Id b)
forall (m :: * -> *) (f :: * -> *) e a.
(Monad m, Applicative f) =>
(e -> f a) -> Steps Id e -> f (Steps m a)
S.traverse a -> f b
f (Steps Id a -> f (Steps Id b))
-> (Array r ix a -> Steps Id a) -> Array r ix a -> f (Steps Id b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE straverse #-}
sitraverse
:: forall r ix a b f
. (S.Stream r ix a, Applicative f)
=> (ix -> a -> f b)
-> Array r ix a
-> f (Vector DS b)
sitraverse :: forall r ix a b (f :: * -> *).
(Stream r ix a, Applicative f) =>
(ix -> a -> f b) -> Array r ix a -> f (Vector DS b)
sitraverse ix -> a -> f b
f = (Steps Id b -> Vector DS b) -> f (Steps Id b) -> f (Vector DS b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Steps Id b -> Vector DS b
forall e. Steps Id e -> Vector DS e
fromSteps (f (Steps Id b) -> f (Vector DS b))
-> (Array r ix a -> f (Steps Id b))
-> Array r ix a
-> f (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ix, a) -> f b) -> Steps Id (ix, a) -> f (Steps Id b)
forall (m :: * -> *) (f :: * -> *) e a.
(Monad m, Applicative f) =>
(e -> f a) -> Steps Id e -> f (Steps m a)
S.traverse ((ix -> a -> f b) -> (ix, a) -> f b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> f b
f) (Steps Id (ix, a) -> f (Steps Id b))
-> (Array r ix a -> Steps Id (ix, a))
-> Array r ix a
-> f (Steps Id b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx
{-# INLINE sitraverse #-}
smapM
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> (a -> m b)
-> Array r ix a
-> m (Vector DS b)
smapM :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(a -> m b) -> Array r ix a -> m (Vector DS b)
smapM a -> m b
f = Steps m b -> m (Vector DS b)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m b -> m (Vector DS b))
-> (Array r ix a -> Steps m b) -> Array r ix a -> m (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> m b) -> Steps m a -> Steps m b
forall (m :: * -> *) e a.
Monad m =>
(e -> m a) -> Steps m e -> Steps m a
S.mapM a -> m b
f (Steps m a -> Steps m b)
-> (Array r ix a -> Steps m a) -> Array r ix a -> Steps m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id a -> Steps m a
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id a -> Steps m a)
-> (Array r ix a -> Steps Id a) -> Array r ix a -> Steps m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE smapM #-}
simapM
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> (ix -> a -> m b)
-> Array r ix a
-> m (Vector DS b)
simapM :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(ix -> a -> m b) -> Array r ix a -> m (Vector DS b)
simapM ix -> a -> m b
f = Steps m b -> m (Vector DS b)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m b -> m (Vector DS b))
-> (Array r ix a -> Steps m b) -> Array r ix a -> m (Vector DS b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ix, a) -> m b) -> Steps m (ix, a) -> Steps m b
forall (m :: * -> *) e a.
Monad m =>
(e -> m a) -> Steps m e -> Steps m a
S.mapM ((ix -> a -> m b) -> (ix, a) -> m b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> m b
f) (Steps m (ix, a) -> Steps m b)
-> (Array r ix a -> Steps m (ix, a)) -> Array r ix a -> Steps m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id (ix, a) -> Steps m (ix, a)
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id (ix, a) -> Steps m (ix, a))
-> (Array r ix a -> Steps Id (ix, a))
-> Array r ix a
-> Steps m (ix, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx
{-# INLINE simapM #-}
smapM_
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> (a -> m b)
-> Array r ix a
-> m ()
smapM_ :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(a -> m b) -> Array r ix a -> m ()
smapM_ a -> m b
f = (a -> m b) -> Steps m a -> m ()
forall (m :: * -> *) e a.
Monad m =>
(e -> m a) -> Steps m e -> m ()
S.mapM_ a -> m b
f (Steps m a -> m ())
-> (Array r ix a -> Steps m a) -> Array r ix a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id a -> Steps m a
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id a -> Steps m a)
-> (Array r ix a -> Steps Id a) -> Array r ix a -> Steps m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream
{-# INLINE smapM_ #-}
simapM_
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> (ix -> a -> m b)
-> Array r ix a
-> m ()
simapM_ :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(ix -> a -> m b) -> Array r ix a -> m ()
simapM_ ix -> a -> m b
f = ((ix, a) -> m b) -> Steps m (ix, a) -> m ()
forall (m :: * -> *) e a.
Monad m =>
(e -> m a) -> Steps m e -> m ()
S.mapM_ ((ix -> a -> m b) -> (ix, a) -> m b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ix -> a -> m b
f) (Steps m (ix, a) -> m ())
-> (Array r ix a -> Steps m (ix, a)) -> Array r ix a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id (ix, a) -> Steps m (ix, a)
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id (ix, a) -> Steps m (ix, a))
-> (Array r ix a -> Steps Id (ix, a))
-> Array r ix a
-> Steps m (ix, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix a -> Steps Id (ix, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx
{-# INLINE simapM_ #-}
sforM
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> Array r ix a
-> (a -> m b)
-> m (Vector DS b)
sforM :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
Array r ix a -> (a -> m b) -> m (Vector DS b)
sforM = ((a -> m b) -> Array r ix a -> m (Vector DS b))
-> Array r ix a -> (a -> m b) -> m (Vector DS b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> m b) -> Array r ix a -> m (Vector DS b)
forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(a -> m b) -> Array r ix a -> m (Vector DS b)
smapM
{-# INLINE sforM #-}
siforM
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> Array r ix a
-> (ix -> a -> m b)
-> m (Vector DS b)
siforM :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
Array r ix a -> (ix -> a -> m b) -> m (Vector DS b)
siforM = ((ix -> a -> m b) -> Array r ix a -> m (Vector DS b))
-> Array r ix a -> (ix -> a -> m b) -> m (Vector DS b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (ix -> a -> m b) -> Array r ix a -> m (Vector DS b)
forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(ix -> a -> m b) -> Array r ix a -> m (Vector DS b)
simapM
{-# INLINE siforM #-}
sforM_ :: (S.Stream r ix a, Monad m) => Array r ix a -> (a -> m b) -> m ()
sforM_ :: forall r ix a (m :: * -> *) b.
(Stream r ix a, Monad m) =>
Array r ix a -> (a -> m b) -> m ()
sforM_ = ((a -> m b) -> Array r ix a -> m ())
-> Array r ix a -> (a -> m b) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> m b) -> Array r ix a -> m ()
forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(a -> m b) -> Array r ix a -> m ()
smapM_
{-# INLINE sforM_ #-}
siforM_
:: forall r ix a b m
. (S.Stream r ix a, Monad m)
=> Array r ix a
-> (ix -> a -> m b)
-> m ()
siforM_ :: forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
Array r ix a -> (ix -> a -> m b) -> m ()
siforM_ = ((ix -> a -> m b) -> Array r ix a -> m ())
-> Array r ix a -> (ix -> a -> m b) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip (ix -> a -> m b) -> Array r ix a -> m ()
forall r ix a b (m :: * -> *).
(Stream r ix a, Monad m) =>
(ix -> a -> m b) -> Array r ix a -> m ()
simapM_
{-# INLINE siforM_ #-}
szip
:: forall ra rb a b
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b)
=> Vector ra a
-> Vector rb b
-> Vector DS (a, b)
szip :: forall ra rb a b.
(Stream ra Int a, Stream rb Int b) =>
Vector ra a -> Vector rb b -> Vector DS (a, b)
szip = (a -> b -> (a, b))
-> Vector ra a -> Vector rb b -> Vector DS (a, b)
forall ra rb a b c.
(Stream ra Int a, Stream rb Int b) =>
(a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c
szipWith (,)
{-# INLINE szip #-}
szip3
:: forall ra rb rc a b c
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c)
=> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector DS (a, b, c)
szip3 :: forall ra rb rc a b c.
(Stream ra Int a, Stream rb Int b, Stream rc Int c) =>
Vector ra a -> Vector rb b -> Vector rc c -> Vector DS (a, b, c)
szip3 = (a -> b -> c -> (a, b, c))
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS (a, b, c)
forall ra rb rc a b c d.
(Stream ra Int a, Stream rb Int b, Stream rc Int c) =>
(a -> b -> c -> d)
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d
szipWith3 (,,)
{-# INLINE szip3 #-}
szip4
:: forall ra rb rc rd a b c d
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d)
=> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS (a, b, c, d)
szip4 :: forall ra rb rc rd a b c d.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d) =>
Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS (a, b, c, d)
szip4 = (a -> b -> c -> d -> (a, b, c, d))
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS (a, b, c, d)
forall ra rb rc rd a b c d e.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d) =>
(a -> b -> c -> d -> e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS e
szipWith4 (,,,)
{-# INLINE szip4 #-}
szip5
:: forall ra rb rc rd re a b c d e
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, S.Stream re Ix1 e)
=> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS (a, b, c, d, e)
szip5 :: forall ra rb rc rd re a b c d e.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e) =>
Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS (a, b, c, d, e)
szip5 = (a -> b -> c -> d -> e -> (a, b, c, d, e))
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS (a, b, c, d, e)
forall ra rb rc rd re a b c d e f.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e) =>
(a -> b -> c -> d -> e -> f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS f
szipWith5 (,,,,)
{-# INLINE szip5 #-}
szip6
:: forall ra rb rc rd re rf a b c d e f
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
)
=> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS (a, b, c, d, e, f)
szip6 :: forall ra rb rc rd re rf a b c d e f.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f) =>
Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS (a, b, c, d, e, f)
szip6 = (a -> b -> c -> d -> e -> f -> (a, b, c, d, e, f))
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS (a, b, c, d, e, f)
forall ra rb rc rd re rf a b c d e f g.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f) =>
(a -> b -> c -> d -> e -> f -> g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS g
szipWith6 (,,,,,)
{-# INLINE szip6 #-}
szipWith
:: forall ra rb a b c
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b)
=> (a -> b -> c)
-> Vector ra a
-> Vector rb b
-> Vector DS c
szipWith :: forall ra rb a b c.
(Stream ra Int a, Stream rb Int b) =>
(a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c
szipWith a -> b -> c
f Vector ra a
v1 Vector rb b
v2 = Steps Id c -> Vector DS c
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id c -> Vector DS c) -> Steps Id c -> Vector DS c
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> Steps Id a -> Steps Id b -> Steps Id c
forall (m :: * -> *) a b e.
Monad m =>
(a -> b -> e) -> Steps m a -> Steps m b -> Steps m e
S.zipWith a -> b -> c
f (Vector ra a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2)
{-# INLINE szipWith #-}
szipWith3
:: forall ra rb rc a b c d
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c)
=> (a -> b -> c -> d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector DS d
szipWith3 :: forall ra rb rc a b c d.
(Stream ra Int a, Stream rb Int b, Stream rc Int c) =>
(a -> b -> c -> d)
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d
szipWith3 a -> b -> c -> d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 = Steps Id d -> Vector DS d
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id d -> Vector DS d) -> Steps Id d -> Vector DS d
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d)
-> Steps Id a -> Steps Id b -> Steps Id c -> Steps Id d
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> d)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d
S.zipWith3 a -> b -> c -> d
f (Vector ra a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2) (Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3)
{-# INLINE szipWith3 #-}
szipWith4
:: forall ra rb rc rd a b c d e
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d)
=> (a -> b -> c -> d -> e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS e
szipWith4 :: forall ra rb rc rd a b c d e.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d) =>
(a -> b -> c -> d -> e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS e
szipWith4 a -> b -> c -> d -> e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e) -> Steps Id e -> Vector DS e
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> e)
-> Steps Id a
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> Steps m e
S.zipWith4 a -> b -> c -> d -> e
f (Vector ra a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2) (Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3) (Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4)
{-# INLINE szipWith4 #-}
szipWith5
:: forall ra rb rc rd re a b c d e f
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, S.Stream re Ix1 e)
=> (a -> b -> c -> d -> e -> f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS f
szipWith5 :: forall ra rb rc rd re a b c d e f.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e) =>
(a -> b -> c -> d -> e -> f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS f
szipWith5 a -> b -> c -> d -> e -> f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
Steps Id f -> Vector DS f
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id f -> Vector DS f) -> Steps Id f -> Vector DS f
forall a b. (a -> b) -> a -> b
$
(a -> b -> c -> d -> e -> f)
-> Steps Id a
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
-> Steps Id f
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
S.zipWith5 a -> b -> c -> d -> e -> f
f (Vector ra a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2) (Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3) (Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4) (Vector re e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector re e
v5)
{-# INLINE szipWith5 #-}
szipWith6
:: forall ra rb rc rd re rf a b c d e f g
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
)
=> (a -> b -> c -> d -> e -> f -> g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS g
szipWith6 :: forall ra rb rc rd re rf a b c d e f g.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f) =>
(a -> b -> c -> d -> e -> f -> g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS g
szipWith6 a -> b -> c -> d -> e -> f -> g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
Steps Id g -> Vector DS g
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id g -> Vector DS g) -> Steps Id g -> Vector DS g
forall a b. (a -> b) -> a -> b
$
(a -> b -> c -> d -> e -> f -> g)
-> Steps Id a
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
-> Steps Id f
-> Steps Id g
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
S.zipWith6
a -> b -> c -> d -> e -> f -> g
f
(Vector ra a -> Steps Id a
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector ra a
v1)
(Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2)
(Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3)
(Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4)
(Vector re e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector re e
v5)
(Vector rf f -> Steps Id f
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rf f
v6)
{-# INLINE szipWith6 #-}
sizipWith
:: forall ra rb a b c
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b)
=> (Ix1 -> a -> b -> c)
-> Vector ra a
-> Vector rb b
-> Vector DS c
sizipWith :: forall ra rb a b c.
(Stream ra Int a, Stream rb Int b) =>
(Int -> a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c
sizipWith Int -> a -> b -> c
f Vector ra a
v1 Vector rb b
v2 = Steps Id c -> Vector DS c
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id c -> Vector DS c) -> Steps Id c -> Vector DS c
forall a b. (a -> b) -> a -> b
$ ((Int, a) -> b -> c)
-> Steps Id (Int, a) -> Steps Id b -> Steps Id c
forall (m :: * -> *) a b e.
Monad m =>
(a -> b -> e) -> Steps m a -> Steps m b -> Steps m e
S.zipWith ((Int -> a -> b -> c) -> (Int, a) -> b -> c
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c
f) (Vector ra a -> Steps Id (Int, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2)
{-# INLINE sizipWith #-}
sizipWith3
:: forall ra rb rc a b c d
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c)
=> (Ix1 -> a -> b -> c -> d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector DS d
sizipWith3 :: forall ra rb rc a b c d.
(Stream ra Int a, Stream rb Int b, Stream rc Int c) =>
(Int -> a -> b -> c -> d)
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d
sizipWith3 Int -> a -> b -> c -> d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 =
Steps Id d -> Vector DS d
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id d -> Vector DS d) -> Steps Id d -> Vector DS d
forall a b. (a -> b) -> a -> b
$ ((Int, a) -> b -> c -> d)
-> Steps Id (Int, a) -> Steps Id b -> Steps Id c -> Steps Id d
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> d)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d
S.zipWith3 ((Int -> a -> b -> c -> d) -> (Int, a) -> b -> c -> d
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d
f) (Vector ra a -> Steps Id (Int, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2) (Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3)
{-# INLINE sizipWith3 #-}
sizipWith4
:: forall ra rb rc rd a b c d e
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d)
=> (Ix1 -> a -> b -> c -> d -> e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS e
sizipWith4 :: forall ra rb rc rd a b c d e.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d) =>
(Int -> a -> b -> c -> d -> e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector DS e
sizipWith4 Int -> a -> b -> c -> d -> e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
Steps Id e -> Vector DS e
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id e -> Vector DS e) -> Steps Id e -> Vector DS e
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> e)
-> Steps Id (Int, a)
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> Steps m e
S.zipWith4 ((Int -> a -> b -> c -> d -> e) -> (Int, a) -> b -> c -> d -> e
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e
f) (Vector ra a -> Steps Id (Int, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx Vector ra a
v1) (Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2) (Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3) (Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4)
{-# INLINE sizipWith4 #-}
sizipWith5
:: forall ra rb rc rd re a b c d e f
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, S.Stream re Ix1 e)
=> (Ix1 -> a -> b -> c -> d -> e -> f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS f
sizipWith5 :: forall ra rb rc rd re a b c d e f.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e) =>
(Int -> a -> b -> c -> d -> e -> f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector DS f
sizipWith5 Int -> a -> b -> c -> d -> e -> f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
Steps Id f -> Vector DS f
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id f -> Vector DS f) -> Steps Id f -> Vector DS f
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> e -> f)
-> Steps Id (Int, a)
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
-> Steps Id f
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
S.zipWith5
((Int -> a -> b -> c -> d -> e -> f)
-> (Int, a) -> b -> c -> d -> e -> f
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> f
f)
(Vector ra a -> Steps Id (Int, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx Vector ra a
v1)
(Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2)
(Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3)
(Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4)
(Vector re e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector re e
v5)
{-# INLINE sizipWith5 #-}
sizipWith6
:: forall ra rb rc rd re rf a b c d e f g
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
)
=> (Ix1 -> a -> b -> c -> d -> e -> f -> g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS g
sizipWith6 :: forall ra rb rc rd re rf a b c d e f g.
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f) =>
(Int -> a -> b -> c -> d -> e -> f -> g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> Vector DS g
sizipWith6 Int -> a -> b -> c -> d -> e -> f -> g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
Steps Id g -> Vector DS g
forall e. Steps Id e -> Vector DS e
fromSteps (Steps Id g -> Vector DS g) -> Steps Id g -> Vector DS g
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> e -> f -> g)
-> Steps Id (Int, a)
-> Steps Id b
-> Steps Id c
-> Steps Id d
-> Steps Id e
-> Steps Id f
-> Steps Id g
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
S.zipWith6
((Int -> a -> b -> c -> d -> e -> f -> g)
-> (Int, a) -> b -> c -> d -> e -> f -> g
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> f -> g
f)
(Vector ra a -> Steps Id (Int, a)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
S.toStreamIx Vector ra a
v1)
(Vector rb b -> Steps Id b
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rb b
v2)
(Vector rc c -> Steps Id c
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rc c
v3)
(Vector rd d -> Steps Id d
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rd d
v4)
(Vector re e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector re e
v5)
(Vector rf f -> Steps Id f
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
S.toStream Vector rf f
v6)
{-# INLINE sizipWith6 #-}
szipWithM
:: forall ra rb a b c m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, Monad m)
=> (a -> b -> m c)
-> Vector ra a
-> Vector rb b
-> m (Vector DS c)
szipWithM :: forall ra rb a b c (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Monad m) =>
(a -> b -> m c) -> Vector ra a -> Vector rb b -> m (Vector DS c)
szipWithM a -> b -> m c
f Vector ra a
v1 Vector rb b
v2 = Steps m c -> m (Vector DS c)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m c -> m (Vector DS c)) -> Steps m c -> m (Vector DS c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> m c) -> Steps m a -> Steps m b -> Steps m c
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> Steps m a -> Steps m b -> Steps m c
S.zipWithM a -> b -> m c
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
{-# INLINE szipWithM #-}
szipWith3M
:: forall ra rb rc a b c d m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, Monad m)
=> (a -> b -> c -> m d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> m (Vector DS d)
szipWith3M :: forall ra rb rc a b c d (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c, Monad m) =>
(a -> b -> c -> m d)
-> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d)
szipWith3M a -> b -> c -> m d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 = Steps m d -> m (Vector DS d)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m d -> m (Vector DS d)) -> Steps m d -> m (Vector DS d)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> m d)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> m d)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d
S.zipWith3M a -> b -> c -> m d
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
{-# INLINE szipWith3M #-}
szipWith4M
:: forall ra rb rc rd a b c d e m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, Monad m)
=> (a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m (Vector DS e)
szipWith4M :: forall ra rb rc rd a b c d e (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Monad m) =>
(a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m (Vector DS e)
szipWith4M a -> b -> c -> d -> m e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e)) -> Steps m e -> m (Vector DS e)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> Steps m e
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> Steps m e
S.zipWith4M a -> b -> c -> d -> m e
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
{-# INLINE szipWith4M #-}
szipWith5M
:: forall ra rb rc rd re a b c d e f m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, Monad m
)
=> (a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m (Vector DS f)
szipWith5M :: forall ra rb rc rd re a b c d e f (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Monad m) =>
(a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m (Vector DS f)
szipWith5M a -> b -> c -> d -> e -> m f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
Steps m f -> m (Vector DS f)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m f -> m (Vector DS f)) -> Steps m f -> m (Vector DS f)
forall a b. (a -> b) -> a -> b
$
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
S.zipWith5M a -> b -> c -> d -> e -> m f
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4) (Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
{-# INLINE szipWith5M #-}
szipWith6M
:: forall ra rb rc rd re rf a b c d e f g m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
, Monad m
)
=> (a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m (Vector DS g)
szipWith6M :: forall ra rb rc rd re rf a b c d e f g (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f, Monad m) =>
(a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m (Vector DS g)
szipWith6M a -> b -> c -> d -> e -> f -> m g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
Steps m g -> m (Vector DS g)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m g -> m (Vector DS g)) -> Steps m g -> m (Vector DS g)
forall a b. (a -> b) -> a -> b
$
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
S.zipWith6M
a -> b -> c -> d -> e -> f -> m g
f
(Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
(Vector rf f -> Steps m f
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rf f
v6)
{-# INLINE szipWith6M #-}
sizipWithM
:: forall ra rb a b c m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, Monad m)
=> (Ix1 -> a -> b -> m c)
-> Vector ra a
-> Vector rb b
-> m (Vector DS c)
sizipWithM :: forall ra rb a b c (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Monad m) =>
(Int -> a -> b -> m c)
-> Vector ra a -> Vector rb b -> m (Vector DS c)
sizipWithM Int -> a -> b -> m c
f Vector ra a
v1 Vector rb b
v2 = Steps m c -> m (Vector DS c)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m c -> m (Vector DS c)) -> Steps m c -> m (Vector DS c)
forall a b. (a -> b) -> a -> b
$ ((Int, a) -> b -> m c)
-> Steps m (Int, a) -> Steps m b -> Steps m c
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> Steps m a -> Steps m b -> Steps m c
S.zipWithM ((Int -> a -> b -> m c) -> (Int, a) -> b -> m c
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> m c
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
{-# INLINE sizipWithM #-}
sizipWith3M
:: forall ra rb rc a b c d m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, Monad m)
=> (Ix1 -> a -> b -> c -> m d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> m (Vector DS d)
sizipWith3M :: forall ra rb rc a b c d (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c, Monad m) =>
(Int -> a -> b -> c -> m d)
-> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d)
sizipWith3M Int -> a -> b -> c -> m d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 =
Steps m d -> m (Vector DS d)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m d -> m (Vector DS d)) -> Steps m d -> m (Vector DS d)
forall a b. (a -> b) -> a -> b
$ ((Int, a) -> b -> c -> m d)
-> Steps m (Int, a) -> Steps m b -> Steps m c -> Steps m d
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> m d)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d
S.zipWith3M ((Int -> a -> b -> c -> m d) -> (Int, a) -> b -> c -> m d
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> m d
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
{-# INLINE sizipWith3M #-}
sizipWith4M
:: forall ra rb rc rd a b c d e m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, Monad m)
=> (Ix1 -> a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m (Vector DS e)
sizipWith4M :: forall ra rb rc rd a b c d e (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Monad m) =>
(Int -> a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m (Vector DS e)
sizipWith4M Int -> a -> b -> c -> d -> m e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
Steps m e -> m (Vector DS e)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m e -> m (Vector DS e)) -> Steps m e -> m (Vector DS e)
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> m e)
-> Steps m (Int, a)
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> Steps m e
S.zipWith4M ((Int -> a -> b -> c -> d -> m e) -> (Int, a) -> b -> c -> d -> m e
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> m e
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
{-# INLINE sizipWith4M #-}
sizipWith5M
:: forall ra rb rc rd re a b c d e f m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, Monad m
)
=> (Ix1 -> a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m (Vector DS f)
sizipWith5M :: forall ra rb rc rd re a b c d e f (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Monad m) =>
(Int -> a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m (Vector DS f)
sizipWith5M Int -> a -> b -> c -> d -> e -> m f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
Steps m f -> m (Vector DS f)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m f -> m (Vector DS f)) -> Steps m f -> m (Vector DS f)
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> e -> m f)
-> Steps m (Int, a)
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
S.zipWith5M
((Int -> a -> b -> c -> d -> e -> m f)
-> (Int, a) -> b -> c -> d -> e -> m f
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> m f
f)
(Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
{-# INLINE sizipWith5M #-}
sizipWith6M
:: forall ra rb rc rd re rf a b c d e f g m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
, Monad m
)
=> (Ix1 -> a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m (Vector DS g)
sizipWith6M :: forall ra rb rc rd re rf a b c d e f g (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f, Monad m) =>
(Int -> a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m (Vector DS g)
sizipWith6M Int -> a -> b -> c -> d -> e -> f -> m g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
Steps m g -> m (Vector DS g)
forall (m :: * -> *) e. Monad m => Steps m e -> m (Vector DS e)
fromStepsM (Steps m g -> m (Vector DS g)) -> Steps m g -> m (Vector DS g)
forall a b. (a -> b) -> a -> b
$
((Int, a) -> b -> c -> d -> e -> f -> m g)
-> Steps m (Int, a)
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> Steps m g
S.zipWith6M
((Int -> a -> b -> c -> d -> e -> f -> m g)
-> (Int, a) -> b -> c -> d -> e -> f -> m g
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> f -> m g
f)
(Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
(Vector rf f -> Steps m f
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rf f
v6)
{-# INLINE sizipWith6M #-}
szipWithM_
:: forall ra rb a b c m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, Monad m)
=> (a -> b -> m c)
-> Vector ra a
-> Vector rb b
-> m ()
szipWithM_ :: forall ra rb a b c (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Monad m) =>
(a -> b -> m c) -> Vector ra a -> Vector rb b -> m ()
szipWithM_ a -> b -> m c
f Vector ra a
v1 Vector rb b
v2 = (a -> b -> m c) -> Steps m a -> Steps m b -> m ()
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> Steps m a -> Steps m b -> m ()
S.zipWithM_ a -> b -> m c
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
{-# INLINE szipWithM_ #-}
szipWith3M_
:: forall ra rb rc a b c d m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, Monad m)
=> (a -> b -> c -> m d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> m ()
szipWith3M_ :: forall ra rb rc a b c d (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c, Monad m) =>
(a -> b -> c -> m d)
-> Vector ra a -> Vector rb b -> Vector rc c -> m ()
szipWith3M_ a -> b -> c -> m d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 = (a -> b -> c -> m d) -> Steps m a -> Steps m b -> Steps m c -> m ()
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> m d) -> Steps m a -> Steps m b -> Steps m c -> m ()
S.zipWith3M_ a -> b -> c -> m d
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
{-# INLINE szipWith3M_ #-}
szipWith4M_
:: forall ra rb rc rd a b c d e m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, Monad m)
=> (a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m ()
szipWith4M_ :: forall ra rb rc rd a b c d e (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Monad m) =>
(a -> b -> c -> d -> m e)
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m ()
szipWith4M_ a -> b -> c -> d -> m e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
(a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> m ()
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> m ()
S.zipWith4M_ a -> b -> c -> d -> m e
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
{-# INLINE szipWith4M_ #-}
szipWith5M_
:: forall ra rb rc rd re a b c d e f m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, Monad m
)
=> (a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m ()
szipWith5M_ :: forall ra rb rc rd re a b c d e f (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Monad m) =>
(a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m ()
szipWith5M_ a -> b -> c -> d -> e -> m f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> m ()
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> m ()
S.zipWith5M_ a -> b -> c -> d -> e -> m f
f (Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4) (Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
{-# INLINE szipWith5M_ #-}
szipWith6M_
:: forall ra rb rc rd re rf a b c d e f g m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
, Monad m
)
=> (a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m ()
szipWith6M_ :: forall ra rb rc rd re rf a b c d e f g (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f, Monad m) =>
(a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m ()
szipWith6M_ a -> b -> c -> d -> e -> f -> m g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> m ()
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> m ()
S.zipWith6M_
a -> b -> c -> d -> e -> f -> m g
f
(Vector ra a -> Steps m a
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
(Vector rf f -> Steps m f
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rf f
v6)
{-# INLINE szipWith6M_ #-}
sizipWithM_
:: forall ra rb a b c m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, Monad m)
=> (Ix1 -> a -> b -> m c)
-> Vector ra a
-> Vector rb b
-> m ()
sizipWithM_ :: forall ra rb a b c (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Monad m) =>
(Int -> a -> b -> m c) -> Vector ra a -> Vector rb b -> m ()
sizipWithM_ Int -> a -> b -> m c
f Vector ra a
v1 Vector rb b
v2 = ((Int, a) -> b -> m c) -> Steps m (Int, a) -> Steps m b -> m ()
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> Steps m a -> Steps m b -> m ()
S.zipWithM_ ((Int -> a -> b -> m c) -> (Int, a) -> b -> m c
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> m c
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
{-# INLINE sizipWithM_ #-}
sizipWith3M_
:: forall ra rb rc a b c d m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, Monad m)
=> (Ix1 -> a -> b -> c -> m d)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> m ()
sizipWith3M_ :: forall ra rb rc a b c d (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c, Monad m) =>
(Int -> a -> b -> c -> m d)
-> Vector ra a -> Vector rb b -> Vector rc c -> m ()
sizipWith3M_ Int -> a -> b -> c -> m d
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 = ((Int, a) -> b -> c -> m d)
-> Steps m (Int, a) -> Steps m b -> Steps m c -> m ()
forall (m :: * -> *) a b c d.
Monad m =>
(a -> b -> c -> m d) -> Steps m a -> Steps m b -> Steps m c -> m ()
S.zipWith3M_ ((Int -> a -> b -> c -> m d) -> (Int, a) -> b -> c -> m d
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> m d
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
{-# INLINE sizipWith3M_ #-}
sizipWith4M_
:: forall ra rb rc rd a b c d e m
. (S.Stream ra Ix1 a, S.Stream rb Ix1 b, S.Stream rc Ix1 c, S.Stream rd Ix1 d, Monad m)
=> (Ix1 -> a -> b -> c -> d -> m e)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> m ()
sizipWith4M_ :: forall ra rb rc rd a b c d e (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Monad m) =>
(Int -> a -> b -> c -> d -> m e)
-> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m ()
sizipWith4M_ Int -> a -> b -> c -> d -> m e
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 =
((Int, a) -> b -> c -> d -> m e)
-> Steps m (Int, a) -> Steps m b -> Steps m c -> Steps m d -> m ()
forall (m :: * -> *) a b c d e.
Monad m =>
(a -> b -> c -> d -> m e)
-> Steps m a -> Steps m b -> Steps m c -> Steps m d -> m ()
S.zipWith4M_ ((Int -> a -> b -> c -> d -> m e) -> (Int, a) -> b -> c -> d -> m e
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> m e
f) (Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1) (Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2) (Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3) (Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
{-# INLINE sizipWith4M_ #-}
sizipWith5M_
:: forall ra rb rc rd re a b c d e f m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, Monad m
)
=> (Ix1 -> a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m ()
sizipWith5M_ :: forall ra rb rc rd re a b c d e f (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Monad m) =>
(Int -> a -> b -> c -> d -> e -> m f)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> m ()
sizipWith5M_ Int -> a -> b -> c -> d -> e -> m f
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 =
((Int, a) -> b -> c -> d -> e -> m f)
-> Steps m (Int, a)
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> m ()
forall (m :: * -> *) a b c d e f.
Monad m =>
(a -> b -> c -> d -> e -> m f)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> m ()
S.zipWith5M_
((Int -> a -> b -> c -> d -> e -> m f)
-> (Int, a) -> b -> c -> d -> e -> m f
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> m f
f)
(Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
{-# INLINE sizipWith5M_ #-}
sizipWith6M_
:: forall ra rb rc rd re rf a b c d e f g m
. ( S.Stream ra Ix1 a
, S.Stream rb Ix1 b
, S.Stream rc Ix1 c
, S.Stream rd Ix1 d
, S.Stream re Ix1 e
, S.Stream rf Ix1 f
, Monad m
)
=> (Ix1 -> a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m ()
sizipWith6M_ :: forall ra rb rc rd re rf a b c d e f g (m :: * -> *).
(Stream ra Int a, Stream rb Int b, Stream rc Int c,
Stream rd Int d, Stream re Int e, Stream rf Int f, Monad m) =>
(Int -> a -> b -> c -> d -> e -> f -> m g)
-> Vector ra a
-> Vector rb b
-> Vector rc c
-> Vector rd d
-> Vector re e
-> Vector rf f
-> m ()
sizipWith6M_ Int -> a -> b -> c -> d -> e -> f -> m g
f Vector ra a
v1 Vector rb b
v2 Vector rc c
v3 Vector rd d
v4 Vector re e
v5 Vector rf f
v6 =
((Int, a) -> b -> c -> d -> e -> f -> m g)
-> Steps m (Int, a)
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> m ()
forall (m :: * -> *) a b c d e f g.
Monad m =>
(a -> b -> c -> d -> e -> f -> m g)
-> Steps m a
-> Steps m b
-> Steps m c
-> Steps m d
-> Steps m e
-> Steps m f
-> m ()
S.zipWith6M_
((Int -> a -> b -> c -> d -> e -> f -> m g)
-> (Int, a) -> b -> c -> d -> e -> f -> m g
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> a -> b -> c -> d -> e -> f -> m g
f)
(Vector ra a -> Steps m (Int, a)
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m (ix, e)
toStreamIxM Vector ra a
v1)
(Vector rb b -> Steps m b
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rb b
v2)
(Vector rc c -> Steps m c
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rc c
v3)
(Vector rd d -> Steps m d
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rd d
v4)
(Vector re e -> Steps m e
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector re e
v5)
(Vector rf f -> Steps m f
forall r ix e (m :: * -> *).
(Stream r ix e, Monad m) =>
Array r ix e -> Steps m e
toStreamM Vector rf f
v6)
{-# INLINE sizipWith6M_ #-}
sfoldl
:: forall r ix e a
. Stream r ix e
=> (a -> e -> a)
-> a
-> Array r ix e
-> a
sfoldl :: forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> a
sfoldl a -> e -> a
f a
acc = Id a -> a
forall a. Id a -> a
S.unId (Id a -> a) -> (Array r ix e -> Id a) -> Array r ix e -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> e -> a) -> a -> Steps Id e -> Id a
forall (m :: * -> *) b a.
Monad m =>
(b -> a -> b) -> b -> Steps m a -> m b
S.foldl a -> e -> a
f a
acc (Steps Id e -> Id a)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sfoldl #-}
sfoldlM
:: forall r ix e a m
. (Stream r ix e, Monad m)
=> (a -> e -> m a)
-> a
-> Array r ix e
-> m a
sfoldlM :: forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> e -> m a) -> a -> Array r ix e -> m a
sfoldlM a -> e -> m a
f a
acc = (a -> e -> m a) -> a -> Steps m e -> m a
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Steps m b -> m a
S.foldlM a -> e -> m a
f a
acc (Steps m e -> m a)
-> (Array r ix e -> Steps m e) -> Array r ix e -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id e -> Steps m e
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id e -> Steps m e)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps m e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sfoldlM #-}
sfoldlM_
:: forall r ix e a m
. (Stream r ix e, Monad m)
=> (a -> e -> m a)
-> a
-> Array r ix e
-> m ()
sfoldlM_ :: forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> e -> m a) -> a -> Array r ix e -> m ()
sfoldlM_ a -> e -> m a
f a
acc = m a -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m a -> m ()) -> (Array r ix e -> m a) -> Array r ix e -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> e -> m a) -> a -> Array r ix e -> m a
forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> e -> m a) -> a -> Array r ix e -> m a
sfoldlM a -> e -> m a
f a
acc
{-# INLINE sfoldlM_ #-}
sfoldl1'
:: forall r ix e
. (HasCallStack, Stream r ix e)
=> (e -> e -> e)
-> Array r ix e
-> e
sfoldl1' :: forall r ix e.
(HasCallStack, Stream r ix e) =>
(e -> e -> e) -> Array r ix e -> e
sfoldl1' e -> e -> e
f = Either SomeException e -> e
forall a. HasCallStack => Either SomeException a -> a
throwEither (Either SomeException e -> e)
-> (Array r ix e -> Either SomeException e) -> Array r ix e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> e -> Either SomeException e)
-> Array r ix e -> Either SomeException e
forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m e
sfoldl1M (\e
e -> e -> Either SomeException e
forall a. a -> Either SomeException a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> Either SomeException e)
-> (e -> e) -> e -> Either SomeException e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> e -> e
f e
e)
{-# INLINE sfoldl1' #-}
sfoldl1M
:: forall r ix e m
. (Stream r ix e, MonadThrow m)
=> (e -> e -> m e)
-> Array r ix e
-> m e
sfoldl1M :: forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m e
sfoldl1M e -> e -> m e
f Array r ix e
arr = do
let str :: Steps m e
str = Steps Id e -> Steps m e
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id e -> Steps m e) -> Steps Id e -> Steps m e
forall a b. (a -> b) -> a -> b
$ Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream Array r ix e
arr
Bool
isNullStream <- Steps m e -> m Bool
forall (m :: * -> *) a. Monad m => Steps m a -> m Bool
S.null Steps m e
str
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isNullStream (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ SizeException -> m ()
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM (SizeException -> m ()) -> SizeException -> m ()
forall a b. (a -> b) -> a -> b
$ Sz ix -> SizeException
forall ix. Index ix => Sz ix -> SizeException
SizeEmptyException (Array r ix e -> Sz ix
forall e. Array r ix e -> Sz ix
forall r ix e. Shape r ix => Array r ix e -> Sz ix
outerSize Array r ix e
arr)
(e -> e -> m e) -> Steps m e -> m e
forall (m :: * -> *) a.
Monad m =>
(a -> a -> m a) -> Steps m a -> m a
S.foldl1M e -> e -> m e
f Steps m e
str
{-# INLINE sfoldl1M #-}
sfoldl1M_
:: forall r ix e m
. (Stream r ix e, MonadThrow m)
=> (e -> e -> m e)
-> Array r ix e
-> m ()
sfoldl1M_ :: forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m ()
sfoldl1M_ e -> e -> m e
f = m e -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m e -> m ()) -> (Array r ix e -> m e) -> Array r ix e -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> e -> m e) -> Array r ix e -> m e
forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m e
sfoldl1M e -> e -> m e
f
{-# INLINE sfoldl1M_ #-}
sifoldl
:: forall r ix e a
. Stream r ix e
=> (a -> ix -> e -> a)
-> a
-> Array r ix e
-> a
sifoldl :: forall r ix e a.
Stream r ix e =>
(a -> ix -> e -> a) -> a -> Array r ix e -> a
sifoldl a -> ix -> e -> a
f a
acc = Id a -> a
forall a. Id a -> a
S.unId (Id a -> a) -> (Array r ix e -> Id a) -> Array r ix e -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> (ix, e) -> a) -> a -> Steps Id (ix, e) -> Id a
forall (m :: * -> *) b a.
Monad m =>
(b -> a -> b) -> b -> Steps m a -> m b
S.foldl (\a
a (ix
ix, e
e) -> a -> ix -> e -> a
f a
a ix
ix e
e) a
acc (Steps Id (ix, e) -> Id a)
-> (Array r ix e -> Steps Id (ix, e)) -> Array r ix e -> Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id (ix, e)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
toStreamIx
{-# INLINE sifoldl #-}
sifoldlM
:: forall r ix e a m
. (Stream r ix e, Monad m)
=> (a -> ix -> e -> m a)
-> a
-> Array r ix e
-> m a
sifoldlM :: forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> ix -> e -> m a) -> a -> Array r ix e -> m a
sifoldlM a -> ix -> e -> m a
f a
acc = (a -> (ix, e) -> m a) -> a -> Steps m (ix, e) -> m a
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Steps m b -> m a
S.foldlM (\a
a (ix
ix, e
e) -> a -> ix -> e -> m a
f a
a ix
ix e
e) a
acc (Steps m (ix, e) -> m a)
-> (Array r ix e -> Steps m (ix, e)) -> Array r ix e -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id (ix, e) -> Steps m (ix, e)
forall (m :: * -> *) e. Monad m => Steps Id e -> Steps m e
S.transStepsId (Steps Id (ix, e) -> Steps m (ix, e))
-> (Array r ix e -> Steps Id (ix, e))
-> Array r ix e
-> Steps m (ix, e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id (ix, e)
forall r ix e. Stream r ix e => Array r ix e -> Steps Id (ix, e)
toStreamIx
{-# INLINE sifoldlM #-}
sifoldlM_
:: forall r ix e a m
. (Stream r ix e, Monad m)
=> (a -> ix -> e -> m a)
-> a
-> Array r ix e
-> m ()
sifoldlM_ :: forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> ix -> e -> m a) -> a -> Array r ix e -> m ()
sifoldlM_ a -> ix -> e -> m a
f a
acc = m a -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m a -> m ()) -> (Array r ix e -> m a) -> Array r ix e -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> ix -> e -> m a) -> a -> Array r ix e -> m a
forall r ix e a (m :: * -> *).
(Stream r ix e, Monad m) =>
(a -> ix -> e -> m a) -> a -> Array r ix e -> m a
sifoldlM a -> ix -> e -> m a
f a
acc
{-# INLINE sifoldlM_ #-}
sor
:: forall r ix
. Stream r ix Bool
=> Array r ix Bool
-> Bool
sor :: forall r ix. Stream r ix Bool => Array r ix Bool -> Bool
sor = Id Bool -> Bool
forall a. Id a -> a
S.unId (Id Bool -> Bool)
-> (Array r ix Bool -> Id Bool) -> Array r ix Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id Bool -> Id Bool
forall (m :: * -> *). Monad m => Steps m Bool -> m Bool
S.or (Steps Id Bool -> Id Bool)
-> (Array r ix Bool -> Steps Id Bool) -> Array r ix Bool -> Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix Bool -> Steps Id Bool
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sor #-}
sand :: forall r ix. Stream r ix Bool => Array r ix Bool -> Bool
sand :: forall r ix. Stream r ix Bool => Array r ix Bool -> Bool
sand = Id Bool -> Bool
forall a. Id a -> a
S.unId (Id Bool -> Bool)
-> (Array r ix Bool -> Id Bool) -> Array r ix Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id Bool -> Id Bool
forall (m :: * -> *). Monad m => Steps m Bool -> m Bool
S.and (Steps Id Bool -> Id Bool)
-> (Array r ix Bool -> Steps Id Bool) -> Array r ix Bool -> Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix Bool -> Steps Id Bool
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sand #-}
sany :: forall r ix e. Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
sany :: forall r ix e. Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
sany e -> Bool
f = Id Bool -> Bool
forall a. Id a -> a
S.unId (Id Bool -> Bool)
-> (Array r ix e -> Id Bool) -> Array r ix e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id Bool -> Id Bool
forall (m :: * -> *). Monad m => Steps m Bool -> m Bool
S.or (Steps Id Bool -> Id Bool)
-> (Array r ix e -> Steps Id Bool) -> Array r ix e -> Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Bool) -> Steps Id e -> Steps Id Bool
forall (m :: * -> *) e a.
Monad m =>
(e -> a) -> Steps m e -> Steps m a
S.map e -> Bool
f (Steps Id e -> Steps Id Bool)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sany #-}
sall :: forall r ix e. Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
sall :: forall r ix e. Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
sall e -> Bool
f = Id Bool -> Bool
forall a. Id a -> a
S.unId (Id Bool -> Bool)
-> (Array r ix e -> Id Bool) -> Array r ix e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steps Id Bool -> Id Bool
forall (m :: * -> *). Monad m => Steps m Bool -> m Bool
S.and (Steps Id Bool -> Id Bool)
-> (Array r ix e -> Steps Id Bool) -> Array r ix e -> Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Bool) -> Steps Id e -> Steps Id Bool
forall (m :: * -> *) e a.
Monad m =>
(e -> a) -> Steps m e -> Steps m a
S.map e -> Bool
f (Steps Id e -> Steps Id Bool)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sall #-}
ssum :: forall r ix e. (Num e, Stream r ix e) => Array r ix e -> e
ssum :: forall r ix e. (Num e, Stream r ix e) => Array r ix e -> e
ssum = (e -> e -> e) -> e -> Array r ix e -> e
forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> a
sfoldl e -> e -> e
forall a. Num a => a -> a -> a
(+) e
0
{-# INLINE ssum #-}
sproduct :: forall r ix e. (Num e, Stream r ix e) => Array r ix e -> e
sproduct :: forall r ix e. (Num e, Stream r ix e) => Array r ix e -> e
sproduct = (e -> e -> e) -> e -> Array r ix e -> e
forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> a
sfoldl e -> e -> e
forall a. Num a => a -> a -> a
(*) e
1
{-# INLINE sproduct #-}
smaximum' :: forall r ix e. (HasCallStack, Ord e, Stream r ix e) => Array r ix e -> e
smaximum' :: forall r ix e.
(HasCallStack, Ord e, Stream r ix e) =>
Array r ix e -> e
smaximum' = (e -> e -> e) -> Array r ix e -> e
forall r ix e.
(HasCallStack, Stream r ix e) =>
(e -> e -> e) -> Array r ix e -> e
sfoldl1' e -> e -> e
forall a. Ord a => a -> a -> a
max
{-# INLINE smaximum' #-}
smaximumM :: forall r ix e m. (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e
smaximumM :: forall r ix e (m :: * -> *).
(Ord e, Stream r ix e, MonadThrow m) =>
Array r ix e -> m e
smaximumM = (e -> e -> m e) -> Array r ix e -> m e
forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m e
sfoldl1M (\e
e e
acc -> e -> m e
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> e -> e
forall a. Ord a => a -> a -> a
max e
e e
acc))
{-# INLINE smaximumM #-}
sminimum' :: forall r ix e. (HasCallStack, Ord e, Stream r ix e) => Array r ix e -> e
sminimum' :: forall r ix e.
(HasCallStack, Ord e, Stream r ix e) =>
Array r ix e -> e
sminimum' = (e -> e -> e) -> Array r ix e -> e
forall r ix e.
(HasCallStack, Stream r ix e) =>
(e -> e -> e) -> Array r ix e -> e
sfoldl1' e -> e -> e
forall a. Ord a => a -> a -> a
min
{-# INLINE sminimum' #-}
sminimumM :: forall r ix e m. (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e
sminimumM :: forall r ix e (m :: * -> *).
(Ord e, Stream r ix e, MonadThrow m) =>
Array r ix e -> m e
sminimumM = (e -> e -> m e) -> Array r ix e -> m e
forall r ix e (m :: * -> *).
(Stream r ix e, MonadThrow m) =>
(e -> e -> m e) -> Array r ix e -> m e
sfoldl1M (\e
e e
acc -> e -> m e
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> e -> e
forall a. Ord a => a -> a -> a
min e
e e
acc))
{-# INLINE sminimumM #-}
sprescanl :: Stream r ix e => (a -> e -> a) -> a -> Array r ix e -> Vector DS a
sprescanl :: forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> Vector DS a
sprescanl a -> e -> a
f a
acc = Steps Id a -> Array DS Int a
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id a -> Array DS Int a)
-> (Array r ix e -> Steps Id a) -> Array r ix e -> Array DS Int a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> e -> Id a) -> a -> Steps Id e -> Steps Id a
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Steps m b -> Steps m a
S.prescanlM (\a
a e
b -> a -> Id a
forall a. a -> Id a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> e -> a
f a
a e
b)) a
acc (Steps Id e -> Steps Id a)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sprescanl #-}
spostscanl :: Stream r ix e => (a -> e -> a) -> a -> Array r ix e -> Vector DS a
spostscanl :: forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> Vector DS a
spostscanl a -> e -> a
f a
acc = Steps Id a -> Array DS Int a
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id a -> Array DS Int a)
-> (Array r ix e -> Steps Id a) -> Array r ix e -> Array DS Int a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> e -> Id a) -> a -> Steps Id e -> Steps Id a
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Steps m b -> Steps m a
S.postscanlM (\a
a e
b -> a -> Id a
forall a. a -> Id a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> e -> a
f a
a e
b)) a
acc (Steps Id e -> Steps Id a)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE spostscanl #-}
spostscanlAcc :: Stream r ix e => (c -> e -> (a, c)) -> c -> Array r ix e -> Vector DS a
spostscanlAcc :: forall r ix e c a.
Stream r ix e =>
(c -> e -> (a, c)) -> c -> Array r ix e -> Vector DS a
spostscanlAcc c -> e -> (a, c)
f c
acc = Steps Id a -> Array DS Int a
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id a -> Array DS Int a)
-> (Array r ix e -> Steps Id a) -> Array r ix e -> Array DS Int a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> e -> Id (a, c)) -> c -> Steps Id e -> Steps Id a
forall (m :: * -> *) c b a.
Monad m =>
(c -> b -> m (a, c)) -> c -> Steps m b -> Steps m a
S.postscanlAccM (\c
a e
b -> (a, c) -> Id (a, c)
forall a. a -> Id a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (c -> e -> (a, c)
f c
a e
b)) c
acc (Steps Id e -> Steps Id a)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE spostscanlAcc #-}
sscanl :: Stream r ix e => (a -> e -> a) -> a -> Array r ix e -> Vector DS a
sscanl :: forall r ix e a.
Stream r ix e =>
(a -> e -> a) -> a -> Array r ix e -> Vector DS a
sscanl a -> e -> a
f a
acc = Steps Id a -> Array DS Int a
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id a -> Array DS Int a)
-> (Array r ix e -> Steps Id a) -> Array r ix e -> Array DS Int a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> e -> Id a) -> a -> Steps Id e -> Steps Id a
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Steps m b -> Steps m a
S.scanlM (\a
a e
b -> a -> Id a
forall a. a -> Id a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> e -> a
f a
a e
b)) a
acc (Steps Id e -> Steps Id a)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sscanl #-}
sscanl1 :: Stream r ix e => (e -> e -> e) -> Array r ix e -> Vector DS e
sscanl1 :: forall r ix e.
Stream r ix e =>
(e -> e -> e) -> Array r ix e -> Vector DS e
sscanl1 e -> e -> e
f = Steps Id e -> Array DS Int e
forall e. Steps Id e -> Vector DS e
DSArray (Steps Id e -> Array DS Int e)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Array DS Int e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> e -> Id e) -> Steps Id e -> Steps Id e
forall (m :: * -> *) a.
Monad m =>
(a -> a -> m a) -> Steps m a -> Steps m a
S.scanl1M (\e
a e
b -> e -> Id e
forall a. a -> Id a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> e -> e
f e
a e
b)) (Steps Id e -> Steps Id e)
-> (Array r ix e -> Steps Id e) -> Array r ix e -> Steps Id e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array r ix e -> Steps Id e
forall r ix e. Stream r ix e => Array r ix e -> Steps Id e
toStream
{-# INLINE sscanl1 #-}