Safe Haskell  None 

Language  Haskell98 
Converting Stream
s and Chain
s to and from generic Vector
s.
 NOTE: Support for streams of unknown length is not complete.
 unstreamToVector2 :: (PrimMonad m, Vector v a, Vector v b) => Stream m (Maybe a, Maybe b) > m (v a, v b)
 unstreamToMVector2 :: (PrimMonad m, MVector v a, MVector v b) => Stream m (Maybe a, Maybe b) > m (v (PrimState m) a, v (PrimState m) b)
 compact :: (Vector v a, Vector v b) => (s > a > (s, Maybe b)) > s > v a > v b
 compactIn :: Vector v a => (a > a > (a, Maybe a)) > v a > v a
 findSegments :: (Vector v a, Vector v Int, Vector v (Int, Int)) => (a > Bool) > (a > Bool) > v a > (v Int, v Int)
 findSegmentsFrom :: (Vector v Int, Vector v (Int, Int)) => (a > Bool) > (a > Bool) > Int > (Int > a) > (v Int, v Int)
 diceSep :: (Vector v a, Vector v (Int, Int)) => (a > Bool) > (a > Bool) > v a > (v (Int, Int), v (Int, Int))
 extract :: (Vector v (Int, Int), Vector v a) => (Int > a) > v (Int, Int) > v a
 insert :: Vector v a => (Int > Maybe a) > v a > v a
 merge :: (Ord k, Vector v (k, a), Vector v (k, b), Vector v (k, c)) => (k > a > b > c) > (k > a > c) > (k > b > c) > v (k, a) > v (k, b) > v (k, c)
 mergeMaybe :: (Ord k, Vector v (k, a), Vector v (k, b), Vector v (k, c)) => (k > a > b > Maybe c) > (k > a > Maybe c) > (k > b > Maybe c) > v (k, a) > v (k, b) > v (k, c)
 padForward :: (Ord k, Vector v (k, a)) => (k > k) > v (k, a) > v (k, a)
 ratchet :: (Vector v Int, Vector v (Int, Int)) => v (Int, Int) > (v Int, v Int)
 replicates :: (Vector v (Int, a), Vector v a) => v (Int, a) > v a
 chainOfVector :: (Monad m, Vector v a) => v a > Chain m Int a
 unchainToVector :: (PrimMonad m, Vector v a) => Chain m s a > m (v a, s)
 unchainToMVector :: (PrimMonad m, MVector v a) => Chain m s a > m (v (PrimState m) a, s)
 folds :: forall v n a b. (Vector v (n, Int), Vector v a, Vector v (n, b)) => (a > b > b) > b > Option3 n Int b > v (n, Int) > v a > (v (n, b), Folds Int Int n a b)
 data Folds sLens sVals n a b = Folds {
 _stateLens :: !sLens
 _stateVals :: !sVals
 _nameSeg :: !(Option n)
 _lenSeg :: !Int
 _valSeg :: !b
 scanMaybe :: forall v1 v2 a b s. (Vector v1 a, Vector v2 b) => (s > a > (s, Maybe b)) > s > v1 a > (v2 b, s)
 groupsBy :: forall v1 v2 a. (Vector v1 a, Vector v2 (a, Int)) => (a > a > Bool) > Maybe (a, Int) > v1 a > (v2 (a, Int), Maybe (a, Int))
Stream operators
:: (PrimMonad m, Vector v a, Vector v b)  
=> Stream m (Maybe a, Maybe b)  Source data. 
> m (v a, v b)  Resulting vectors. 
Unstream some elements to two separate vectors.
Nothing
values are ignored.
:: (PrimMonad m, MVector v a, MVector v b)  
=> Stream m (Maybe a, Maybe b)  Source data. 
> m (v (PrimState m) a, v (PrimState m) b)  Resulting vectors. 
Unstream some elements to two separate mutable vectors.
Nothing
values are ignored.
Compacting
:: (Vector v a, Vector v b)  
=> (s > a > (s, Maybe b))  Worker function 
> s  Starting state 
> v a  Input vector 
> v b 
Combination of fold
and filter
.
We walk over the stream front to back, maintaining an accumulator. At each point we can chose to emit an element (or not)
Like compact
but use the first value of the stream as the
initial state, and add the final state to the end of the output.
Dicing
:: (Vector v a, Vector v Int, Vector v (Int, Int))  
=> (a > Bool)  Predicate to check for start of segment. 
> (a > Bool)  Predicate to check for end of segment. 
> v a  Input vector. 
> (v Int, v Int) 
Given predicates that detect the beginning and end of some interesting segment of information, scan through a vector looking for when these segments begin and end. Return vectors of the segment starting positions and lengths.
 As each segment must end on a element where the ending predicate returns True, the miniumum segment length returned is 1.
:: (Vector v Int, Vector v (Int, Int))  
=> (a > Bool)  Predicate to check for start of segment. 
> (a > Bool)  Predicate to check for end of segment. 
> Int  Input length. 
> (Int > a)  Get an element from the input. 
> (v Int, v Int) 
Given predicates that detect the beginning and end of some interesting segment of information, scan through a vector looking for when these segments begin and end. Return vectors of the segment starting positions and lengths.
:: (Vector v a, Vector v (Int, Int))  
=> (a > Bool)  Detect the end of a column. 
> (a > Bool)  Detect the end of a row. 
> v a  
> (v (Int, Int), v (Int, Int))  Segment starts and lengths 
Dice a vector stream into rows and columns.
Extracting
:: (Vector v (Int, Int), Vector v a)  
=> (Int > a)  Function to get elements from the source. 
> v (Int, Int)  Segment starts and lengths. 
> v a  Result elements. 
Extract segments from some source array and concatenate them.
let arr = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] in extractS (index arr) [(0, 1), (3, 3), (2, 6)] => [10, 13, 14, 15, 12, 13, 14, 15, 16, 17]
Inserting
Insert elements produced by the given function into a vector.
Merging
:: (Ord k, Vector v (k, a), Vector v (k, b), Vector v (k, c))  
=> (k > a > b > c)  Combine two values with the same key. 
> (k > a > c)  Handle a left value without a right value. 
> (k > b > c)  Handle a right value without a left value. 
> v (k, a)  Vector of keys and left values. 
> v (k, b)  Vector of keys and right values. 
> v (k, c)  Vector of keys and results. 
Merge two presorted keyvalue streams.
:: (Ord k, Vector v (k, a), Vector v (k, b), Vector v (k, c))  
=> (k > a > b > Maybe c)  Combine two values with the same key. 
> (k > a > Maybe c)  Handle a left value without a right value. 
> (k > b > Maybe c)  Handle a right value without a left value. 
> v (k, a)  Vector of keys and left values. 
> v (k, b)  Vector of keys and right values. 
> v (k, c)  Vector of keys and results. 
Padding
:: (Ord k, Vector v (k, a))  
=> (k > k)  Successor function. 
> v (k, a)  Input keys and values. 
> v (k, a) 
Given a stream of keys and values, and a successor function for keys, if the stream is has keys missing in the sequence then insert the missing key, copying forward the the previous value.
Ratcheting
:: (Vector v Int, Vector v (Int, Int))  
=> v (Int, Int)  Starting and ending values. 
> (v Int, v Int)  Elements and Lengths vectors. 
Interleaved enumFromTo
.
Given a vector of starting values, and a vector of stopping values, produce an stream of elements where we increase each of the starting values to the stopping values in a roundrobin order. Also produce a vector of result segment lengths.
unsafeRatchetS [10,20,30,40] [15,26,33,47] = [10,20,30,40  4 ,11,21,31,41  4 ,12,22,32,42  4 ,13,23 ,43  3 ,14,24 ,44  3 ,25 ,45  2 ,46]  1 ^^^^ ^^^ Elements Lengths
Replicating
Chain operators
chainOfVector :: (Monad m, Vector v a) => v a > Chain m Int a Source #
Produce a chain from a generic vector.
unchainToVector :: (PrimMonad m, Vector v a) => Chain m s a > m (v a, s) Source #
Compute a chain into a generic vector.
unchainToMVector :: (PrimMonad m, MVector v a) => Chain m s a > m (v (PrimState m) a, s) Source #
Compute a chain into a generic mutable vector.
Folding
:: (Vector v (n, Int), Vector v a, Vector v (n, b))  
=> (a > b > b)  Worker function to fold each segment. 
> b  Initial state when folding segments. 
> Option3 n Int b  Length and initial state for first segment. 
> v (n, Int)  Segment names and lengths. 
> v a  Elements. 
> (v (n, b), Folds Int Int n a b) 
Segmented fold over vectors of segment lengths and input values.
The total lengths of all segments need not match the length of the
input elements vector. The returned Folds
state can be inspected
to determine whether all segments were completely folded, or the
vector of segment lengths or elements was too short relative to the
other. In the resulting state, foldLensState
is the index into
the lengths vector *after* the last one that was consumed. If this
equals the length of the lengths vector then all segment lengths were
consumed. Similarly for the elements vector.
data Folds sLens sVals n a b Source #
Return state of a folds operation.
Folds  

Scanning
:: (Vector v1 a, Vector v2 b)  
=> (s > a > (s, Maybe b))  Worker function. 
> s  Initial state for scan. 
> v1 a  Input elements. 
> (v2 b, s)  Output elements. 
Perform a lefttoright scan through an input vector, maintaining a state value between each element. For each element of input we may or may not produce an element of output.
:: (Vector v1 a, Vector v2 (a, Int))  
=> (a > a > Bool)  Comparison function. 
> Maybe (a, Int)  Starting element and count. 
> v1 a  Input elements. 
> (v2 (a, Int), Maybe (a, Int)) 
From a stream of values which has consecutive runs of idential values, produce a stream of the lengths of these runs.
groupsBy (==) (Just (a
, 4)) ['a', 'a', 'a', 'b', 'b', 'c', 'd', 'd'] => ([(a
, 7), (b
, 2), (c
, 1)], Just ('d', 2))