/**
* Provides a pointed array, which is a non-empty zipper-like array structure that tracks an index (focus)
* position in an array. Focus can be moved forward and backwards through the array.
*
* The array `[1, 2, 3, 4]` with focus on `3` is represented by `Zipper([1, 2], 3, [4])`
*
* Adapted from
*
* - https://github.com/DavidHarrison/purescript-list-zipper
* - https://github.com/thunklife/purescript-zipper
* - https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Zipper.scala
*
* @since 0.1.6
*/
import { Applicative1 } from 'fp-ts/lib/Applicative'
import { Apply1 } from 'fp-ts/lib/Apply'
import { Comonad1 } from 'fp-ts/lib/Comonad'
import { Foldable1 } from 'fp-ts/lib/Foldable'
import { Predicate } from 'fp-ts/lib/function'
import { Functor1 } from 'fp-ts/lib/Functor'
import { FunctorWithIndex1 } from 'fp-ts/lib/FunctorWithIndex'
import { Monoid } from 'fp-ts/lib/Monoid'
import * as NEA from 'fp-ts/lib/NonEmptyArray'
import * as O from 'fp-ts/lib/Option'
import { Semigroup } from 'fp-ts/lib/Semigroup'
import { Show } from 'fp-ts/lib/Show'
import { Traversable1 } from 'fp-ts/lib/Traversable'
import { ReadonlyNonEmptyArray } from 'fp-ts/ReadonlyNonEmptyArray'
import NonEmptyArray = NEA.NonEmptyArray
import Option = O.Option
/**
* @category model
* @since 0.1.6
*/
export interface Zipper {
readonly lefts: Array
readonly focus: A
readonly rights: Array
}
/**
* Creates a new zipper.
*
* @category constructors
* @since 0.1.6
*/
export declare const make: (lefts: ReadonlyArray, focus: A, rights: ReadonlyArray) => Zipper
/**
* @category constructors
* @since 0.1.23
*/
export declare const fromReadonlyArray: (as: ReadonlyArray, focusIndex?: number) => Option>
/**
* @category constructors
* @since 0.1.6
*/
export declare const fromArray: (as: Array, focusIndex?: number) => Option>
/**
* @category constructors
* @since 0.1.23
*/
export declare const fromReadonlyNonEmptyArray: (rnea: ReadonlyNonEmptyArray) => Zipper
/**
* @category constructors
* @since 0.1.6
*/
export declare const fromNonEmptyArray: (nea: NonEmptyArray) => Zipper
/**
* @category destructors
* @since 0.1.18
*/
export declare const isOutOfBound: (index: number, fa: Zipper) => boolean
/**
* @category destructors
* @since 0.1.6
*/
export declare const length: (fa: Zipper) => number
/**
* @category destructors
* @since 0.1.23
*/
export declare const toNonEmptyArray: (fa: Zipper) => NonEmptyArray
/**
* @category destructors
* @since 0.1.23
*/
export declare const toReadonlyNonEmptyArray: (fa: Zipper) => ReadonlyNonEmptyArray
/**
* @category destructors
* @since 0.1.6
* @deprecated Use the new {@link toNonEmptyArray} destructor instead.
*/
export declare const toArray: (fa: Zipper) => Array
/**
* Updates the focus of the zipper.
*
* @category combinators
* @since 0.1.6
*/
export declare const update: (a: A) => (fa: Zipper) => Zipper
/**
* Applies `f` to the focus and update with the result.
*
* @category combinators
* @since 0.1.6
*/
export declare const modify: (f: (a: A) => A) => (fa: Zipper) => Zipper
/**
* Moves focus in the zipper, or `None` if there is no such element.
*
* @category combinators
* @since 0.1.6
*/
export declare const move: (f: (currentIndex: number) => number, fa: Zipper) => Option>
/**
* Find the first index for which a predicate holds.
*
* @category utils
* @since 0.1.24
*/
export declare const findIndex: (predicate: Predicate) => (fa: Zipper) => Option
/**
* Use a function to find and focus the first matching element in the array. If
* no element matches, `None` is returned. If an element matches,
* `Some>` is returned.
*
* @category combinators
* @since 0.1.26
*/
export declare const moveByFindFirst: (predicate: Predicate) => (fa: Zipper) => O.Option>
/**
* Moves focus of the zipper up.
*
* @category combinators
* @since 0.1.6
*/
export declare const up: (fa: Zipper) => Option>
/**
* Moves focus of the zipper down.
*
* @category combinators
* @since 0.1.6
*/
export declare const down: (fa: Zipper) => Option>
/**
* Moves focus to the start of the zipper.
*
* @category combinators
* @since 0.1.6
*/
export declare const start: (fa: Zipper) => Zipper
/**
* Moves focus to the end of the zipper.
*
* @category combinators
* @since 0.1.6
*/
export declare const end: (fa: Zipper) => Zipper
/**
* Inserts an element to the left of the focus and focuses on the new element.
*
* @category combinators
* @since 0.1.6
*/
export declare const insertLeft: (a: A) => (fa: Zipper) => Zipper
/**
* Inserts an element to the right of the focus and focuses on the new element.
*
* @category combinators
* @since 0.1.6
*/
export declare const insertRight: (a: A) => (fa: Zipper) => Zipper
/**
* Deletes the element at focus and moves the focus to the left. If there is no element on the left,
* the focus is moved to the right.
*
* @category combinators
* @since 0.1.6
*/
export declare const deleteLeft: (fa: Zipper) => Option>
/**
* Deletes the element at focus and moves the focus to the right. If there is no element on the right,
* the focus is moved to the left.
*
* @category combinators
* @since 0.1.6
*/
export declare const deleteRight: (fa: Zipper) => Option>
/**
* @category Functor
* @since 0.1.18
*/
export declare const map: (f: (a: A) => B) => (fa: Zipper) => Zipper
/**
* @category FunctorWithIndex
* @since 0.1.18
*/
export declare const mapWithIndex: (f: (i: number, a: A) => B) => (fa: Zipper) => Zipper
/**
* @category Apply
* @since 0.1.18
*/
export declare const ap: (fa: Zipper) => (fab: Zipper<(a: A) => B>) => Zipper
/**
* @category Apply
* @since 0.1.18
*/
export declare const apFirst: (fb: Zipper) => (fa: Zipper) => Zipper
/**
* @category Apply
* @since 0.1.18
*/
export declare const apSecond: (fb: Zipper) => (fa: Zipper) => Zipper
/**
* @category Applicative
* @since 0.1.6
*/
export declare const of: (focus: A) => Zipper
/**
* @category Extend
* @since 0.1.18
*/
export declare const extend: (f: (fa: Zipper) => B) => (wa: Zipper) => Zipper
/**
* @category Extend
* @since 0.1.18
*/
export declare const duplicate: (wa: Zipper) => Zipper>
/**
* @category Foldable
* @since 0.1.18
*/
export declare const foldMap: (M: Monoid) => (f: (a: A) => M) => (fa: Zipper) => M
/**
* @category Foldable
* @since 0.1.18
*/
export declare const reduce: (b: B, f: (b: B, a: A) => B) => (fa: Zipper) => B
/**
* @category Foldable
* @since 0.1.18
*/
export declare const reduceRight: (b: B, f: (a: A, b: B) => B) => (fa: Zipper) => B
/**
* @category Traversable
* @since 0.1.18
*/
export declare const sequence: Traversable1['sequence']
/**
* @category Comonad
* @since 0.1.18
*/
export declare const extract: Comonad1['extract']
/**
* @category instances
* @since 0.1.6
*/
export declare const URI = 'Zipper'
/**
* @category instances
* @since 0.1.6
*/
export declare type URI = typeof URI
declare module 'fp-ts/lib/HKT' {
interface URItoKind {
Zipper: Zipper
}
}
/**
* @category instances
* @since 0.1.6
*/
export declare const getShow: (S: Show) => Show>
/**
* @category instances
* @since 0.1.6
*/
export declare const getSemigroup: (S: Semigroup) => Semigroup>
/**
* @category instances
* @since 0.1.6
*/
export declare const getMonoid: (M: Monoid) => Monoid>
/**
* @category instances
* @since 0.1.18
*/
export declare const Functor: Functor1
/**
* @category instances
* @since 0.1.18
*/
export declare const FunctorWithIndex: FunctorWithIndex1
/**
* @category instances
* @since 0.1.18
*/
export declare const Applicative: Applicative1
/**
* @category instances
* @since 0.1.18
*/
export declare const Apply: Apply1
/**
* @category instances
* @since 0.1.18
*/
export declare const Foldable: Foldable1
/**
* @category instances
* @since 0.1.18
*/
export declare const Traversable: Traversable1
/**
* @category instances
* @since 0.1.18
*/
export declare const Comonad: Comonad1
/**
* @category instances
* @since 0.1.6
*/
export declare const zipper: Applicative1 &
Foldable1 &
Traversable1 &
Comonad1 &
FunctorWithIndex1