Safe Haskell | None |
---|
- reduceL :: Foldl i a b -> (b -> a -> b) -> StatefulWalk i a b
- reduceLeftM :: Foldl i a b -> (b -> a -> IO b) -> StatefulWalk i a b
- reduceR :: Foldr i a b -> (a -> b -> b) -> StatefulWalk i a b
- reduceRightM :: Foldr i a b -> (a -> b -> IO b) -> StatefulWalk i a b
- mutate :: Fill i a -> (s -> a -> IO ()) -> StatefulWalk i a s
- imutate :: Fill i a -> (s -> i -> a -> IO ()) -> StatefulWalk i a s
- walk :: (USource r l sh a, PreferredWorkIndex l sh i) => StatefulWalk i a s -> IO s -> UArray r l sh a -> IO s
- iwalk :: USource r l sh a => StatefulWalk sh a s -> IO s -> UArray r l sh a -> IO s
- rangeWalk :: USource r l sh a => StatefulWalk sh a s -> IO s -> UArray r l sh a -> sh -> sh -> IO s
- walkP :: (USource r l sh a, PreferredWorkIndex l sh i) => Threads -> StatefulWalk i a s -> IO s -> (s -> s -> IO s) -> UArray r l sh a -> IO s
- iwalkP :: USource r l sh a => Threads -> StatefulWalk sh a s -> IO s -> (s -> s -> IO s) -> UArray r l sh a -> IO s
- rangeWalkP :: USource r l sh a => Threads -> StatefulWalk sh a s -> IO s -> (s -> s -> IO s) -> UArray r l sh a -> sh -> sh -> IO s
- walkSlicesSeparate :: (UVecSource r slr l sh v e, PreferredWorkIndex l sh i) => StatefulWalk i e s -> IO s -> UArray r l sh (v e) -> IO (VecList (Dim v) s)
- iwalkSlicesSeparate :: UVecSource r slr l sh v e => StatefulWalk sh e s -> IO s -> UArray r l sh (v e) -> IO (VecList (Dim v) s)
- rangeWalkSlicesSeparate :: UVecSource r slr l sh v e => StatefulWalk sh e s -> IO s -> UArray r l sh (v e) -> sh -> sh -> IO (VecList (Dim v) s)
- walkSlicesSeparateP :: (UVecSource r slr l sh v e, PreferredWorkIndex l sh i) => Threads -> StatefulWalk i e s -> IO s -> (s -> s -> IO s) -> UArray r l sh (v e) -> IO (VecList (Dim v) s)
- iwalkSlicesSeparateP :: UVecSource r slr l sh v e => Threads -> StatefulWalk sh e s -> IO s -> (s -> s -> IO s) -> UArray r l sh (v e) -> IO (VecList (Dim v) s)
- rangeWalkSlicesSeparateP :: UVecSource r slr l sh v e => Threads -> StatefulWalk sh e s -> IO s -> (s -> s -> IO s) -> UArray r l sh (v e) -> sh -> sh -> IO (VecList (Dim v) s)
- type StatefulWalk sh a s = IO s -> (sh -> IO a) -> Walk sh s
- type Foldl sh a b = (b -> sh -> a -> IO b) -> StatefulWalk sh a b
- type Foldr sh a b = (sh -> a -> b -> IO b) -> StatefulWalk sh a b
Fold combinators
See source of these 4 functions to construct more similar ones, if you need.
:: Foldl i a b |
|
-> (b -> a -> b) | Pure left reduce |
-> StatefulWalk i a b | Result stateful walk to be passed to walk runners |
O(0)
:: Foldl i a b |
|
-> (b -> a -> IO b) | Monadic left reduce |
-> StatefulWalk i a b | Result stateful walk to be passed to walk runners |
O(0)
:: Foldr i a b |
|
-> (a -> b -> b) | Pure right reduce |
-> StatefulWalk i a b | Result stateful walk to be passed to walk runners |
O(0)
:: Foldr i a b |
|
-> (a -> b -> IO b) | Monadic right reduce |
-> StatefulWalk i a b | Result stateful walk to be passed to walk runners |
O(0)
Combinators to walk with mutable state
Added specially to improve performance of tasks like histogram filling.
Unfortunately, GHC doesn't figure that folding state isn't changed as ADT in such cases and doesn't lift it's evaluation higher from folding routine.
:: Fill i a |
|
-> (s -> a -> IO ()) | (state -> array element -> (state has changed)) -- State mutating function |
-> StatefulWalk i a s | Result stateful walk to be passed to walk runners |
O(0)
:: Fill i a |
|
-> (s -> i -> a -> IO ()) | Indexed state mutating function |
-> StatefulWalk i a s | Result stateful walk to be passed to walk runners |
O(0) Version of mutate
, accepts mutating function
which additionaly accepts array index.
Walk runners
:: (USource r l sh a, PreferredWorkIndex l sh i) | |
=> StatefulWalk i a s | Stateful walking function |
-> IO s | Monadic initial state (fold zero).
Wrap pure state in |
-> UArray r l sh a | Source array |
-> IO s | Final state (fold result) |
:: USource r l sh a | |
=> StatefulWalk sh a s | Stateful walking function |
-> IO s | Monadic initial state (fold zero).
Wrap pure state in |
-> UArray r l sh a | Source array |
-> sh | Top-left |
-> sh | and bottom-right corners of range to walk in |
-> IO s | Final state (fold result) |
O(n) Walk with state, in specified range of indices.
:: (USource r l sh a, PreferredWorkIndex l sh i) | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk i a s | Associative stateful walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh a | Source array |
-> IO s | Gathered state (fold result) |
O(n) Run associative non-indexed stateful walk, in parallel.
Example -- associative image histogram filling in the test: https://github.com/leventov/yarr/blob/master/tests/lum-equalization.hs
:: USource r l sh a | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk sh a s | Associative stateful walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh a | Source array |
-> IO s | Gathered state (fold result) |
O(n) Run associative indexed stateful walk, in parallel.
:: USource r l sh a | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk sh a s | Associative stateful walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh a | Source array |
-> sh | Top-left |
-> sh | and bottom-right corners of range to walk in |
-> IO s | Gathered state (fold result) |
O(n) Run associative stateful walk in specified range, in parallel.
:: (UVecSource r slr l sh v e, PreferredWorkIndex l sh i) | |
=> StatefulWalk i e s | Stateful slice-wise walking function |
-> IO s | Monadic initial state (fold zero).
Wrap pure state in |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) s) | Vector of final states (fold results) |
O(n) Walk with state, with non-indexed function, over each slice of array of vectors.
:: UVecSource r slr l sh v e | |
=> StatefulWalk sh e s | Stateful slice-wise walking function |
-> IO s | Monadic initial state (fold zero).
Wrap pure state in |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) s) | Vector of final states (fold results) |
O(n) Walk with state, with indexed function, over each slice of array of vectors.
:: UVecSource r slr l sh v e | |
=> StatefulWalk sh e s | Stateful slice-wise walking function |
-> IO s | Monadic initial state (fold zero).
Wrap pure state in |
-> UArray r l sh (v e) | Source array of vectors |
-> sh | Top-left |
-> sh | and bottom-right corners of range to walk in |
-> IO (VecList (Dim v) s) | Vector of final states (fold results) |
O(n) Walk with state, in specified range of indices, over each slice of array of vectors.
:: (UVecSource r slr l sh v e, PreferredWorkIndex l sh i) | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk i e s | Stateful slice-wise walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) s) | Vector of gathered per slice results |
O(n) Run associative non-indexed stateful walk over slices of array of vectors, in parallel.
:: UVecSource r slr l sh v e | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk sh e s | Stateful slice-wise walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) s) | Vector of gathered per slice results |
O(n) Run associative indexed stateful walk over slices of array of vectors, in parallel.
rangeWalkSlicesSeparatePSource
:: UVecSource r slr l sh v e | |
=> Threads | Number of threads to parallelize walk on |
-> StatefulWalk sh e s | Stateful slice-wise walking function |
-> IO s | Monadic zero state.
Wrap pure state in |
-> (s -> s -> IO s) | Associative monadic state joining function |
-> UArray r l sh (v e) | Source array of vectors |
-> sh | Top-left |
-> sh | and bottom-right corners of range to walk in |
-> IO (VecList (Dim v) s) | Vector of gathered per slice results |
O(n) Run associative stateful walk in specified range, over slices of array of vectors, in parallel.
Aliases for walk types
type StatefulWalk sh a sSource
= IO s | Initial state |
-> (sh -> IO a) | Indexing function |
-> Walk sh s | Curried result function -- walker, emits final state |
Generalizes both partially applied left and right folds, as well as walks with mutable state.
To be passed to walk runners from Data.Yarr.Walk module.
= (b -> sh -> a -> IO b) | Generalized left reduce |
-> StatefulWalk sh a b | Curried result stateful walk |
Generalizes left folds.
To be passed to fold combinators from Data.Yarr.Walk module.
= (sh -> a -> b -> IO b) | Generalized right reduce |
-> StatefulWalk sh a b | Curried result stateful walk |
Generalizes right folds.
To be passed to fold combinators from Data.Yarr.Walk module.