    module Data.List.PointedList.Circular
      ( -- Re-export many of the regular PointedList features
      module Data.List.PointedList

      -- And, of course, export the alternatives here
      , next
      , previous
      , delete
      , deleteLeft
      , deleteRight
      , moveN
      ) where

    import Data.List.PointedList
      ( PointedList(..)
      , focus
      , singleton
      , fromList
      , fromListEnd
      , replace
      , insert
      , insertLeft
      , insertRight
      , deleteOthers
      , length
      , positions
      , contextMap
      , withFocus
      , find
      , index
      )
    import qualified Data.List.PointedList as PL

    -- | Move the focus to the next element in the list. If the last element is
    --   currently focused, loop to the first element.
    next :: PointedList a -> PointedList a
    next :: forall a. PointedList a -> PointedList a
    next pl :: PointedList a
    pl@(PointedList [] a
    b []) = PointedList a
    pl
    next    (PointedList [a]
    a  a
    b []) = let (a
    x:[a]
    xs) = [a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    a in
                                      [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList [] a
    x ([a]
    xs [a] -> [a] -> [a]
    forall a. [a] -> [a] -> [a]
    ++ [a
    b])
    next PointedList a
    pl = PointedList a -> PointedList a
    forall a. PointedList a -> PointedList a
    PL.tryNext PointedList a
    pl

    -- | Move the focus to the previous element in the list. If the first element is
    --   currently focused, loop to the last element.
    previous :: PointedList a -> PointedList a
    previous :: forall a. PointedList a -> PointedList a
    previous pl :: PointedList a
    pl@(PointedList [] a
    b []) = PointedList a
    pl
    previous    (PointedList [] a
    b [a]
    c ) = let (a
    x:[a]
    xs) = [a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    c in
                                          [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList ([a]
    xs [a] -> [a] -> [a]
    forall a. [a] -> [a] -> [a]
    ++ [a
    b]) a
    x []
    previous PointedList a
    pl = PointedList a -> PointedList a
    forall a. PointedList a -> PointedList a
    PL.tryPrevious PointedList a
    pl

    -- | An alias of 'deleteRight'.
    delete :: PointedList a -> Maybe (PointedList a)
    delete :: forall a. PointedList a -> Maybe (PointedList a)
    delete = PointedList a -> Maybe (PointedList a)
    forall a. PointedList a -> Maybe (PointedList a)
    deleteRight

    -- | Possibly delete the element at the focus, then move the element on the
    --   left to the focus. If no element is on the left, focus on the element to
    --   the right. If the deletion will cause the list to be empty, return
    --   @Nothing@.
    deleteLeft :: PointedList a -> Maybe (PointedList a)
    deleteLeft :: forall a. PointedList a -> Maybe (PointedList a)
    deleteLeft (PointedList []     a
    _ []) = Maybe (PointedList a)
    forall a. Maybe a
    Nothing
    deleteLeft (PointedList (a
    l:[a]
    ls) a
    _ [a]
    rs) = PointedList a -> Maybe (PointedList a)
    forall a. a -> Maybe a
    Just (PointedList a -> Maybe (PointedList a))
    -> PointedList a -> Maybe (PointedList a)
    forall a b. (a -> b) -> a -> b
    $ [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList [a]
    ls a
    l [a]
    rs
    deleteLeft (PointedList []     a
    _ [a]
    rs) = let (a
    x:[a]
    xs) = [a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    rs in
                                             PointedList a -> Maybe (PointedList a)
    forall a. a -> Maybe a
    Just (PointedList a -> Maybe (PointedList a))
    -> PointedList a -> Maybe (PointedList a)
    forall a b. (a -> b) -> a -> b
    $ [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList [a]
    xs a
    x []

    -- | Possibly delete the element at the focus, then move the element on the
    --   right to the focus. If no element is on the right, focus on the element to
    --   the left. If the deletion will cause the list to be empty, return
    --   @Nothing@.
    deleteRight :: PointedList a -> Maybe (PointedList a)
    deleteRight :: forall a. PointedList a -> Maybe (PointedList a)
    deleteRight (PointedList [] a
    _ []    ) = Maybe (PointedList a)
    forall a. Maybe a
    Nothing
    deleteRight (PointedList [a]
    ls a
    _ (a
    r:[a]
    rs)) = PointedList a -> Maybe (PointedList a)
    forall a. a -> Maybe a
    Just (PointedList a -> Maybe (PointedList a))
    -> PointedList a -> Maybe (PointedList a)
    forall a b. (a -> b) -> a -> b
    $ [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList [a]
    ls a
    r [a]
    rs
    deleteRight (PointedList [a]
    ls a
    _ []    ) = let (a
    x:[a]
    xs) = [a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    ls in
                                                PointedList a -> Maybe (PointedList a)
    forall a. a -> Maybe a
    Just (PointedList a -> Maybe (PointedList a))
    -> PointedList a -> Maybe (PointedList a)
    forall a b. (a -> b) -> a -> b
    $ [a] -> a -> [a] -> PointedList a
    forall a. [a] -> a -> [a] -> PointedList a
    PointedList [] a
    x [a]
    xs

    -- | Move
    moveN :: Int -> PointedList a -> PointedList a
    moveN :: forall a. Int -> PointedList a -> PointedList a
    moveN Int
    0 PointedList a
    pl = PointedList a
    pl
    moveN Int
    n PointedList a
    pl | Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    0     = Int -> PointedList a -> PointedList a
    forall a. Int -> PointedList a -> PointedList a
    moveN (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    1) (PointedList a -> PointedList a) -> PointedList a -> PointedList a
    forall a b. (a -> b) -> a -> b
    $ PointedList a -> PointedList a
    forall a. PointedList a -> PointedList a
    next PointedList a
    pl
               | Bool
    otherwise = Int -> PointedList a -> PointedList a
    forall a. Int -> PointedList a -> PointedList a
    moveN (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +Int
    1) (PointedList a -> PointedList a) -> PointedList a -> PointedList a
    forall a b. (a -> b) -> a -> b
    $ PointedList a -> PointedList a
    forall a. PointedList a -> PointedList a
    previous PointedList a
    pl