vector-0.12.0.2: Efficient Arrays

Copyright (c) Roman Leshchinskiy 2008-2010 BSD-style Roman Leshchinskiy experimental non-portable None Haskell2010

Data.Vector.Fusion.Bundle

Description

Bundles for stream fusion

Synopsis

# Types

data Step s a where #

Result of taking a single step in a stream

Constructors

 Yield :: a -> s -> Step s a Skip :: s -> Step s a Done :: Step s a
Instances
 Functor (Step s) # Instance detailsDefined in Data.Vector.Fusion.Stream.Monadic Methodsfmap :: (a -> b) -> Step s a -> Step s b #(<\$) :: a -> Step s b -> Step s a #

data Chunk v a #

Constructors

 Chunk Int (forall m. (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m ())

type Bundle = Bundle Id #

The type of pure streams

type MBundle = Bundle #

# In-place markers

inplace :: (forall m. Monad m => Stream m a -> Stream m b) -> (Size -> Size) -> Bundle v a -> Bundle v b #

# Size hints

size :: Bundle v a -> Size #

Size hint of a Bundle

sized :: Bundle v a -> Size -> Bundle v a #

Attach a Size hint to a Bundle

# Length information

length :: Bundle v a -> Int #

Length of a Bundle

null :: Bundle v a -> Bool #

Check if a Bundle is empty

# Construction

empty :: Bundle v a #

Empty Bundle

singleton :: a -> Bundle v a #

Singleton Bundle

cons :: a -> Bundle v a -> Bundle v a #

Prepend an element

snoc :: Bundle v a -> a -> Bundle v a #

Append an element

replicate :: Int -> a -> Bundle v a #

Replicate a value to a given length

generate :: Int -> (Int -> a) -> Bundle v a #

Generate a stream from its indices

(++) :: Bundle v a -> Bundle v a -> Bundle v a infixr 5 #

Concatenate two Bundles

# Accessing individual elements

head :: Bundle v a -> a #

First element of the Bundle or error if empty

last :: Bundle v a -> a #

Last element of the Bundle or error if empty

(!!) :: Bundle v a -> Int -> a infixl 9 #

Element at the given position

(!?) :: Bundle v a -> Int -> Maybe a infixl 9 #

Element at the given position or Nothing if out of bounds

# Substreams

Arguments

 :: Int starting index -> Int length -> Bundle v a -> Bundle v a

Extract a substream of the given length starting at the given position.

init :: Bundle v a -> Bundle v a #

All but the last element

tail :: Bundle v a -> Bundle v a #

All but the first element

take :: Int -> Bundle v a -> Bundle v a #

The first n elements

drop :: Int -> Bundle v a -> Bundle v a #

All but the first n elements

# Mapping

map :: (a -> b) -> Bundle v a -> Bundle v b #

Map a function over a Bundle

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 #

Create a Bundle of values from a Bundle of streamable things

unbox :: Bundle v (Box a) -> Bundle v a #

# Zipping

indexed :: Bundle v a -> Bundle v (Int, a) #

Pair each element in a Bundle with its index

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 Bundles with the given function

zipWith3 :: (a -> b -> c -> d) -> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d #

Zip three Bundles 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 #

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) #

# Filtering

filter :: (a -> Bool) -> Bundle v a -> Bundle v a #

Drop elements which do not satisfy the predicate

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

elem :: Eq a => a -> Bundle v a -> Bool infix 4 #

Check whether the Bundle contains an element

notElem :: Eq a => a -> Bundle v a -> Bool infix 4 #

Inverse of elem

find :: (a -> Bool) -> Bundle v a -> Maybe a #

Yield Just the first element matching the predicate or Nothing if no such element exists.

findIndex :: (a -> Bool) -> Bundle v a -> Maybe Int #

Yield Just the index of the first element matching the predicate or Nothing if no such element exists.

# Folding

foldl :: (a -> b -> a) -> a -> Bundle v b -> a #

Left fold

foldl1 :: (a -> a -> a) -> Bundle v a -> a #

Left fold on non-empty Bundles

foldl' :: (a -> b -> a) -> a -> Bundle v b -> a #

Left fold with strict accumulator

foldl1' :: (a -> a -> a) -> Bundle v a -> a #

Left fold on non-empty Bundles with strict accumulator

foldr :: (a -> b -> b) -> b -> Bundle v a -> b #

Right fold

foldr1 :: (a -> a -> a) -> Bundle v a -> a #

Right fold on non-empty Bundles

# Specialised folds

and :: Bundle v Bool -> Bool #

or :: Bundle v Bool -> Bool #

# Unfolding

unfoldr :: (s -> Maybe (a, s)) -> s -> Bundle v a #

Unfold

unfoldrN :: Int -> (s -> Maybe (a, s)) -> s -> Bundle v a #

Unfold at most n elements

iterateN :: Int -> (a -> a) -> a -> Bundle v a #

Apply function n-1 times to value. Zeroth element is original value.

# Scans

prescanl :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #

Prefix scan

prescanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #

Prefix scan with strict accumulator

postscanl :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #

Suffix scan

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 #

scanl' :: (a -> b -> a) -> a -> Bundle v b -> Bundle v a #

scanl1 :: (a -> a -> a) -> Bundle v a -> Bundle v a #

Scan over a non-empty Bundle

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

toList :: Bundle v a -> [a] #

Convert a Bundle to a list

fromList :: [a] -> Bundle v a #

Create a Bundle from a list

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 #

lift :: Monad m => Bundle v a -> Bundle m v a #

Convert a pure stream to a monadic stream

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 #

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

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 #

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 #

Monad fold over non-empty stream with strict accumulator

eq :: Eq a => Bundle v a -> Bundle v a -> Bool #

Check if two Bundles are equal

cmp :: Ord a => Bundle v a -> Bundle v a -> Ordering #

Lexicographically compare two Bundles

eqBy :: (a -> b -> Bool) -> Bundle v a -> Bundle v b -> Bool #

cmpBy :: (a -> b -> Ordering) -> Bundle v a -> Bundle v b -> Ordering #

# Orphan instances

 Eq1 (Bundle Id v) # Instance details MethodsliftEq :: (a -> b -> Bool) -> Bundle Id v a -> Bundle Id v b -> Bool # Ord1 (Bundle Id v) # Instance details MethodsliftCompare :: (a -> b -> Ordering) -> Bundle Id v a -> Bundle Id v b -> Ordering # Eq a => Eq (Bundle Id v a) # Instance details Methods(==) :: Bundle Id v a -> Bundle Id v a -> Bool #(/=) :: Bundle Id v a -> Bundle Id v a -> Bool # Ord a => Ord (Bundle Id v a) # Instance details Methodscompare :: 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 #max :: Bundle Id v a -> Bundle Id v a -> Bundle Id v a #min :: Bundle Id v a -> Bundle Id v a -> Bundle Id v a #