-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | a cyclic doubly linked list -- -- This package implements a cyclic doubly linked list and defines -- various instances for it. @package data-cycle @version 0.1.0 module Data.Cycle -- | A cyclic doubly linked list. -- -- To create a new Cycle, use fromList, fromFoldable or any -- of the insertion functions from Unfoldable. Elements are -- inserted in front of the current position. -- -- To get the length of the list, use size. To extract all cycle -- elements, use toList. You can also create an infinite list with -- cycleToInfiniteList. -- -- The functions front and back fail with error for -- empty cycles. -- -- take, drop and splitAt fail with error for -- empty cycles if their first argument is not 0. They also accept -- negative values for working backwards (see takeLR and -- dropLR for details). -- -- In general, any function f working on [a] can be -- adapted for Cycle a by writing fromList . f . -- toList. -- -- The Monad, Functor, Applicative, -- Alternative, Monoid and Foldable instances work -- like the default instances for lists. data Cycle a -- | Move focus to the element on the left of the current position. goLeft :: Cycle a -> Cycle a -- | Move focus to the element on the right of the current position. -- --
--   goLeft . goRight == id
--   
goRight :: Cycle a -> Cycle a -- | Move abs n steps to the left (n < 0) or right -- (n > 0) or don't move at all (n == 0). goLR :: Int -> Cycle a -> Cycle a -- | Get the value at the current position. error if null -- c. getValue :: Cycle a -> a -- | Get value on the left. error if null c. leftValue :: Cycle a -> a -- | Get value on the right. error if null c. rightValue :: Cycle a -> a -- | Get nth value to the left (n < 0) or right (n > -- 0) or the current value (n == 0). error if -- null c. -- --
--   nthValue = flip (!)
--   
nthValue :: Int -> Cycle a -> a -- | Take abs n values starting at the current one and moving to -- the right (n > 0) or left (n < 0). n -- can be arbitrary big. -- --
--   take n = fromList . takeLR n
--   
takeLR :: Int -> Cycle a -> [a] -- | Drop abs n values starting at the current one and moving to -- the right (n > 0) or left (n < 0). n -- can be arbitrary big. -- --
--   drop n = fromList . dropLR n
--   
dropLR :: Int -> Cycle a -> [a] -- | Convert to an infinite list starting with the current value and moving -- to the right. cycleToInfiniteList :: Cycle a -> [a] -- |
--   zipCycle = zipCycleWith (,)
--   
zipCycle :: Cycle a -> Cycle b -> Cycle (a, b) -- | Combine to cycles by applying a binary function to all element pairs. -- Like Data.List.zipWith. zipCycleWith :: (a -> b -> c) -> Cycle a -> Cycle b -> Cycle c instance Eq a => Eq (Cycle a) instance Indexed (Cycle a) Int a instance Sequence (Cycle a) a instance Monoid (Cycle a) instance Show a => Show (Cycle a) instance Collection (Cycle a) a instance Foldable (Cycle a) a instance Unfoldable (Cycle a) a instance Monad Cycle instance Alternative Cycle instance Applicative Cycle instance Functor Cycle instance Functor DList