/**
* @since 2.5.0
*/
import { Alt1 } from './Alt'
import { Alternative1 } from './Alternative'
import { Applicative1 } from './Applicative'
import { Compactable1, Separated } from './Compactable'
import { Either } from './Either'
import { Eq } from './Eq'
import { Extend1 } from './Extend'
import { Filterable1 } from './Filterable'
import { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'
import { Foldable1 } from './Foldable'
import { FoldableWithIndex1 } from './FoldableWithIndex'
import { Lazy, Predicate, Refinement } from './function'
import { Functor1 } from './Functor'
import { FunctorWithIndex1 } from './FunctorWithIndex'
import { Monad1 } from './Monad'
import { Monoid } from './Monoid'
import * as O from './Option'
import { Ord } from './Ord'
import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'
import { Show } from './Show'
import { PipeableTraverse1, Traversable1 } from './Traversable'
import { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'
import { Unfoldable1 } from './Unfoldable'
import { PipeableWilt1, PipeableWither1, Witherable1 } from './Witherable'
import Option = O.Option
/**
* @category constructors
* @since 2.5.0
*/
export declare function fromArray(as: Array): ReadonlyArray
/**
* @category destructors
* @since 2.5.0
*/
export declare function toArray(ras: ReadonlyArray): Array
/**
* @category instances
* @since 2.5.0
*/
export declare function getShow(S: Show): Show>
/**
* Returns a `Monoid` for `ReadonlyArray`
*
* @example
* import { getMonoid } from 'fp-ts/ReadonlyArray'
*
* const M = getMonoid()
* assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])
*
* @category instances
* @since 2.5.0
*/
export declare function getMonoid(): Monoid>
/**
* Derives an `Eq` over the `ReadonlyArray` of a given element type from the `Eq` of that type. The derived `Eq` defines two
* arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of
* different lengths, the result is non equality.
*
* @example
* import { eqString } from 'fp-ts/Eq'
* import { getEq } from 'fp-ts/ReadonlyArray'
*
* const E = getEq(eqString)
* assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)
* assert.strictEqual(E.equals(['a'], []), false)
*
* @category instances
* @since 2.5.0
*/
export declare function getEq(E: Eq): Eq>
/**
* Derives an `Ord` over the `ReadonlyArray` of a given element type from the `Ord` of that type. The ordering between two such
* arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in
* case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have
* the same length, the result is equality.
*
* @example
* import { getOrd } from 'fp-ts/ReadonlyArray'
* import { ordString } from 'fp-ts/Ord'
*
* const O = getOrd(ordString)
* assert.strictEqual(O.compare(['b'], ['a']), 1)
* assert.strictEqual(O.compare(['a'], ['a']), 0)
* assert.strictEqual(O.compare(['a'], ['b']), -1)
*
*
* @category instances
* @since 2.5.0
*/
export declare function getOrd(O: Ord): Ord>
/**
* Return a list of length `n` with element `i` initialized with `f(i)`
*
* @example
* import { makeBy } from 'fp-ts/ReadonlyArray'
*
* const double = (n: number): number => n * 2
* assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])
*
* @category constructors
* @since 2.5.0
*/
export declare function makeBy(n: number, f: (i: number) => A): ReadonlyArray
/**
* Create an array containing a range of integers, including both endpoints
*
* @example
* import { range } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])
*
* @category constructors
* @since 2.5.0
*/
export declare function range(start: number, end: number): ReadonlyArray
/**
* Create an array containing a value repeated the specified number of times
*
* @example
* import { replicate } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])
*
* @category constructors
* @since 2.5.0
*/
export declare function replicate(n: number, a: A): ReadonlyArray
/**
* Removes one level of nesting
*
* Derivable from `Monad`.
*
* @example
* import { flatten } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(flatten([[1], [2], [3]]), [1, 2, 3])
*
* @category combinators
* @since 2.5.0
*/
export declare function flatten(mma: ReadonlyArray>): ReadonlyArray
/**
* Break an array into its first element and remaining elements
*
* @example
* import { foldLeft } from 'fp-ts/ReadonlyArray'
*
* const len: (as: ReadonlyArray) => number = foldLeft(() => 0, (_, tail) => 1 + len(tail))
* assert.strictEqual(len([1, 2, 3]), 3)
*
* @category destructors
* @since 2.5.0
*/
export declare function foldLeft(
onEmpty: Lazy,
onCons: (head: A, tail: ReadonlyArray) => B
): (as: ReadonlyArray) => B
/**
* Break an array into its initial elements and the last element
*
* @category destructors
* @since 2.5.0
*/
export declare function foldRight(
onEmpty: Lazy,
onCons: (init: ReadonlyArray, last: A) => B
): (as: ReadonlyArray) => B
/**
* Same as `reduce` but it carries over the intermediate steps
*
* @example
* import { scanLeft } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])
*
* @category combinators
* @since 2.5.0
*/
export declare function scanLeft(b: B, f: (b: B, a: A) => B): (as: ReadonlyArray) => ReadonlyArray
/**
* Fold an array from the right, keeping all intermediate results instead of only the final result
*
* @example
* import { scanRight } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])
*
* @category combinators
* @since 2.5.0
*/
export declare function scanRight(b: B, f: (a: A, b: B) => B): (as: ReadonlyArray) => ReadonlyArray
/**
* Test whether an array is empty
*
* @example
* import { isEmpty } from 'fp-ts/ReadonlyArray'
*
* assert.strictEqual(isEmpty([]), true)
*
* @since 2.5.0
*/
export declare function isEmpty(as: ReadonlyArray): boolean
/**
* Test whether an array is non empty narrowing down the type to `NonEmptyReadonlyArray`
*
* @category guards
* @since 2.5.0
*/
export declare function isNonEmpty(as: ReadonlyArray): as is ReadonlyNonEmptyArray
/**
* Test whether an array contains a particular index
*
* @since 2.5.0
*/
export declare function isOutOfBound(i: number, as: ReadonlyArray): boolean
/**
* This function provides a safe way to read a value at a particular index from an array
*
* @example
* import { lookup } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))
* assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)
*
* @since 2.5.0
*/
export declare function lookup(i: number): (as: ReadonlyArray) => Option
export declare function lookup(i: number, as: ReadonlyArray): Option
/**
* Attaches an element to the front of an array, creating a new non empty array
*
* @example
* import { cons } from 'fp-ts/ReadonlyArray'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], cons(0)), [0, 1, 2, 3])
*
* @category constructors
* @since 2.5.0
*/
export declare function cons(head: A): (tail: ReadonlyArray) => ReadonlyNonEmptyArray
export declare function cons(head: A, tail: ReadonlyArray): ReadonlyNonEmptyArray
/**
* Append an element to the end of an array, creating a new non empty array
*
* @example
* import { snoc } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4])
*
* @category constructors
* @since 2.5.0
*/
export declare function snoc(init: ReadonlyArray, end: A): ReadonlyNonEmptyArray
/**
* Get the first element in an array, or `None` if the array is empty
*
* @example
* import { head } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(head([1, 2, 3]), some(1))
* assert.deepStrictEqual(head([]), none)
*
* @since 2.5.0
*/
export declare function head(as: ReadonlyArray): Option
/**
* Get the last element in an array, or `None` if the array is empty
*
* @example
* import { last } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(last([1, 2, 3]), some(3))
* assert.deepStrictEqual(last([]), none)
*
* @since 2.5.0
*/
export declare function last(as: ReadonlyArray): Option
/**
* Get all but the first element of an array, creating a new array, or `None` if the array is empty
*
* @example
* import { tail } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))
* assert.deepStrictEqual(tail([]), none)
*
* @since 2.5.0
*/
export declare function tail(as: ReadonlyArray): Option>
/**
* Get all but the last element of an array, creating a new array, or `None` if the array is empty
*
* @example
* import { init } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))
* assert.deepStrictEqual(init([]), none)
*
* @since 2.5.0
*/
export declare function init(as: ReadonlyArray): Option>
/**
* Keep only a number of elements from the start of an array, creating a new array.
* `n` must be a natural number
*
* @example
* import { takeLeft } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(takeLeft(2)([1, 2, 3]), [1, 2])
*
* @category combinators
* @since 2.5.0
*/
export declare function takeLeft(n: number): (as: ReadonlyArray) => ReadonlyArray
/**
* Keep only a number of elements from the end of an array, creating a new array.
* `n` must be a natural number
*
* @example
* import { takeRight } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5])
*
* @since 2.5.0
*/
export declare function takeRight(n: number): (as: ReadonlyArray) => ReadonlyArray
/**
* Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array
*
* @example
* import { takeLeftWhile } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])
*
* @category combinators
* @since 2.5.0
*/
export declare function takeLeftWhile(
refinement: Refinement
): (as: ReadonlyArray) => ReadonlyArray
export declare function takeLeftWhile(predicate: Predicate): (as: ReadonlyArray) => ReadonlyArray
/**
* @since 2.5.0
*/
export interface Spanned {
readonly init: ReadonlyArray
readonly rest: ReadonlyArray
}
/**
* Split an array into two parts:
* 1. the longest initial subarray for which all elements satisfy the specified predicate
* 2. the remaining elements
*
* @example
* import { spanLeft } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(spanLeft((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })
*
* @since 2.5.0
*/
export declare function spanLeft(refinement: Refinement): (as: ReadonlyArray) => Spanned
export declare function spanLeft(predicate: Predicate): (as: ReadonlyArray) => Spanned
/**
* Drop a number of elements from the start of an array, creating a new array
*
* @example
* import { dropLeft } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3])
*
* @category combinators
* @since 2.5.0
*/
export declare function dropLeft(n: number): (as: ReadonlyArray) => ReadonlyArray
/**
* Drop a number of elements from the end of an array, creating a new array
*
* @example
* import { dropRight } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(dropRight(2)([1, 2, 3, 4, 5]), [1, 2, 3])
*
* @category combinators
* @since 2.5.0
*/
export declare function dropRight(n: number): (as: ReadonlyArray) => ReadonlyArray
/**
* Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array
*
* @example
* import { dropLeftWhile } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])
*
* @category combinators
* @since 2.5.0
*/
export declare function dropLeftWhile(predicate: Predicate): (as: ReadonlyArray) => ReadonlyArray
/**
* Find the first index for which a predicate holds
*
* @example
* import { findIndex } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))
* assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)
*
* @since 2.5.0
*/
export declare function findIndex(predicate: Predicate): (as: ReadonlyArray) => Option
/**
* Find the first element which satisfies a predicate (or a refinement) function
*
* @example
* import { findFirst } from 'fp-ts/ReadonlyArray'
* import { some } from 'fp-ts/Option'
*
* assert.deepStrictEqual(findFirst((x: { a: number, b: number }) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 1 }))
*
* @since 2.5.0
*/
export declare function findFirst(refinement: Refinement): (as: ReadonlyArray) => Option
export declare function findFirst(predicate: Predicate): (as: ReadonlyArray) => Option
/**
* Find the first element returned by an option based selector function
*
* @example
* import { findFirstMap } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* interface Person {
* name: string
* age?: number
* }
*
* const persons: ReadonlyArray = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]
*
* // returns the name of the first person that has an age
* assert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary'))
*
* @since 2.5.0
*/
export declare function findFirstMap(f: (a: A) => Option): (as: ReadonlyArray) => Option
/**
* Find the last element which satisfies a predicate function
*
* @example
* import { findLast } from 'fp-ts/ReadonlyArray'
* import { some } from 'fp-ts/Option'
*
* assert.deepStrictEqual(findLast((x: { a: number, b: number }) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 2 }))
*
* @since 2.5.0
*/
export declare function findLast(refinement: Refinement): (as: ReadonlyArray) => Option
export declare function findLast(predicate: Predicate): (as: ReadonlyArray) => Option
/**
* Find the last element returned by an option based selector function
*
* @example
* import { findLastMap } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* interface Person {
* name: string
* age?: number
* }
*
* const persons: ReadonlyArray = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]
*
* // returns the name of the last person that has an age
* assert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey'))
*
* @since 2.5.0
*/
export declare function findLastMap(f: (a: A) => Option): (as: ReadonlyArray) => Option
/**
* Returns the index of the last element of the list which matches the predicate
*
* @example
* import { findLastIndex } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* interface X {
* a: number
* b: number
* }
* const xs: ReadonlyArray = [{ a: 1, b: 0 }, { a: 1, b: 1 }]
* assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 1)(xs), some(1))
* assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 4)(xs), none)
*
*
* @since 2.5.0
*/
export declare function findLastIndex(predicate: Predicate): (as: ReadonlyArray) => Option
/**
* Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds
*
* @example
* import { insertAt } from 'fp-ts/ReadonlyArray'
* import { some } from 'fp-ts/Option'
*
* assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))
*
* @since 2.5.0
*/
export declare function insertAt(i: number, a: A): (as: ReadonlyArray) => Option>
/**
* Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds
*
* @example
* import { updateAt } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))
* assert.deepStrictEqual(updateAt(1, 1)([]), none)
*
* @since 2.5.0
*/
export declare function updateAt(i: number, a: A): (as: ReadonlyArray) => Option>
/**
* Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds
*
* @example
* import { deleteAt } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))
* assert.deepStrictEqual(deleteAt(1)([]), none)
*
* @since 2.5.0
*/
export declare function deleteAt(i: number): (as: ReadonlyArray) => Option>
/**
* Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out
* of bounds
*
* @example
* import { modifyAt } from 'fp-ts/ReadonlyArray'
* import { some, none } from 'fp-ts/Option'
*
* const double = (x: number): number => x * 2
* assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))
* assert.deepStrictEqual(modifyAt(1, double)([]), none)
*
* @since 2.5.0
*/
export declare function modifyAt(i: number, f: (a: A) => A): (as: ReadonlyArray) => Option>
/**
* Reverse an array, creating a new array
*
* @example
* import { reverse } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])
*
* @category combinators
* @since 2.5.0
*/
export declare function reverse(as: ReadonlyArray): ReadonlyArray
/**
* Extracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order
*
* @example
* import { rights } from 'fp-ts/ReadonlyArray'
* import { right, left } from 'fp-ts/Either'
*
* assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])
*
* @category combinators
* @since 2.5.0
*/
export declare function rights(as: ReadonlyArray>): ReadonlyArray
/**
* Extracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order
*
* @example
* import { lefts } from 'fp-ts/ReadonlyArray'
* import { left, right } from 'fp-ts/Either'
*
* assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])
*
* @since 2.5.0
*/
export declare function lefts(as: ReadonlyArray>): ReadonlyArray
/**
* Sort the elements of an array in increasing order, creating a new array
*
* @example
* import { sort } from 'fp-ts/ReadonlyArray'
* import { ordNumber } from 'fp-ts/Ord'
*
* assert.deepStrictEqual(sort(ordNumber)([3, 2, 1]), [1, 2, 3])
*
* @category combinators
* @since 2.5.0
*/
export declare const sort: (O: Ord) => (as: readonly A[]) => readonly A[]
/**
* Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one
* input array is short, excess elements of the longer array are discarded.
*
* @example
* import { zipWith } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3'])
*
* @category combinators
* @since 2.5.0
*/
export declare function zipWith(
fa: ReadonlyArray,
fb: ReadonlyArray,
f: (a: A, b: B) => C
): ReadonlyArray
/**
* Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the
* longer array are discarded
*
* @example
* import { zip } from 'fp-ts/ReadonlyArray'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [[1, 'a'], [2, 'b'], [3, 'c']])
*
* @category combinators
* @since 2.5.0
*/
export declare function zip(bs: ReadonlyArray): (as: ReadonlyArray) => ReadonlyArray
export declare function zip(as: ReadonlyArray, bs: ReadonlyArray): ReadonlyArray
/**
* The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays
*
* @example
* import { unzip } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']])
*
* @since 2.5.0
*/
export declare function unzip(as: ReadonlyArray): readonly [ReadonlyArray, ReadonlyArray]
/**
* Prepend an element to every member of an array
*
* @example
* import { prependToAll } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(prependToAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])
*
* @category combinators
* @since 2.9.0
*/
export declare const prependToAll: (e: A) => (xs: readonly A[]) => readonly A[]
/**
* Places an element in between members of an array
*
* @example
* import { intersperse } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])
*
* @category combinators
* @since 2.9.0
*/
export declare function intersperse(e: A): (as: ReadonlyArray) => ReadonlyArray
/**
* Rotate an array to the right by `n` steps
*
* @example
* import { rotate } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
*
* @category combinators
* @since 2.5.0
*/
export declare function rotate(n: number): (as: ReadonlyArray) => ReadonlyArray
/**
* Test if a value is a member of an array. Takes a `Eq` as a single
* argument which returns the function to use to search for a value of type `A` in
* an array of type `ReadonlyArray`.
*
* @example
* import { elem } from 'fp-ts/ReadonlyArray'
* import { eqNumber } from 'fp-ts/Eq'
* import { pipe } from 'fp-ts/function'
*
* assert.strictEqual(pipe([1, 2, 3], elem(eqNumber)(2)), true)
* assert.strictEqual(pipe([1, 2, 3], elem(eqNumber)(0)), false)
*
* @since 2.5.0
*/
export declare function elem(
E: Eq
): {
(a: A): (as: ReadonlyArray) => boolean
(a: A, as: ReadonlyArray): boolean
}
/**
* Remove duplicates from an array, keeping the first occurrence of an element.
*
* @example
* import { uniq } from 'fp-ts/ReadonlyArray'
* import { eqNumber } from 'fp-ts/Eq'
*
* assert.deepStrictEqual(uniq(eqNumber)([1, 2, 1]), [1, 2])
*
* @category combinators
* @since 2.5.0
*/
export declare function uniq(E: Eq): (as: ReadonlyArray) => ReadonlyArray
/**
* Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,
* etc...
*
* @example
* import { sortBy } from 'fp-ts/ReadonlyArray'
* import { ord, ordString, ordNumber } from 'fp-ts/Ord'
*
* interface Person {
* name: string
* age: number
* }
* const byName = ord.contramap(ordString, (p: Person) => p.name)
* const byAge = ord.contramap(ordNumber, (p: Person) => p.age)
*
* const sortByNameByAge = sortBy([byName, byAge])
*
* const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }]
* assert.deepStrictEqual(sortByNameByAge(persons), [
* { name: 'a', age: 1 },
* { name: 'b', age: 2 },
* { name: 'b', age: 3 },
* { name: 'c', age: 2 }
* ])
*
* @category combinators
* @since 2.5.0
*/
export declare function sortBy(ords: ReadonlyArray>): (as: ReadonlyArray) => ReadonlyArray
/**
* A useful recursion pattern for processing an array to produce a new array, often used for "chopping" up the input
* array. Typically chop is called with some function that will consume an initial prefix of the array and produce a
* value and the rest of the array.
*
* @example
* import { Eq, eqNumber } from 'fp-ts/Eq'
* import { chop, spanLeft } from 'fp-ts/ReadonlyArray'
*
* const group = (S: Eq): ((as: ReadonlyArray) => ReadonlyArray>) => {
* return chop(as => {
* const { init, rest } = spanLeft((a: A) => S.equals(a, as[0]))(as)
* return [init, rest]
* })
* }
* assert.deepStrictEqual(group(eqNumber)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])
*
* @category combinators
* @since 2.5.0
*/
export declare const chop: (
f: (as: ReadonlyNonEmptyArray) => readonly [B, readonly A[]]
) => (as: readonly A[]) => readonly B[]
/**
* Splits an array into two pieces, the first piece has `n` elements.
*
* @example
* import { splitAt } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]])
*
* @since 2.5.0
*/
export declare function splitAt(n: number): (as: ReadonlyArray) => readonly [ReadonlyArray, ReadonlyArray]
/**
* Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
* the array. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive
* definition of `chunksOf`; it satisfies the property that
*
* ```ts
* chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))
* ```
*
* whenever `n` evenly divides the length of `xs`.
*
* @example
* import { chunksOf } from 'fp-ts/ReadonlyArray'
*
* assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])
*
*
* @since 2.5.0
*/
export declare function chunksOf(n: number): (as: ReadonlyArray) => ReadonlyArray>
/**
* Array comprehension
*
* ```
* [ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]
* ```
*
* @example
* import { comprehension } from 'fp-ts/ReadonlyArray'
* import { tuple } from 'fp-ts/function'
*
* assert.deepStrictEqual(comprehension([[1, 2, 3], ['a', 'b']], tuple, (a, b) => (a + b.length) % 2 === 0), [
* [1, 'a'],
* [1, 'b'],
* [3, 'a'],
* [3, 'b']
* ])
*
* @category constructors
* @since 2.5.0
*/
export declare function comprehension(
input: readonly [ReadonlyArray, ReadonlyArray, ReadonlyArray, ReadonlyArray],
f: (a: A, b: B, c: C, d: D) => R,
g?: (a: A, b: B, c: C, d: D) => boolean
): ReadonlyArray
export declare function comprehension(
input: readonly [ReadonlyArray, ReadonlyArray, ReadonlyArray],
f: (a: A, b: B, c: C) => R,
g?: (a: A, b: B, c: C) => boolean
): ReadonlyArray
export declare function comprehension(
input: readonly [ReadonlyArray],
f: (a: A) => R,
g?: (a: A) => boolean
): ReadonlyArray
export declare function comprehension(
input: readonly [ReadonlyArray, ReadonlyArray],
f: (a: A, b: B) => R,
g?: (a: A, b: B) => boolean
): ReadonlyArray
export declare function comprehension(
input: readonly [ReadonlyArray],
f: (a: A) => boolean,
g?: (a: A) => R
): ReadonlyArray
/**
* Creates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons
*
* @example
* import { union } from 'fp-ts/ReadonlyArray'
* import { eqNumber } from 'fp-ts/Eq'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], union(eqNumber)([2, 3])), [1, 2, 3])
*
* @category combinators
* @since 2.5.0
*/
export declare function union(
E: Eq
): {
(xs: ReadonlyArray): (ys: ReadonlyArray) => ReadonlyArray
(xs: ReadonlyArray, ys: ReadonlyArray): ReadonlyArray
}
/**
* Creates an array of unique values that are included in all given arrays using a `Eq` for equality
* comparisons. The order and references of result values are determined by the first array.
*
* @example
* import { intersection } from 'fp-ts/ReadonlyArray'
* import { eqNumber } from 'fp-ts/Eq'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], intersection(eqNumber)([2, 3])), [2])
*
* @category combinators
* @since 2.5.0
*/
export declare function intersection(
E: Eq
): {
(xs: ReadonlyArray): (ys: ReadonlyArray) => ReadonlyArray
(xs: ReadonlyArray, ys: ReadonlyArray): ReadonlyArray
}
/**
* Creates an array of array values not included in the other given array using a `Eq` for equality
* comparisons. The order and references of result values are determined by the first array.
*
* @example
* import { difference } from 'fp-ts/ReadonlyArray'
* import { eqNumber } from 'fp-ts/Eq'
* import { pipe } from 'fp-ts/function'
*
* assert.deepStrictEqual(pipe([1, 2], difference(eqNumber)([2, 3])), [1])
*
* @category combinators
* @since 2.5.0
*/
export declare function difference(
E: Eq
): {
(xs: ReadonlyArray): (ys: ReadonlyArray) => ReadonlyArray
(xs: ReadonlyArray, ys: ReadonlyArray): ReadonlyArray
}
/**
* Wrap a value into the type constructor.
*
* @category Applicative
* @since 2.5.0
*/
export declare const of: Applicative1['of']
/**
* @category Alternative
* @since 2.7.0
*/
export declare const zero: Alternative1['zero']
/**
* Less strict version of [`alt`](#alt).
*
* @category Alt
* @since 2.9.0
*/
export declare const altW: (that: Lazy>) => (fa: ReadonlyArray) => ReadonlyArray
/**
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
* types of kind `* -> *`.
*
* @category Alt
* @since 2.5.0
*/
export declare const alt: (that: Lazy>) => (fa: ReadonlyArray) => ReadonlyArray
/**
* Apply a function to an argument under a type constructor.
*
* @category Apply
* @since 2.5.0
*/
export declare const ap: (fa: ReadonlyArray) => (fab: ReadonlyArray<(a: A) => B>) => ReadonlyArray
/**
* Combine two effectful actions, keeping only the result of the first.
*
* Derivable from `Apply`.
*
* @category combinators
* @since 2.5.0
*/
export declare const apFirst: (fb: ReadonlyArray) => (fa: ReadonlyArray) => ReadonlyArray
/**
* Combine two effectful actions, keeping only the result of the second.
*
* Derivable from `Apply`.
*
* @category combinators
* @since 2.5.0
*/
export declare const apSecond: (fb: readonly B[]) => (fa: readonly A[]) => readonly B[]
/**
* Composes computations in sequence, using the return value of one computation to determine the next computation.
*
* @category Monad
* @since 2.5.0
*/
export declare const chain: (f: (a: A) => ReadonlyArray) => (ma: ReadonlyArray) => ReadonlyArray
/**
* @since 2.7.0
*/
export declare const chainWithIndex: (
f: (i: number, a: A) => ReadonlyArray
) => (ma: ReadonlyArray) => ReadonlyArray
/**
* Composes computations in sequence, using the return value of one computation to determine the next computation and
* keeping only the result of the first.
*
* Derivable from `Monad`.
*
* @category combinators
* @since 2.5.0
*/
export declare const chainFirst: (f: (a: A) => ReadonlyArray) => (ma: ReadonlyArray) => ReadonlyArray
/**
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types
* use the type constructor `F` to represent some computational context.
*
* @category Functor
* @since 2.5.0
*/
export declare const map: (f: (a: A) => B) => (fa: ReadonlyArray) => ReadonlyArray
/**
* @category FunctorWithIndex
* @since 2.5.0
*/
export declare const mapWithIndex: (f: (i: number, a: A) => B) => (fa: ReadonlyArray) => ReadonlyArray
/**
* @category Compactable
* @since 2.5.0
*/
export declare const separate: (fa: readonly Either[]) => Separated
/**
* @category Filterable
* @since 2.5.0
*/
export declare const filter: {
(refinement: Refinement): (fa: ReadonlyArray) => ReadonlyArray
(predicate: Predicate): (fa: ReadonlyArray) => ReadonlyArray
}
/**
* @category FilterableWithIndex
* @since 2.5.0
*/
export declare const filterMapWithIndex: (
f: (i: number, a: A) => O.Option
) => (fa: readonly A[]) => readonly B[]
/**
* @category Filterable
* @since 2.5.0
*/
export declare const filterMap: (f: (a: A) => Option) => (fa: ReadonlyArray) => ReadonlyArray
/**
* @category Compactable
* @since 2.5.0
*/
export declare const compact: (fa: ReadonlyArray