Safe Haskell | Safe-Inferred |
---|

Helpers for performing nested loop iteration. Includes variants for parallel computation.

- data Zipper a = Zip [a] a [a]
- toZipper :: a -> [a] -> Zipper a
- unsafeToZipper :: [a] -> Zipper a
- fromZipper :: Zipper a -> [a]
- left :: Zipper a -> Maybe (Zipper a)
- unsafeLeft :: Zipper a -> Zipper a
- right :: Zipper a -> Maybe (Zipper a)
- focus :: Zipper a -> a
- rightmost :: Zipper a -> Zipper a
- zipSum :: Num a => Zipper a -> a
- zipStep :: Num a => Zipper a -> a
- zipStride :: Num a => Zipper a -> a
- zipFoldM :: Monad m => Zipper Int -> (a -> Int -> m a) -> a -> [Int] -> m ()
- parChunkMapM_ :: (a -> IO ()) -> [a] -> IO ()
- parZipFoldM :: Zipper Int -> (a -> Int -> IO a) -> a -> [Int] -> IO ()
- zipMapM_ :: Monad m => Zipper Int -> (Int -> m ()) -> [Int] -> m ()
- zipFoldMAsYouDo :: Monad m => Zipper Int -> (Int -> Int -> m ()) -> m ()
- parZipFoldMAsYouDo :: Zipper Int -> (Int -> Int -> IO ()) -> IO ()

# Documentation

toZipper :: a -> [a] -> Zipper aSource

Create a `Zipper`

from a non-empty list, with the cursor on the
leftmost element.

unsafeToZipper :: [a] -> Zipper aSource

Create a `Zipper`

from a non-empty list, with the cursor on the
leftmost element. An exception is thrown if the given list is
empty.

fromZipper :: Zipper a -> [a]Source

Convert a `Zipper`

to a list.

unsafeLeft :: Zipper a -> Zipper aSource

Comonadic coreturn: produce the value a `Zipper`

is currently
focused upon.

zipSum :: Num a => Zipper a -> aSource

Since we are using `Zipper`

s to track the size of
multidemensional arrays, the sum of all zipper elements gives the
size of the entire array.

zipStep :: Num a => Zipper a -> aSource

Computes the step between consective elements at the currently focused dimension. This involves stepping over all nested dimensions.

zipStride :: Num a => Zipper a -> aSource

Computes the stride between rows at the currently focused dimension. This involves stepping over the rest of the current row along all nested dimensions.

parChunkMapM_ :: (a -> IO ()) -> [a] -> IO ()Source