Copyright | (C) 2017 Isaac Shapira |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Isaac Shapira <fresheyeball@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Its the Zipper for NonEmpty lists.
- data NonEmptyZipper a = NonEmptyZipper {}
- current :: forall a. Lens' (NonEmptyZipper a) a
- before :: forall a. Lens' (NonEmptyZipper a) [a]
- after :: forall a. Lens' (NonEmptyZipper a) [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
Documentation
data NonEmptyZipper a Source #
Functor NonEmptyZipper Source # | |
Applicative NonEmptyZipper Source # | |
Eq a => Eq (NonEmptyZipper a) Source # | |
Ord a => Ord (NonEmptyZipper a) Source # | |
Show a => Show (NonEmptyZipper a) Source # | |
Semigroup (NonEmptyZipper a) Source # | |
current :: forall a. Lens' (NonEmptyZipper a) a Source #
before :: forall a. Lens' (NonEmptyZipper a) [a] Source #
after :: forall a. Lens' (NonEmptyZipper a) [a] Source #
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.