| Copyright | (C) 2017 Isaac Shapira | 
|---|---|
| License | BSD-style (see the file LICENSE) | 
| Maintainer | Isaac Shapira <fresheyeball@gmail.com> | 
| Stability | provisional | 
| Portability | portable | 
| Safe Haskell | Safe | 
| Language | Haskell2010 | 
Data.List.NonEmptyZipper
Description
Its the Zipper for NonEmpty lists.
- data NonEmptyZipper a = NonEmptyZipper {}
 - before :: Functor f => ([a] -> f [a]) -> NonEmptyZipper a -> f (NonEmptyZipper a)
 - current :: Functor f => (a -> f a) -> NonEmptyZipper a -> f (NonEmptyZipper a)
 - after :: Functor f => ([a] -> f [a]) -> NonEmptyZipper a -> f (NonEmptyZipper a)
 - next :: NonEmptyZipper a -> NonEmptyZipper a
 - nextMod :: NonEmptyZipper a -> NonEmptyZipper a
 - previous :: NonEmptyZipper a -> NonEmptyZipper a
 - previousMod :: NonEmptyZipper a -> NonEmptyZipper a
 - toList :: NonEmptyZipper a -> [a]
 - fromNonEmpty :: NonEmpty a -> NonEmptyZipper a
 - inTheBeginning :: NonEmptyZipper a -> Bool
 - inTheEnd :: NonEmptyZipper a -> Bool
 - getPosition :: NonEmptyZipper a -> Int
 - length :: NonEmptyZipper a -> Int
 - head :: NonEmptyZipper a -> a
 - init :: NonEmptyZipper a -> Maybe (NonEmptyZipper a)
 - last :: NonEmptyZipper a -> a
 - tail :: NonEmptyZipper a -> Maybe (NonEmptyZipper a)
 - reverse :: NonEmptyZipper a -> NonEmptyZipper a
 - cons :: a -> NonEmptyZipper a -> NonEmptyZipper a
 - wrap :: a -> NonEmptyZipper a
 - setCurrent :: Eq a => a -> NonEmptyZipper a -> Maybe (NonEmptyZipper a)
 - setCurrentIndex :: Int -> NonEmptyZipper a -> Maybe (NonEmptyZipper a)
 
Documentation
data NonEmptyZipper a Source #
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.  | 
Instances
| Functor NonEmptyZipper Source # | Its a Functor  | 
| Applicative NonEmptyZipper Source # | Its Applicative, but   | 
| Foldable NonEmptyZipper Source # | Its Foldable  | 
| Eq a => Eq (NonEmptyZipper a) Source # | |
| Ord a => Ord (NonEmptyZipper a) Source # | |
| Show a => Show (NonEmptyZipper a) Source # | |
| Semigroup (NonEmptyZipper a) Source # | Its a   | 
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
next :: NonEmptyZipper a -> NonEmptyZipper a Source #
Advance the current element forward by one. If the current is the last element in the list, we do nothing.
nextMod :: NonEmptyZipper a -> NonEmptyZipper a Source #
Advance the current element forward by one. If the current is the last element in the list, we loop back to the first.
previous :: NonEmptyZipper a -> NonEmptyZipper a Source #
Move the current element backward by one. If the current is the first element in the list, we do nothing.
previousMod :: NonEmptyZipper a -> NonEmptyZipper a Source #
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.
fromNonEmpty :: NonEmpty a -> NonEmptyZipper a Source #
Convert from NonEmpty. The first element will be the current element.
inTheBeginning :: NonEmptyZipper a -> Bool Source #
Is the current selection the first item in the collection?
inTheEnd :: NonEmptyZipper a -> Bool Source #
Is the current selection the last item in the collection?
getPosition :: NonEmptyZipper a -> Int Source #
Get the index of the current element in the collection.
length :: NonEmptyZipper a -> Int Source #
Measure the size of the collection. Will be atleast 1.
head :: NonEmptyZipper a -> a Source #
Get the first element out of the NonEmptyZipper.
init :: NonEmptyZipper a -> Maybe (NonEmptyZipper a) Source #
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.
tail :: NonEmptyZipper a -> Maybe (NonEmptyZipper a) Source #
Get all elements out of the NonEmptyZipper that are not the first element.
 If there is only one element in the collection, its Nothing.
reverse :: NonEmptyZipper a -> NonEmptyZipper a Source #
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
setCurrentIndex :: Int -> NonEmptyZipper a -> Maybe (NonEmptyZipper a) Source #
Set the current element in the NonEmptyZipper via index location.
 If the index is out of bounds the results will be Nothing.