non-empty-zipper-0.1.0.9: The Zipper for NonEmpty

Data.List.NonEmptyZipper

Description

Its the Zipper for NonEmpty lists.

Synopsis

# Documentation

A Zipper with a "current element". The current element represent a singular, focus on a single element in a list. So NonEmptyZipper [1,2] 3 [4] is roughly eqivelant to [1,2,3,4], where 3 is the current element. This is useful, since we are now guarenteed that the current element is an element in the list.

Constructors

 NonEmptyZipper A list of element succeeding the current element. Fields_before :: ![a]A list of elements preceeding the current element._current :: !aThe current element._after :: ![a]

Instances

 Source # Its a Functor Methodsfmap :: (a -> b) -> NonEmptyZipper a -> NonEmptyZipper b #(<\$) :: a -> NonEmptyZipper b -> NonEmptyZipper a # Source # Its Applicative, but pure might not be what you expect Methodspure :: a -> NonEmptyZipper a #(<*>) :: NonEmptyZipper (a -> b) -> NonEmptyZipper a -> NonEmptyZipper b #liftA2 :: (a -> b -> c) -> NonEmptyZipper a -> NonEmptyZipper b -> NonEmptyZipper c # Source # Its Foldable Methodsfold :: Monoid m => NonEmptyZipper m -> m #foldMap :: Monoid m => (a -> m) -> NonEmptyZipper a -> m #foldr :: (a -> b -> b) -> b -> NonEmptyZipper a -> b #foldr' :: (a -> b -> b) -> b -> NonEmptyZipper a -> b #foldl :: (b -> a -> b) -> b -> NonEmptyZipper a -> b #foldl' :: (b -> a -> b) -> b -> NonEmptyZipper a -> b #foldr1 :: (a -> a -> a) -> NonEmptyZipper a -> a #foldl1 :: (a -> a -> a) -> NonEmptyZipper a -> a #toList :: NonEmptyZipper a -> [a] #null :: NonEmptyZipper a -> Bool #length :: NonEmptyZipper a -> Int #elem :: Eq a => a -> NonEmptyZipper a -> Bool #maximum :: Ord a => NonEmptyZipper a -> a #minimum :: Ord a => NonEmptyZipper a -> a #sum :: Num a => NonEmptyZipper a -> a #product :: Num a => NonEmptyZipper a -> a # Source # Its Traversable Methodstraverse :: Applicative f => (a -> f b) -> NonEmptyZipper a -> f (NonEmptyZipper b) #sequenceA :: Applicative f => NonEmptyZipper (f a) -> f (NonEmptyZipper a) #mapM :: Monad m => (a -> m b) -> NonEmptyZipper a -> m (NonEmptyZipper b) #sequence :: Monad m => NonEmptyZipper (m a) -> m (NonEmptyZipper a) # Eq a => Eq (NonEmptyZipper a) Source # Methods(==) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool #(/=) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool # Ord a => Ord (NonEmptyZipper a) Source # Methods(<) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool #(<=) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool #(>) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool #(>=) :: NonEmptyZipper a -> NonEmptyZipper a -> Bool # Show a => Show (NonEmptyZipper a) Source # MethodsshowsPrec :: Int -> NonEmptyZipper a -> ShowS #showList :: [NonEmptyZipper a] -> ShowS # Source # Its a Semigroup by appending the second NonEmptyZipper to the _after list. Methodsstimes :: Integral b => b -> NonEmptyZipper a -> NonEmptyZipper a #

(|:) :: a -> [a] -> NonEmptyZipper a Source #

Make a NonEmptyZipper from a focus item (which will be the head) and ADDITIONAL options.

nezFromBound :: (Bounded a, Enum a, Eq a) => a -> NonEmptyZipper a Source #

Create a NonEmptyZipper based on a focused item in a Bounded Enum, index position within the Enum will be maintained.

nezFromOptions :: Eq a => a -> [a] -> Maybe (NonEmptyZipper a) Source #

Create a NonEmptyZipper by taking a focused element, and list of options If the focused element is not in the list, we get Nothing.

before :: Functor f => ([a] -> f [a]) -> NonEmptyZipper a -> f (NonEmptyZipper a) Source #

Map to _before, useful as a lens

current :: Functor f => (a -> f a) -> NonEmptyZipper a -> f (NonEmptyZipper a) Source #

Map to current, useful as a lens

after :: Functor f => ([a] -> f [a]) -> NonEmptyZipper a -> f (NonEmptyZipper a) Source #

Map to after, useful as a lens

Advance the current element forward by one. If the current is the last element in the list, we do nothing.

Advance the current element forward by one. If the current is the last element in the list, we loop back to the first.

Move the current element backward by one. If the current is the first element in the list, we do nothing.

Move the current element backward by one. If the current is the first element in the list, we loop to the last element.

toList :: NonEmptyZipper a -> [a] Source #

Convert to a standard list. Current element information will be lost.

Convert from NonEmpty. The first element will be the current element.

Is the current selection the first item in the collection?

Is the current selection the last item in the collection?

Get the index of the current element in the collection.

Measure the size of the collection. Will be atleast 1.

head :: NonEmptyZipper a -> a Source #

Get the first element out of the NonEmptyZipper.

Get all elements out of the NonEmptyZipper that are not the last element. If there is only one element in the collection, it's Nothing.

last :: NonEmptyZipper a -> a Source #

Get the last element out of the NonEmptyZipper.

Get all elements out of the NonEmptyZipper that are not the first element. If there is only one element in the collection, its Nothing.

Flip the NonEmptyZipper, maintaining the current element.

cons :: a -> NonEmptyZipper a -> NonEmptyZipper a Source #

Add one element to the front of a NonEmptyZipper.

wrap :: a -> NonEmptyZipper a Source #

This is like pure but more intuitive. The Applicative instance for NonEmptyZipper is likely not what you expect.

setCurrent :: Eq a => a -> NonEmptyZipper a -> Maybe (NonEmptyZipper a) Source #

Set the current element in the NonEmptyZipper. If the element does not appear in the collection, the result with be Nothing

Set the current element in the NonEmptyZipper via index location. If the index is out of bounds the results will be Nothing.