import { Applicative1 } from 'fp-ts/lib/Applicative'; import { Apply1 } from 'fp-ts/lib/Apply'; import { Comonad1 } from 'fp-ts/lib/Comonad'; import * as Eq from 'fp-ts/lib/Eq'; import { Extend1 } from 'fp-ts/lib/Extend'; import { Foldable1 } from 'fp-ts/lib/Foldable'; import { Functor1 } from 'fp-ts/lib/Functor'; import { FunctorWithIndex1 } from 'fp-ts/lib/FunctorWithIndex'; import * as Mn from 'fp-ts/lib/Monoid'; import * as O from 'fp-ts/lib/Option'; import * as RNEA from 'fp-ts/lib/ReadonlyNonEmptyArray'; import * as Sg from 'fp-ts/lib/Semigroup'; import * as Show from 'fp-ts/lib/Show'; import { Traversable1 } from 'fp-ts/lib/Traversable'; /** * ReadonlyArrayZipper is a "zipper" type for arrays - an array with a selected or "focused" item. * * Note: there is a fp-ts-contrib/lib/Zipper, but that is backed by `Array` rather than `ReadonlyArray`, so I'll go ahead with this * for now. Some of the functions were copied from fp-ts-contrib/lib/Zipper. * * If you need a type where zero or one items can be selected, see `ReadonlyArrayOrZipper` * * Some implementations of list zippers use the FP-style linked list, and with that, it makes sense to store the lefts * in reverse for O(1) moving the focus to the left. However, this is just using an Array, so I'm not going to reverse * the lefts. * * For more information, see here: http://data.tmorris.net/talks/zippers/bd054c210649101b84662c614fc45af3c27a5eef/zippers.pdf */ export declare type ReadonlyArrayZipper = { readonly lefts: ReadonlyArray; readonly focus: A; readonly rights: ReadonlyArray; }; /** * Constructs with the given value at the focus */ export declare const of: (focus: A) => ReadonlyArrayZipper; /** * Constructs from the given parts */ export declare const make: (lefts: readonly A[], focus: A, rights: readonly A[]) => ReadonlyArrayZipper; /** * Constructs from the given ReadonlyArray. The first item in the array will be the focus. If the array is empty, none is returned. */ export declare const fromReadonlyArray: (ra: readonly A[]) => O.Option>; /** * Constructs from the given ReadonlyNonEmptyArray. The head will be the focus and the tail the rights. */ export declare const fromReadonlyNonEmptyArray: (rnea: RNEA.ReadonlyNonEmptyArray) => ReadonlyArrayZipper; /** * Dumps the data structure into flattened array with each item flagged with whether it was focused */ export declare const toReadonlyArrayWithFocusFlag: (raz: ReadonlyArrayZipper) => readonly { value: A; isFocus: boolean; }[]; /** * Dumps the collection into a flattened array */ export declare const toReadonlyArray: (raz: ReadonlyArrayZipper) => readonly A[]; /** * Gets the length of the array */ export declare const length: (raz: ReadonlyArrayZipper) => number; /** * Moves the focus one item to the left. If the focus is at the left-most item, none is returned. */ export declare const moveLeft: (raz: ReadonlyArrayZipper) => O.Option>; /** * Moves the focus one item to the left. If the focus is at the left-most item, the array is returned unchanged. */ export declare const moveLeftWithClamp: (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; /** * Moves the focus one item to the right. If the focus is at the right-most item, none is returned. */ export declare const moveRight: (raz: ReadonlyArrayZipper) => O.Option>; /** * Moves the focus one item to the right. If the focus is at the right-most item, the array is returned unchanged. */ export declare const moveRightWithClamp: (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; /** * Overwrites the focus with the given value */ export declare const setFocus: (newFocus: A) => (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; /** * Modifies the focus with the given function. */ export declare const modifyFocus: (f: (a: A) => A) => (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; /** * Attempts to find the given value by checking just the focus. If the focus matches the given item, * the RAZ is returned wrapped in a some. */ export declare const findInFocus: (eq: Eq.Eq) => (item: A) => (raz: ReadonlyArrayZipper) => O.Option>; /** * Attempts to find the given value by checking just the values to the left of the focus. * If found, a new array is returned focused on the given item. */ export declare const findInLefts: (eq: Eq.Eq) => (item: A) => (raz: ReadonlyArrayZipper) => O.Option>; /** * Attempts to find the given value by checking just the values to the right of the focus. * If found, a new array is returned focused on the given item. */ export declare const findInRights: (eq: Eq.Eq) => (item: A) => (raz: ReadonlyArrayZipper) => O.Option>; /** * Attempts to find the given value by checking the focus, the values to the left of the focus and the values to the right of the focus. * If found, a new array is returned focused on the given item. */ export declare const find: (eq: Eq.Eq) => (item: A) => (raz: ReadonlyArrayZipper) => O.Option>; /** * Attempts to find the given value by checking the focus, the values to the left of the focus and the values to the right of the focus. * If found, a new array is returned focused on the given item. * If not found, the input array is returned unchanged. */ export declare const findOrKeep: (eq: Eq.Eq) => (item: A) => (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; /** * Maps a function over the collection */ export declare const map_: Functor1['map']; /** * Maps a function (with index) over the collection */ export declare const mapWithIndex_: FunctorWithIndex1['mapWithIndex']; /** * Applies a wrapped function to a collection */ export declare const ap_: Apply1['ap']; export declare const extend_: Extend1['extend']; export declare const map: (f: (a: A) => B) => (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; export declare const mapWithIndex: (f: (index: number, a: A) => B) => (raz: ReadonlyArrayZipper) => ReadonlyArrayZipper; export declare const ap: (fa: ReadonlyArrayZipper) => (fab: ReadonlyArrayZipper<(a: A) => B>) => ReadonlyArrayZipper; export declare const apFirst: (fb: ReadonlyArrayZipper) => (fa: ReadonlyArrayZipper) => ReadonlyArrayZipper; export declare const apSecond: (fb: ReadonlyArrayZipper) => (fa: ReadonlyArrayZipper) => ReadonlyArrayZipper; export declare const extend: (f: (fa: ReadonlyArrayZipper) => B) => (wa: ReadonlyArrayZipper) => ReadonlyArrayZipper; export declare const duplicate: (wa: ReadonlyArrayZipper) => ReadonlyArrayZipper>; export declare const foldMap: (M: Mn.Monoid) => (f: (a: A) => M) => (fa: ReadonlyArrayZipper) => M; export declare const reduce: (b: B, f: (b: B, a: A) => B) => (fa: ReadonlyArrayZipper) => B; export declare const reduceRight: (b: B, f: (a: A, b: B) => B) => (fa: ReadonlyArrayZipper) => B; export declare const sequence: Traversable1['sequence']; export declare const extract: Comonad1['extract']; export declare const URI = "ReadonlyArrayZipper"; export declare type URI = typeof URI; declare module 'fp-ts/lib/HKT' { interface URItoKind { ReadonlyArrayZipper: ReadonlyArrayZipper; } } export declare const getShow: (showA: Show.Show) => Show.Show>; export declare const getEq: (eqA: Eq.Eq) => Eq.Eq>; export declare const getSemigroup: (semigroupA: Sg.Semigroup) => Sg.Semigroup>; export declare const getMonoid: (monoidA: Mn.Monoid) => Mn.Monoid>; export declare const Functor: Functor1; export declare const FunctorWithIndex: FunctorWithIndex1; export declare const Apply: Apply1; export declare const Applicative: Applicative1; export declare const Foldable: Foldable1; export declare const Traversable: Traversable1; export declare const Comonad: Comonad1; export declare const readonlyArrayZipper: Applicative1 & Foldable1 & Traversable1 & Comonad1 & FunctorWithIndex1;