unfoldl package:massiv

Unfold sequentially from the end. There is no way to save the accumulator after unfolding is done, since resulting array is delayed, but it's possible to use unfoldlPrimM to achieve such effect.
Just like iunfoldlPrimM, but do the unfolding with index aware function.
Sequentially unfold an array from the left.

Examples

Create an array with Fibonacci numbers starting at the end while performing and IO action on the accumulator for each element of the array.
>>> import Data.Massiv.Array

>>> unfoldlPrimM_ (Sz1 10) (\a@(f0, f1) -> let fn = f0 + f1 in print a >> return ((f1, fn), f0)) (0, 1) :: IO (Array P Ix1 Int)
(0,1)
(1,1)
(1,2)
(2,3)
(3,5)
(5,8)
(8,13)
(13,21)
(21,34)
(34,55)
Array P Seq (Sz1 10)
[ 34, 21, 13, 8, 5, 3, 2, 1, 1, 0 ]
Unfold sequentially from the right with an index aware function.
Just like iunfoldlPrimM_, but also returns the final value of the accumulator.
Same as unfoldlPrimM_ but do the unfolding with index aware function.