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 |
Bundles for stream fusion
Synopsis
- data Step s a where
- data Chunk v a = Chunk Int (forall m. (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m ())
- type Bundle = Bundle Id
- type MBundle = Bundle
- inplace :: (forall m. Monad m => Stream m a -> Stream m b) -> (Size -> Size) -> Bundle v a -> Bundle v b
- size :: Bundle v a -> Size
- sized :: Bundle v a -> Size -> Bundle v a
- length :: Bundle v a -> Int
- null :: Bundle v a -> Bool
- empty :: Bundle v a
- singleton :: a -> Bundle v a
- cons :: a -> Bundle v a -> Bundle v a
- snoc :: Bundle v a -> a -> Bundle v a
- replicate :: Int -> a -> Bundle v a
- generate :: Int -> (Int -> a) -> Bundle v a
- (++) :: Bundle v a -> Bundle v a -> Bundle v a
- head :: Bundle v a -> a
- last :: Bundle v a -> a
- (!!) :: Bundle v a -> Int -> a
- (!?) :: Bundle v a -> Int -> Maybe a
- slice :: Int -> Int -> Bundle v a -> Bundle v a
- init :: Bundle v a -> Bundle v a
- tail :: Bundle v a -> Bundle v a
- take :: Int -> Bundle v a -> Bundle v a
- drop :: Int -> Bundle v a -> Bundle v a
- map :: (a -> b) -> Bundle v a -> Bundle v b
- concatMap :: (a -> Bundle v b) -> Bundle v a -> Bundle v b
- flatten :: (a -> s) -> (s -> Step s b) -> Size -> Bundle v a -> Bundle v b
- unbox :: Bundle v (Box a) -> Bundle v a
- indexed :: Bundle v a -> Bundle v (Int, a)
- indexedR :: Int -> Bundle v a -> Bundle v (Int, a)
- zipWith :: (a -> b -> c) -> Bundle v a -> Bundle v b -> Bundle v c
- zipWith3 :: (a -> b -> c -> d) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d
- zipWith4 :: (a -> b -> c -> d -> e) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e
- zipWith5 :: (a -> b -> c -> d -> e -> f) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f
- zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f -> Bundle v g
- zip :: Bundle v a -> Bundle v b -> Bundle v (a, b)
- zip3 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v (a, b, c)
- zip4 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v (a, b, c, d)
- zip5 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v (a, b, c, d, e)
- zip6 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f -> Bundle v (a, b, c, d, e, f)
- filter :: (a -> Bool) -> Bundle v a -> Bundle v a
- takeWhile :: (a -> Bool) -> Bundle v a -> Bundle v a
- dropWhile :: (a -> Bool) -> Bundle v a -> Bundle v a
- elem :: Eq a => a -> Bundle v a -> Bool
- notElem :: Eq a => a -> Bundle v a -> Bool
- find :: (a -> Bool) -> Bundle v a -> Maybe a
- findIndex :: (a -> Bool) -> Bundle v a -> Maybe Int
- foldl :: (a -> b -> a) -> a -> Bundle v b -> a
- foldl1 :: (a -> a -> a) -> Bundle v a -> a
- foldl' :: (a -> b -> a) -> a -> Bundle v b -> a
- foldl1' :: (a -> a -> a) -> Bundle v a -> a
- foldr :: (a -> b -> b) -> b -> Bundle v a -> b
- foldr1 :: (a -> a -> a) -> Bundle v a -> a
- and :: Bundle v Bool -> Bool
- or :: Bundle v Bool -> Bool
- unfoldr :: (s -> Maybe (a, s)) -> s -> Bundle v a
- unfoldrN :: Int -> (s -> Maybe (a, s)) -> s -> Bundle v a
- unfoldrExactN :: Int -> (s -> (a, s)) -> s -> Bundle v a
- iterateN :: Int -> (a -> a) -> a -> Bundle v a
- prescanl :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- prescanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- postscanl :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- postscanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- scanl :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- scanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a
- scanl1 :: (a -> a -> a) -> Bundle v a -> Bundle v a
- scanl1' :: (a -> a -> a) -> Bundle v a -> Bundle v a
- enumFromStepN :: Num a => a -> a -> Int -> Bundle v a
- enumFromTo :: Enum a => a -> a -> Bundle v a
- enumFromThenTo :: Enum a => a -> a -> a -> Bundle v a
- toList :: Bundle v a -> [a]
- fromList :: [a] -> Bundle v a
- fromListN :: Int -> [a] -> Bundle v a
- unsafeFromList :: Size -> [a] -> Bundle v a
- lift :: Monad m => Bundle Id v a -> Bundle m v a
- fromVector :: Vector v a => v a -> Bundle v a
- reVector :: Bundle u a -> Bundle v a
- fromVectors :: Vector v a => [v a] -> Bundle v a
- concatVectors :: Vector v a => Bundle u (v a) -> Bundle v a
- mapM :: Monad m => (a -> m b) -> Bundle v a -> Bundle m v b
- mapM_ :: Monad m => (a -> m b) -> Bundle v a -> m ()
- zipWithM :: Monad m => (a -> b -> m c) -> Bundle v a -> Bundle v b -> Bundle m v c
- zipWithM_ :: Monad m => (a -> b -> m c) -> Bundle v a -> Bundle v b -> m ()
- filterM :: Monad m => (a -> m Bool) -> Bundle v a -> Bundle m v a
- mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Bundle v a -> Bundle m v b
- foldM :: Monad m => (a -> b -> m a) -> a -> Bundle v b -> m a
- fold1M :: Monad m => (a -> a -> m a) -> Bundle v a -> m a
- foldM' :: Monad m => (a -> b -> m a) -> a -> Bundle v b -> m a
- fold1M' :: Monad m => (a -> a -> m a) -> Bundle v a -> m a
- eq :: Eq a => Bundle v a -> Bundle v a -> Bool
- cmp :: Ord a => Bundle v a -> Bundle v a -> Ordering
- eqBy :: (a -> b -> Bool) -> Bundle v a -> Bundle v b -> Bool
- cmpBy :: (a -> b -> Ordering) -> Bundle v a -> Bundle v b -> Ordering
Types
Result of taking a single step in a stream
In-place markers
inplace :: (forall m. Monad m => Stream m a -> Stream m b) -> (Size -> Size) -> Bundle v a -> Bundle v b #
Size hints
Length information
Construction
Accessing individual elements
(!?) :: Bundle v a -> Int -> 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
Zipping
indexedR :: Int -> Bundle v a -> Bundle v (Int, a) #
Pair each element in a Bundle
with its index, starting from the right
and counting down
zipWith :: (a -> b -> c) -> Bundle v a -> Bundle v b -> Bundle v c #
Zip two Bundle
s with the given function
zipWith3 :: (a -> b -> c -> d) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d #
Zip three Bundle
s with the given function
zipWith4 :: (a -> b -> c -> d -> e) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e #
zipWith5 :: (a -> b -> c -> d -> e -> f) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f #
zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f -> Bundle v g #
zip5 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v (a, b, c, d, e) #
zip6 :: Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d -> Bundle v e -> Bundle v f -> Bundle v (a, b, c, d, e, f) #
Filtering
takeWhile :: (a -> Bool) -> Bundle v a -> Bundle v a #
Longest prefix of elements that satisfy the predicate
dropWhile :: (a -> Bool) -> Bundle v a -> Bundle v a #
Drop the longest prefix of elements that satisfy the predicate
Searching
Folding
Specialised folds
Unfolding
unfoldrExactN :: Int -> (s -> (a, s)) -> s -> Bundle v a #
Unfold exactly n
elements
Since: 0.12.2.0
iterateN :: Int -> (a -> a) -> a -> Bundle v a #
O(n) Apply function \(\max(n - 1, 0)\) times to an initial value, producing a pure bundle of exact length \(\max(n, 0)\). Zeroth element will contain the initial value.
Scans
postscanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #
Suffix scan with strict accumulator
scanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #
Haskell-style scan with strict accumulator
scanl1' :: (a -> a -> a) -> Bundle v a -> Bundle v a #
Scan over a non-empty Bundle
with a strict accumulator
Enumerations
enumFromStepN :: Num a => a -> a -> Int -> Bundle v a #
Yield a Bundle
of the given length containing the values x
, x+y
,
x+y+y
etc.
enumFromTo :: Enum a => a -> a -> Bundle v a #
Enumerate values
WARNING: This operations can be very inefficient. If at all possible, use
enumFromStepN
instead.
enumFromThenTo :: Enum a => a -> a -> a -> Bundle v a #
Enumerate values with a given step.
WARNING: This operations is very inefficient. If at all possible, use
enumFromStepN
instead.
Conversions
fromListN :: Int -> [a] -> Bundle v a #
Create a Bundle
from the first n
elements of a list
fromListN n xs = fromList (take n xs)
unsafeFromList :: Size -> [a] -> Bundle v a #
fromVector :: Vector v a => v a -> Bundle v a #
fromVectors :: Vector v a => [v a] -> Bundle v a #
concatVectors :: Vector v a => Bundle u (v a) -> Bundle v a #
Monadic combinators
mapM :: Monad m => (a -> m b) -> Bundle v a -> Bundle m v b #
Apply a monadic action to each element of the stream, producing a monadic stream of results
mapM_ :: Monad m => (a -> m b) -> Bundle v a -> m () #
Apply a monadic action to each element of the stream
filterM :: Monad m => (a -> m Bool) -> Bundle v a -> Bundle m v a #
Yield a monadic stream of elements that satisfy the monadic predicate
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Bundle v a -> Bundle m v b #
O(n) Apply monadic function to each element of a bundle and discard elements returning Nothing.
Since: 0.12.2.0
foldM' :: Monad m => (a -> b -> m a) -> a -> Bundle v b -> m a #
Monadic fold with strict accumulator
fold1M' :: Monad m => (a -> a -> m a) -> Bundle v a -> m a #
Monad fold over non-empty stream with strict accumulator
Orphan instances
Eq1 (Bundle Id v) # | |
Ord1 (Bundle Id v) # | |
Eq a => Eq (Bundle Id v a) # | |
Ord a => Ord (Bundle Id v a) # | |
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 # |