{-# LANGUAGE FlexibleContexts #-} -- only to satisfy the circularShift type spec being there module CircularShift ( circularShift ) where import Data.Array.IO rotate :: [a] -> [a] rotate [] = [] rotate (x:xs) = xs ++ [x] rotateAll :: [a] -> [[a]] rotateAll xs = take (length xs) (iterate rotate xs) -- type generated by GHCi circularShift :: (Ix i, MArray a [e] m, MArray a [[e]] m) => a i [e] -> m (a i [[e]]) circularShift = mapArray rotateAll