Copyright | (c) Roman Leshchinskiy 2008-2010 |
---|---|
License | BSD-style |
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au> |
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) # | |
Eq1 (Bundle Id v) # | |
Ord1 (Bundle Id v) # | |
Defined in Data.Vector.Fusion.Bundle | |
Eq a => Eq (Bundle Id v a) # | |
Ord a => Ord (Bundle Id v a) # | |
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 #
Yield a Bundle
of values obtained by performing the monadic action the
given number of times
Accessing elements
(!?) :: Monad m => Bundle m v a -> Int -> m (Maybe a) infixl 9 #
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 -> m () #
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 #
Transform a Bundle
to use a different monad
Zipping
indexed :: Monad m => Bundle m v a -> Bundle m v (Int, a) #
Pair each element in a Bundle
with its index
indexedR :: Monad m => Int -> Bundle m v a -> Bundle m v (Int, a) #
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 #
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 #
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 #
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 #
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) #
Comparisons
eqBy :: Monad m => (a -> b -> Bool) -> Bundle m v a -> Bundle m v b -> m Bool #
Check if two Bundle
s are equal
cmpBy :: Monad m => (a -> b -> Ordering) -> Bundle m v a -> Bundle m v b -> m Ordering #
Lexicographically compare two Bundle
s
Filtering
filter :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a #
Drop elements which do not satisfy the predicate
filterM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a #
Drop elements which do not satisfy the monadic predicate
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Bundle m v a -> Bundle m v b #
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 #
Longest prefix of elements that satisfy the predicate
takeWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a #
Longest prefix of elements that satisfy the monadic predicate
dropWhile :: Monad m => (a -> Bool) -> Bundle m v a -> Bundle m v a #
Drop the longest prefix of elements that satisfy the predicate
dropWhileM :: Monad m => (a -> m Bool) -> Bundle m v a -> Bundle m v a #
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 #
Check whether the Bundle
contains an element
Folding
foldl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a #
Left fold over a non-empty Bundle
with a monadic operator
foldlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> m a #
Left fold with a strict accumulator and a monadic operator
foldl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> m a #
Left fold over a non-empty Bundle
with a strict accumulator
foldl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a #
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 #
Right fold with a monadic operator
foldr1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> m a #
Right fold over a non-empty stream with a monadic operator
Specialised folds
Unfolding
unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Bundle m u a #
Unfold at most n
elements with a monadic function.
unfoldrExactN :: Monad m => Int -> (s -> (a, s)) -> s -> Bundle m u a #
Unfold exactly n
elements
Since: 0.12.2.0
unfoldrExactNM :: Monad m => Int -> (s -> m (a, s)) -> s -> Bundle m u a #
Unfold exactly n
elements with a monadic function.
Since: 0.12.2.0
iterateN :: Monad m => Int -> (a -> a) -> a -> Bundle m u a #
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 #
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 #
Prefix scan with a monadic operator
prescanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a #
Prefix scan with strict accumulator
prescanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a #
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 #
Suffix scan with a monadic operator
postscanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a #
Suffix scan with strict accumulator
postscanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a #
Suffix scan with strict acccumulator and a monadic operator
scanlM :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a #
Haskell-style scan with a monadic operator
scanl' :: Monad m => (a -> b -> a) -> a -> Bundle m v b -> Bundle m v a #
Haskell-style scan with strict accumulator
scanlM' :: Monad m => (a -> b -> m a) -> a -> Bundle m v b -> Bundle m v a #
Haskell-style scan with strict accumulator and a monadic operator
scanl1M :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a #
Scan over a non-empty Bundle
with a monadic operator
scanl1' :: Monad m => (a -> a -> a) -> Bundle m v a -> Bundle m v a #
Scan over a non-empty Bundle
with a strict accumulator
scanl1M' :: Monad m => (a -> a -> m a) -> Bundle m v a -> Bundle m v a #
Scan over a non-empty Bundle
with a strict accumulator and a monadic
operator
Enumerations
enumFromStepN :: (Num a, Monad m) => a -> a -> Int -> Bundle m v a #
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 #
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 #
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 #
Convert the first n
elements of a list to a Bundle
unsafeFromList :: Monad m => Size -> [a] -> Bundle m v a #
fromVector :: (Monad m, Vector v a) => v a -> Bundle m v a #
fromVectors :: forall m v a. (Monad m, Vector v a) => [v a] -> Bundle m v a #