Safe Haskell | None |
---|---|
Language | Haskell98 |
- See the Data.Repa.Vector.Unboxed module for examples of how these functions can be used.
- extractS :: Monad m => (Int -> a) -> Stream m (Int, Int) -> Stream m a
- mergeS :: (Monad m, Ord k) => (k -> a -> b -> c) -> (k -> a -> c) -> (k -> b -> c) -> Stream m (k, a) -> Stream m (k, b) -> Stream m (k, c)
- findSegmentsS :: Monad m => (a -> Bool) -> (a -> Bool) -> i -> Stream m (i, a) -> Stream m (i, i)
- diceSepS :: Monad m => (a -> Bool) -> (a -> Bool) -> Stream m a -> Stream m (Maybe (Int, Int), Maybe (Int, Int))
- startLengthsOfSegsS :: Monad m => Stream m (Int, Int) -> Stream m (Int, Int)
- padForwardS :: (Monad m, Ord k) => (k -> k) -> Stream m (k, v) -> Stream m (k, v)
- unsafeRatchetS :: IOVector Int -> Vector Int -> IORef (IOVector Int) -> Stream IO Int
Documentation
:: Monad m | |
=> (Int -> a) | Function to get elements from the source. |
-> Stream m (Int, Int) | Segment start positions and lengths. |
-> Stream m a | Result elements. |
Extract segments from some source array and concatenate them.
:: (Monad m, Ord k) | |
=> (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. |
-> Stream m (k, a) | Stream of keys and left values. |
-> Stream m (k, b) | Stream of keys and right values. |
-> Stream m (k, c) | Stream of keys and results. |
Merge two key-value streams.
The streams are assumed to be pre-sorted on the keys.
:: Monad m | |
=> (a -> Bool) | Predicate to check for start of segment. |
-> (a -> Bool) | Predicate to check for end of segment. |
-> i | Index of final element in stream. |
-> Stream m (i, a) | Stream of indices and elements. |
-> Stream m (i, i) | Stream of segment start and end indices. |
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.
:: Monad m | |
=> (a -> Bool) | Detect the end of a column. |
-> (a -> Bool) | Detect the end of a row. |
-> Stream m a | |
-> Stream m (Maybe (Int, Int), Maybe (Int, Int)) | Segment starts and lengths |
Given predicates that detect the begining and end of interesting segments of information, scan through a vector looking for when these begin and end.
:: Monad m | |
=> Stream m (Int, Int) | Start and end indices. |
-> Stream m (Int, Int) | Start indices and lengths of segments. |
Given a stream of starting and ending indices for some segments, convert it to a stream of starting indices and segment lengths.
- The ending indices must be after the starting indices, otherwise the result will contain negative lengths.
:: (Monad m, Ord k) | |
=> (k -> k) | Successor functinon for keys. |
-> Stream m (k, v) | Input stream. |
-> Stream m (k, v) |
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.
Unsafe operators
:: IOVector Int | Starting values. Overwritten duing computation. |
-> Vector Int | Ending values |
-> IORef (IOVector Int) | Vector holding segment lengths. |
-> Stream IO Int |
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 round-robin 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
The function takes the starting values in a mutable vector and updates it during computation. Computation proceeds by making passes through the mutable vector and updating the starting values until they match the stopping values.
UNSAFE: Both input vectors must have the same length, but this is not checked.