-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple zipper for lists
--
-- List zipper with O(1) get element at cursor, insert at cursor, delete
-- at cursor, move right, and move left operations.
@package ListZipper
@version 1.2.0.2
module Data.List.Zipper
data Zipper a
Zip :: ![a] -> ![a] -> Zipper a
-- | empty is an empty zipper
empty :: Zipper a
-- | fromList xs returns a zipper containing the elements of xs,
-- focused on the first element.
fromList :: [a] -> Zipper a
-- | fromListEnd xs returns a zipper containing the elements of
-- xs, focused just off the right end of the list.
fromListEnd :: [a] -> Zipper a
toList :: Zipper a -> [a]
-- | beginp z returns True if the zipper is at the start.
beginp :: Zipper a -> Bool
-- | endp z returns True if the zipper is at the end. It
-- is not safe to call cursor on z if endp z
-- returns True.
endp :: Zipper a -> Bool
-- | emptyp z returns True if the zipper is completely
-- empty. forall z. emptyp z == beginp z && endp z
emptyp :: Zipper a -> Bool
start, end :: Zipper a -> Zipper a
-- | cursor z returns the targeted element in z.
--
-- This function is not total, but the invariant is that endp z ==
-- False means that you can safely call cursor z.
cursor :: Zipper a -> a
-- | safeCursor is like cursor but total.
safeCursor :: Zipper a -> Maybe a
-- | left z returns the zipper with the focus shifted left one
-- element.
left :: Zipper a -> Zipper a
-- | right z returns the zipper with the focus shifted right one
-- element; this can move the cursor off the end.
right :: Zipper a -> Zipper a
-- | insert x z adds x at the cursor.
insert :: a -> Zipper a -> Zipper a
-- | delete z removes the element at the cursor (if any). Safe to
-- call on an empty zipper. forall x z. delete (insert x z) == z
delete :: Zipper a -> Zipper a
-- | push x z inserts x into the zipper, and advances the cursor
-- past it.
push :: a -> Zipper a -> Zipper a
-- | pop z removes the element before the cursor (if any). Safe to
-- call on an empty zipper. forall x z. pop (push x z) == z
pop :: Zipper a -> Zipper a
-- | replace a z changes the current element in the zipper to the
-- passed in value. If there is no current element, the zipper is
-- unchanged. If you want to add the element in that case instead, use
-- insert a (delete z).
replace :: a -> Zipper a -> Zipper a
-- | reversez z returns the zipper with the elements in the
-- reverse order. O(1). The cursor is moved to the previous element, so
-- if the cursor was at the start, it's now off the right end, and if it
-- was off the right end, it's now at the start of the reversed list.
reversez :: Zipper a -> Zipper a
-- | foldrz f x zip calls f with the zipper focused on
-- each element in order, starting with the current. You are guaranteed
-- that f can safely call cursor on its argument; the zipper won't
-- be at the end.
foldrz :: (Zipper a -> b -> b) -> b -> Zipper a -> b
-- | foldlz f x zip calls f with the zipper focused on each
-- element in order, starting with the current. You are guaranteed that f
-- can safely call cursor on its argument; the zipper won't be at
-- the end.
foldlz :: (b -> Zipper a -> b) -> b -> Zipper a -> b
-- | foldlz' is foldlz with a strict accumulator
foldlz' :: (b -> Zipper a -> b) -> b -> Zipper a -> b
-- | extractz, extendz, and duplicatez can be
-- used to implement Copointed and Comonad from category-extras. I didn't
-- add the instances here so as not to introduce a dependency on that
-- package.
extractz :: Zipper a -> a
duplicatez :: Zipper a -> Zipper (Zipper a)
extendz :: (Zipper a -> b) -> Zipper a -> Zipper b
instance Eq a => Eq (Zipper a)
instance Show a => Show (Zipper a)
instance Functor Zipper
instance CoArbitrary a => CoArbitrary (Zipper a)
instance Arbitrary a => Arbitrary (Zipper a)