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

Copyright(C) 2017 Isaac Shapira
LicenseBSD-style (see the file LICENSE)
MaintainerIsaac Shapira <fresheyeball@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.List.NonEmptyZipper

Description

Its the Zipper for NonEmpty lists.

Synopsis

Documentation

data NonEmptyZipper a Source #

Constructors

NonEmptyZipper 

Fields

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.