Copyright | (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 |
---|---|
License | BSD-style |
Maintainer | Haskell Libraries Team <libraries@haskell.org> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Monadic bundles.
Synopsis
- data Bundle m v a = Bundle {}
- data Chunk v a = Chunk Int (forall m. (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m ())
- lift :: Monad m => Bundle Id v a -> Bundle m v a
- size :: Bundle m v a -> Size
- sized :: Bundle m v a -> Size -> Bundle m v a
- length :: Monad m => Bundle m v a -> m Int
- null :: Monad m => Bundle m v a -> m Bool
- empty :: Monad m => Bundle m v a
- singleton :: Monad m => a -> Bundle m v a
- cons :: Monad m => a -> Bundle m v a -> Bundle m v a
- snoc :: Monad m => Bundle m v a -> a -> Bundle m v a
- replicate :: Monad m => Int -> a -> Bundle m v a
- replicateM :: Monad m => Int -> m a -> Bundle m v a
- generate :: Monad m => Int -> (Int -> a) -> Bundle m v a
- generateM :: Monad m => Int -> (Int -> m a) -> Bundle m v a
- (++) :: Monad m => Bundle m v a -> Bundle m v a -> Bundle m v a
- head :: Monad m => Bundle m v a -> m a
- last :: Monad m => Bundle m v a -> m a
- (!!) :: Monad m => Bundle m v a -> Int -> m a
- (!?) :: Monad m => Bundle m v a -> Int -> m (Maybe a)
- slice :: Monad m => Int -> Int -> Bundle m v a -> Bundle m v a
- init :: Monad m => Bundle m v a -> Bundle m v a
- tail :: Monad m => Bundle m v a -> Bundle m v a
- take :: Monad m => Int -> Bundle m v a -> Bundle m v a
- drop :: Monad m => Int -> Bundle m v a -> Bundle m v a
- map :: Monad m => (a -> b) -> Bundle m v a -> Bundle m v b
- mapM :: Monad m => (a -> m b) -> Bundle m v a -> Bundle m v b
- mapM_ :: Monad m => (a -> m b) -> Bundle m v a -> m ()
- trans :: (Monad m, Monad m') => (forall z. m z -> m' z) -> Bundle m v a -> Bundle m' v a
- unbox :: Monad m => Bundle m v (Box a) -> Bundle m v a
- concatMap :: Monad m => (a -> Bundle m v b) -> Bundle m v a -> Bundle m v b
- flatten :: Monad m => (a -> m s) -> (s -> m (Step s b)) -> Size -> Bundle m v a -> Bundle m v b
- indexed :: Monad m => Bundle m v a -> Bundle m v (Int, a)
- indexedR :: Monad m => Int -> Bundle m v a -> Bundle m v (Int, a)
- zipWithM_ :: Monad m => (a -> b -> m c) -> Bundle m v a -> Bundle m v b -> m ()
- zipWithM :: Monad m => (a -> b -> m c) -> Bundle m v a -> Bundle m v b -> Bundle m v c
- zipWith3M :: Monad m => (a -> b -> c -> m d) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d
- zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e
- zipWith5M :: Monad m => (a -> b -> c -> d -> e -> m f) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f
- zipWith6M :: Monad m => (a -> b -> c -> d -> e -> f -> m g) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v g
- zipWith :: Monad m => (a -> b -> c) -> Bundle m v a -> Bundle m v b -> Bundle m v c
- zipWith3 :: Monad m => (a -> b -> c -> d) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d
- zipWith4 :: Monad m => (a -> b -> c -> d -> e) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e
- zipWith5 :: Monad m => (a -> b -> c -> d -> e -> f) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f
- zipWith6 :: Monad m => (a -> b -> c -> d -> e -> f -> g) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v g
- zip :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v (a, b)
- zip3 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v (a, b, c)
- zip4 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v (a, b, c, d)
- zip5 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v (a, b, c, d, e)
- zip6 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v (a, b, c, d, e, f)
- eqBy :: Monad m => (a -> b -> Bool) -> Bundle m v a -> Bundle m v b -> m Bool
- cmpBy :: Monad m => (a -> b -> Ordering) -> Bundle m v a -> Bundle m v b -> m Ordering
- filter :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a
- filterM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a
- mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Bundle m v a -> Bundle m v b
- takeWhile :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a
- takeWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a
- dropWhile :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a
- dropWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a
- elem :: (Monad m, Eq a) => a -> Bundle m v a -> m Bool
- notElem :: (Monad m, Eq a) => a -> Bundle m v a -> m Bool
- find :: Monad m => (a -> Bool) -> Bundle m v a -> m (Maybe a)
- findM :: Monad m => (a -> m Bool) -> Bundle m v a -> m (Maybe a)
- findIndex :: Monad m => (a -> Bool) -> Bundle m v a -> m (Maybe Int)
- findIndexM :: Monad m => (a -> m Bool) -> Bundle m v a -> m (Maybe Int)
- foldl :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> m a
- foldlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a
- foldl1 :: Monad m => (a -> a -> a) -> Bundle m v a -> m a
- foldl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a
- foldM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a
- fold1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a
- foldl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> m a
- foldlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a
- foldl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> m a
- foldl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a
- foldM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a
- fold1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a
- foldr :: Monad m => (a -> b -> b) -> b -> Bundle m v a -> m b
- foldrM :: Monad m => (a -> b -> m b) -> b -> Bundle m v a -> m b
- foldr1 :: Monad m => (a -> a -> a) -> Bundle m v a -> m a
- foldr1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a
- and :: Monad m => Bundle m v Bool -> m Bool
- or :: Monad m => Bundle m v Bool -> m Bool
- concatMapM :: Monad m => (a -> m (Bundle m v b)) -> Bundle m v a -> Bundle m v b
- unfoldr :: Monad m => (s -> Maybe (a, s)) -> s -> Bundle m u a
- unfoldrM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Bundle m u a
- unfoldrN :: Monad m => Int -> (s -> Maybe (a, s)) -> s -> Bundle m u a
- unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Bundle m u a
- unfoldrExactN :: Monad m => Int -> (s -> (a, s)) -> s -> Bundle m u a
- unfoldrExactNM :: Monad m => Int -> (s -> m (a, s)) -> s -> Bundle m u a
- iterateN :: Monad m => Int -> (a -> a) -> a -> Bundle m u a
- iterateNM :: Monad m => Int -> (a -> m a) -> a -> Bundle m u a
- prescanl :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- prescanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- prescanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- prescanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- postscanl :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- postscanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- postscanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- postscanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- scanl :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- scanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- scanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a
- scanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a
- scanl1 :: Monad m => (a -> a -> a) -> Bundle m v a -> Bundle m v a
- scanl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a
- scanl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> Bundle m v a
- scanl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a
- enumFromStepN :: (Num a, Monad m) => a -> a -> Int -> Bundle m v a
- enumFromTo :: (Enum a, Monad m) => a -> a -> Bundle m v a
- enumFromThenTo :: (Enum a, Monad m) => a -> a -> a -> Bundle m v a
- toList :: Monad m => Bundle m v a -> m [a]
- fromList :: Monad m => [a] -> Bundle m v a
- fromListN :: Monad m => Int -> [a] -> Bundle m v a
- unsafeFromList :: Monad m => Size -> [a] -> Bundle m v a
- fromVector :: (Monad m, Vector v a) => v a -> Bundle m v a
- reVector :: Monad m => Bundle m u a -> Bundle m v a
- fromVectors :: forall m v a. (Monad m, Vector v a) => [v a] -> Bundle m v a
- concatVectors :: (Monad m, Vector v a) => Bundle m u (v a) -> Bundle m v a
- fromStream :: Monad m => Stream m a -> Size -> Bundle m v a
- chunks :: Bundle m v a -> Stream m (Chunk v a)
- elements :: Bundle m v a -> Stream m a
Documentation
Monadic streams
Instances
Monad m => Functor (Bundle m v) Source # | |
Eq1 (Bundle Id v) Source # | |
Ord1 (Bundle Id v) Source # | |
Defined in Data.Vector.Fusion.Bundle | |
Eq a => Eq (Bundle Id v a) Source # | |
Ord a => Ord (Bundle Id v a) Source # | |
Defined in Data.Vector.Fusion.Bundle compare :: Bundle Id v a -> Bundle Id v a -> Ordering # (<) :: Bundle Id v a -> Bundle Id v a -> Bool # (<=) :: Bundle Id v a -> Bundle Id v a -> Bool # (>) :: Bundle Id v a -> Bundle Id v a -> Bool # (>=) :: Bundle Id v a -> Bundle Id v a -> Bool # |
Size hints
Length
Construction
replicateM :: Monad m => Int -> m a -> Bundle m v a Source #
Yield a Bundle
of values obtained by performing the monadic action the
given number of times
generateM :: Monad m => Int -> (Int -> m a) -> Bundle m v a Source #
Generate a stream from its indices
(++) :: Monad m => Bundle m v a -> Bundle m v a -> Bundle m v a infixr 5 Source #
Concatenate two Bundle
s
Accessing elements
(!?) :: Monad m => Bundle m v a -> Int -> m (Maybe a) infixl 9 Source #
Element at the given position or Nothing
if out of bounds
Substreams
Extract a substream of the given length starting at the given position.
Mapping
mapM :: Monad m => (a -> m b) -> Bundle m v a -> Bundle m v b Source #
Map a monadic function over a Bundle
mapM_ :: Monad m => (a -> m b) -> Bundle m v a -> m () Source #
Execute a monadic action for each element of the Bundle
trans :: (Monad m, Monad m') => (forall z. m z -> m' z) -> Bundle m v a -> Bundle m' v a Source #
Transform a Bundle
to use a different monad
flatten :: Monad m => (a -> m s) -> (s -> m (Step s b)) -> Size -> Bundle m v a -> Bundle m v b Source #
Zipping
indexed :: Monad m => Bundle m v a -> Bundle m v (Int, a) Source #
Pair each element in a Bundle
with its index
indexedR :: Monad m => Int -> Bundle m v a -> Bundle m v (Int, a) Source #
Pair each element in a Bundle
with its index, starting from the right
and counting down
zipWithM :: Monad m => (a -> b -> m c) -> Bundle m v a -> Bundle m v b -> Bundle m v c Source #
Zip two Bundle
s with the given monadic function
zipWith3M :: Monad m => (a -> b -> c -> m d) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d Source #
zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e Source #
zipWith5M :: Monad m => (a -> b -> c -> d -> e -> m f) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f Source #
zipWith6M :: Monad m => (a -> b -> c -> d -> e -> f -> m g) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v g Source #
zipWith3 :: Monad m => (a -> b -> c -> d) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d Source #
zipWith4 :: Monad m => (a -> b -> c -> d -> e) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e Source #
zipWith5 :: Monad m => (a -> b -> c -> d -> e -> f) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f Source #
zipWith6 :: Monad m => (a -> b -> c -> d -> e -> f -> g) -> Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v g Source #
zip4 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v (a, b, c, d) Source #
zip5 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v (a, b, c, d, e) Source #
zip6 :: Monad m => Bundle m v a -> Bundle m v b -> Bundle m v c -> Bundle m v d -> Bundle m v e -> Bundle m v f -> Bundle m v (a, b, c, d, e, f) Source #
Comparisons
eqBy :: Monad m => (a -> b -> Bool) -> Bundle m v a -> Bundle m v b -> m Bool Source #
Check if two Bundle
s are equal
cmpBy :: Monad m => (a -> b -> Ordering) -> Bundle m v a -> Bundle m v b -> m Ordering Source #
Lexicographically compare two Bundle
s
Filtering
filter :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a Source #
Drop elements which do not satisfy the predicate
filterM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a Source #
Drop elements which do not satisfy the monadic predicate
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Bundle m v a -> Bundle m v b Source #
Apply monadic function to each element and drop all Nothings
Since: 0.12.2.0
takeWhile :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a Source #
Longest prefix of elements that satisfy the predicate
takeWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a Source #
Longest prefix of elements that satisfy the monadic predicate
dropWhile :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a Source #
Drop the longest prefix of elements that satisfy the predicate
dropWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a Source #
Drop the longest prefix of elements that satisfy the monadic predicate
Searching
elem :: (Monad m, Eq a) => a -> Bundle m v a -> m Bool infix 4 Source #
Check whether the Bundle
contains an element
Folding
foldlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a Source #
Left fold with a monadic operator
foldl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a Source #
Left fold over a non-empty Bundle
with a monadic operator
foldl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> m a Source #
Left fold with a strict accumulator
foldlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a Source #
Left fold with a strict accumulator and a monadic operator
foldl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> m a Source #
Left fold over a non-empty Bundle
with a strict accumulator
foldl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a Source #
Left fold over a non-empty Bundle
with a strict accumulator and a
monadic operator
foldrM :: Monad m => (a -> b -> m b) -> b -> Bundle m v a -> m b Source #
Right fold with a monadic operator
foldr1 :: Monad m => (a -> a -> a) -> Bundle m v a -> m a Source #
Right fold over a non-empty stream
foldr1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a Source #
Right fold over a non-empty stream with a monadic operator
Specialised folds
Unfolding
unfoldrM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Bundle m u a Source #
Unfold with a monadic function
unfoldrN :: Monad m => Int -> (s -> Maybe (a, s)) -> s -> Bundle m u a Source #
Unfold at most n
elements
unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Bundle m u a Source #
Unfold at most n
elements with a monadic function.
unfoldrExactN :: Monad m => Int -> (s -> (a, s)) -> s -> Bundle m u a Source #
Unfold exactly n
elements
Since: 0.12.2.0
unfoldrExactNM :: Monad m => Int -> (s -> m (a, s)) -> s -> Bundle m u a Source #
Unfold exactly n
elements with a monadic function.
Since: 0.12.2.0
iterateN :: Monad m => Int -> (a -> a) -> a -> Bundle m u a Source #
O(n) Apply function \(\max(n - 1, 0)\) times to an initial value, producing a monadic bundle of exact length \(\max(n, 0)\). Zeroth element will contain the initial value.
iterateNM :: Monad m => Int -> (a -> m a) -> a -> Bundle m u a Source #
O(n) Apply monadic function \(\max(n - 1, 0)\) times to an initial value, producing a monadic bundle of exact length \(\max(n, 0)\). Zeroth element will contain the initial value.
Scans
prescanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Prefix scan with a monadic operator
prescanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a Source #
Prefix scan with strict accumulator
prescanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Prefix scan with strict accumulator and a monadic operator
postscanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Suffix scan with a monadic operator
postscanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a Source #
Suffix scan with strict accumulator
postscanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Suffix scan with strict accumulator and a monadic operator
scanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Haskell-style scan with a monadic operator
scanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a Source #
Haskell-style scan with strict accumulator
scanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a Source #
Haskell-style scan with strict accumulator and a monadic operator
scanl1 :: Monad m => (a -> a -> a) -> Bundle m v a -> Bundle m v a Source #
Initial-value free scan over a Bundle
scanl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a Source #
Initial-value free scan over a Bundle
with a monadic operator
scanl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> Bundle m v a Source #
Initial-value free scan over a Bundle
with a strict accumulator
scanl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a Source #
Initial-value free scan over a Bundle
with a strict accumulator
and a monadic operator
Enumerations
enumFromStepN :: (Num a, Monad m) => a -> a -> Int -> Bundle m v a Source #
Yield a Bundle
of the given length containing the values x
, x+y
,
x+y+y
etc.
enumFromTo :: (Enum a, Monad m) => a -> a -> Bundle m v a Source #
Enumerate values
WARNING: This operation can be very inefficient. If at all possible, use
enumFromStepN
instead.
enumFromThenTo :: (Enum a, Monad m) => a -> a -> a -> Bundle m v a Source #
Enumerate values with a given step.
WARNING: This operation is very inefficient. If at all possible, use
enumFromStepN
instead.
Conversions
fromListN :: Monad m => Int -> [a] -> Bundle m v a Source #
Convert the first n
elements of a list to a Bundle