Data.ZipperArray
- Package
- purescript-zipperarray
- Repository
- jamieyung/purescript-zipperarray
#ZipperArray Source
data ZipperArray a
A ZipperArray
is represented by a NonEmptyArray
, an index into the
array, and the element at that index. The constructor is kept private so
that correctness guarantees can be ensured (as long as all the functions
are correct).
Instances
#DeleteFocusedItemFocusBumpPolicy Source
data DeleteFocusedItemFocusBumpPolicy
If the focused item is the one that was deleted, this policy describes which adjacent item should be focused (if possible).
Constructors
#DeleteItemResult Source
data DeleteItemResult a
Constructors
Instances
(Eq a) => Eq (DeleteItemResult a)
(Show a) => Show (DeleteItemResult a)
#singleton Source
singleton :: forall a. a -> ZipperArray a
Constructs a ZipperArray from a single item. The current item of the resultant ZipperArray is the given item.
#fromArray Source
fromArray :: forall a. Array a -> Maybe (ZipperArray a)
Constructs a ZipperArray from an array of items. Returns Nothing if the array is empty. Focuses the first item.
#fromNonEmptyArray Source
fromNonEmptyArray :: forall a. NonEmptyArray a -> ZipperArray a
Constructs a ZipperArray from a NonEmptyArray
. Focuses the first item.
#cons Source
cons :: forall a. a -> ZipperArray a -> ZipperArray a
#cons' Source
cons' :: forall a. a -> Array a -> ZipperArray a
#appendArray Source
appendArray :: forall a. ZipperArray a -> Array a -> ZipperArray a
#modifyCurrent Source
modifyCurrent :: forall a. (a -> a) -> ZipperArray a -> ZipperArray a
#modifyAt Source
modifyAt :: forall a. Natural -> (a -> a) -> ZipperArray a -> Maybe (ZipperArray a)
#deleteWith Source
deleteWith :: forall a. DeleteFocusedItemFocusBumpPolicy -> (a -> Boolean) -> ZipperArray a -> DeleteItemResult a
#toArray Source
toArray :: forall a. ZipperArray a -> Array a
#toNonEmptyArray Source
toNonEmptyArray :: forall a. ZipperArray a -> NonEmptyArray a
#toCurrentSingleton Source
toCurrentSingleton :: forall a. ZipperArray a -> ZipperArray a
Returns a ZipperArray containing just the current item.
#prec Source
prec :: forall a. ZipperArray a -> Array a
Returns all the items preceding the current item in the array.
#current Source
current :: forall a. ZipperArray a -> a
Returns the current item.
#succ Source
succ :: forall a. ZipperArray a -> Array a
Returns all the items succeeding the current item in the array.
#prev Source
prev :: forall a. ZipperArray a -> Maybe a
Returns the item immediately preceding the current item if it exists, Nothing otherwise.
#next Source
next :: forall a. ZipperArray a -> Maybe a
Returns the item immediately succeeding the current item if it exists, Nothing otherwise.
#foldlCurrent Source
foldlCurrent :: forall a b. { cur :: b -> a -> b, rest :: b -> a -> b } -> b -> ZipperArray a -> b
Performs a foldl using the provided functions to transform the items. The
cur
function is used for the current item, and the rest
function is
used for the other items.
#foldrCurrent Source
foldrCurrent :: forall a b. { cur :: a -> b -> b, rest :: a -> b -> b } -> b -> ZipperArray a -> b
Performs a foldr using the provided functions to transform the items. The
cur
function is used for the current item, and the rest
function is
used for the other items.
#foldlWithIndexCurrent Source
foldlWithIndexCurrent :: forall a b. { cur :: Int -> b -> a -> b, rest :: Int -> b -> a -> b } -> b -> ZipperArray a -> b
Performs a foldlWithIndex using the provided functions to transform the
items. The cur
function is used for the current item, and the rest
function is used for the other items.
#foldrWithIndexCurrent Source
foldrWithIndexCurrent :: forall a b. { cur :: Int -> a -> b -> b, rest :: Int -> a -> b -> b } -> b -> ZipperArray a -> b
Performs a foldrWithIndex using the provided functions to transform the
items. The cur
function is used for the current item, and the rest
function is used for the other items.
#atStart Source
atStart :: forall a. ZipperArray a -> Boolean
Returns true if the current item is the head of the array, false otherwise.
#atEnd Source
atEnd :: forall a. ZipperArray a -> Boolean
Returns true if the current item is the last item in the array, false otherwise.
#curIndex Source
curIndex :: forall a. ZipperArray a -> Natural
Returns the index of the current item in the array.
#length Source
length :: forall a. ZipperArray a -> Int
Returns the number of items in the array.
#focusWith Source
focusWith :: forall a. (a -> Boolean) -> ZipperArray a -> Maybe (ZipperArray a)
#goIndex Source
goIndex :: forall a. Natural -> ZipperArray a -> Maybe (ZipperArray a)
#goFirst Source
goFirst :: forall a. ZipperArray a -> ZipperArray a
Focuses the head of the array.
#goLast Source
goLast :: forall a. ZipperArray a -> ZipperArray a
Focuses the last item in the array.
#goPrev Source
goPrev :: forall a. ZipperArray a -> Maybe (ZipperArray a)
Focuses the previous item in the array if it exists. Returns Nothing if there is no item preceding the current item.
#goNext Source
goNext :: forall a. ZipperArray a -> Maybe (ZipperArray a)
Focuses the next item in the array if it exists. Returns Nothing if there is no item succeeding the current item.
#mapCurrent Source
mapCurrent :: forall a b. { cur :: a -> b, rest :: a -> b } -> ZipperArray a -> ZipperArray b
Performs a map, using the provided functions to transform the items. The
cur
function is used for the current item, and the rest
function is
used for the other items.
- Modules
- Data.
ZipperArray