/** * Data structure which represents non-empty arrays * * @since 2.5.0 */ import { Alt1 } from './Alt' import { Applicative1 } from './Applicative' import { Comonad1 } from './Comonad' import { Eq } from './Eq' 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 { Option } from './Option' import { Ord } from './Ord' import { ReadonlyRecord } from './ReadonlyRecord' import { Semigroup } from './Semigroup' import { Show } from './Show' import { PipeableTraverse1, Traversable1 } from './Traversable' import { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex' /** * @category model * @since 2.5.0 */ export declare type ReadonlyNonEmptyArray = ReadonlyArray & { readonly 0: A } /** * Append an element to the front of an array, creating a new non empty array * * @example * import { cons } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4]) * * @category constructors * @since 2.5.0 */ export declare const 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/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4]) * * @category constructors * @since 2.5.0 */ export declare const snoc: (init: ReadonlyArray, end: A) => ReadonlyNonEmptyArray /** * Builds a `ReadonlyNonEmptyArray` from an array returning `none` if `as` is an empty array * * @category constructors * @since 2.5.0 */ export declare function fromReadonlyArray(as: ReadonlyArray): Option> /** * @category constructors * @since 2.5.0 */ export declare function fromArray(as: Array): Option> /** * Produces a couple of the first element of the array, and a new array of the remaining elements, if any * * @example * import { cons, uncons } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(uncons(cons(1, [2, 3, 4])), [1, [2, 3, 4]]) * * @category destructors * @since 2.9.0 */ export declare function uncons(nea: ReadonlyNonEmptyArray): readonly [A, ReadonlyArray] /** * Produces a couple of a copy of the array without its last element, and that last element * * @example * import { snoc, unsnoc } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(unsnoc(snoc([1, 2, 3], 4)), [[1, 2, 3], 4]) * * @category destructors * @since 2.9.0 */ export declare function unsnoc(nea: ReadonlyNonEmptyArray): readonly [ReadonlyArray, A] /** * @category instances * @since 2.5.0 */ export declare const getShow: (S: Show) => Show> /** * @since 2.5.0 */ export declare function head(nea: ReadonlyNonEmptyArray): A /** * @since 2.5.0 */ export declare function tail(nea: ReadonlyNonEmptyArray): ReadonlyArray /** * @category combinators * @since 2.5.0 */ export declare const reverse: (nea: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @since 2.5.0 */ export declare function min(ord: Ord): (nea: ReadonlyNonEmptyArray) => A /** * @since 2.5.0 */ export declare function max(ord: Ord): (nea: ReadonlyNonEmptyArray) => A /** * Builds a `Semigroup` instance for `ReadonlyNonEmptyArray` * * @category instances * @since 2.5.0 */ export declare function getSemigroup(): Semigroup> /** * @example * import { getEq, cons } from 'fp-ts/ReadonlyNonEmptyArray' * import { eqNumber } from 'fp-ts/Eq' * * const E = getEq(eqNumber) * assert.strictEqual(E.equals(cons(1, [2]), [1, 2]), true) * assert.strictEqual(E.equals(cons(1, [2]), [1, 3]), false) * * @category instances * @since 2.5.0 */ export declare const getEq: (E: Eq) => Eq> /** * Group equal, consecutive elements of an array into non empty arrays. * * @example * import { cons, group } from 'fp-ts/ReadonlyNonEmptyArray' * import { ordNumber } from 'fp-ts/Ord' * * assert.deepStrictEqual(group(ordNumber)([1, 2, 1, 1]), [ * cons(1, []), * cons(2, []), * cons(1, [1]) * ]) * * @category combinators * @since 2.5.0 */ export declare function group( E: Eq ): { (as: ReadonlyNonEmptyArray): ReadonlyNonEmptyArray> (as: ReadonlyArray): ReadonlyArray> } /** * Sort and then group the elements of an array into non empty arrays. * * @example * import { cons, groupSort } from 'fp-ts/ReadonlyNonEmptyArray' * import { ordNumber } from 'fp-ts/Ord' * * assert.deepStrictEqual(groupSort(ordNumber)([1, 2, 1, 1]), [cons(1, [1, 1]), cons(2, [])]) * * @category combinators * @since 2.5.0 */ export declare function groupSort( O: Ord ): { (as: ReadonlyNonEmptyArray): ReadonlyNonEmptyArray> (as: ReadonlyArray): ReadonlyArray> } /** * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning * function on each element, and grouping the results according to values returned * * @example * import { cons, groupBy } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['foo', 'bar', 'foobar']), { * '3': cons('foo', ['bar']), * '6': cons('foobar', []) * }) * * @category constructors * @since 2.5.0 */ export declare function groupBy( f: (a: A) => string ): (as: ReadonlyArray) => ReadonlyRecord> /** * @since 2.5.0 */ export declare function last(nea: ReadonlyNonEmptyArray): A /** * Get all but the last element of a non empty array, creating a new array. * * @example * import { init } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(init([1, 2, 3]), [1, 2]) * assert.deepStrictEqual(init([1]), []) * * @since 2.5.0 */ export declare function init(nea: ReadonlyNonEmptyArray): ReadonlyArray /** * @category combinators * @since 2.5.0 */ export declare function sort(O: Ord): (nea: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @since 2.5.0 */ export declare function insertAt( i: number, a: A ): (nea: ReadonlyNonEmptyArray) => Option> /** * @since 2.5.0 */ export declare function updateAt( i: number, a: A ): (nea: ReadonlyNonEmptyArray) => Option> /** * @since 2.5.0 */ export declare function modifyAt( i: number, f: (a: A) => A ): (nea: ReadonlyNonEmptyArray) => Option> /** * @since 2.5.0 */ export declare function filter( refinement: Refinement ): (nea: ReadonlyNonEmptyArray) => Option> export declare function filter( predicate: Predicate ): (nea: ReadonlyNonEmptyArray) => Option> /** * @since 2.5.0 */ export declare function filterWithIndex( predicate: (i: number, a: A) => boolean ): (nea: ReadonlyNonEmptyArray) => Option> /** * Wrap a value into the type constructor. * * @category Applicative * @since 2.5.0 */ export declare const of: Applicative1['of'] /** * @category constructors * @since 2.5.0 */ export declare function concat(fx: ReadonlyArray, fy: ReadonlyNonEmptyArray): ReadonlyNonEmptyArray export declare function concat(fx: ReadonlyNonEmptyArray, fy: ReadonlyArray): ReadonlyNonEmptyArray /** * @since 2.5.0 */ export declare function fold(S: Semigroup): (fa: ReadonlyNonEmptyArray) => A /** * @category combinators * @since 2.5.1 */ export declare const zipWith: ( fa: ReadonlyNonEmptyArray, fb: ReadonlyNonEmptyArray, f: (a: A, b: B) => C ) => ReadonlyNonEmptyArray /** * @category combinators * @since 2.5.1 */ export declare const zip: { (bs: ReadonlyNonEmptyArray): (as: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray (as: ReadonlyNonEmptyArray, bs: ReadonlyNonEmptyArray): ReadonlyNonEmptyArray } /** * @since 2.5.1 */ export declare const unzip: ( as: ReadonlyNonEmptyArray ) => readonly [ReadonlyNonEmptyArray, ReadonlyNonEmptyArray] /** * Prepend an element to every member of an array * * @example * import { cons, prependToAll } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(prependToAll(9)(cons(1, [2, 3, 4])), cons(9, [1, 9, 2, 9, 3, 9, 4])) * * @category combinators * @since 2.9.0 */ export declare const prependToAll: (e: A) => (xs: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * Places an element in between members of an array * * @example * import { cons, intersperse } from 'fp-ts/ReadonlyNonEmptyArray' * * assert.deepStrictEqual(intersperse(9)(cons(1, [2, 3, 4])), cons(1, [9, 2, 9, 3, 9, 4])) * * @category combinators * @since 2.9.0 */ export declare const intersperse: (e: A) => (as: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @category FoldableWithIndex * @since 2.5.0 */ export declare const foldMapWithIndex: ( S: Semigroup ) => (f: (i: number, a: A) => S) => (fa: ReadonlyNonEmptyArray) => S /** * @category Foldable * @since 2.5.0 */ export declare const foldMap: (S: Semigroup) => (f: (a: A) => S) => (fa: ReadonlyNonEmptyArray) => S /** * Less strict version of [`alt`](#alt). * * @category Alt * @since 2.9.0 */ export declare const altW: ( that: Lazy> ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * 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.6.2 */ export declare const alt: ( that: Lazy> ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @category Apply * @since 2.5.0 */ export declare const ap: ( fa: ReadonlyNonEmptyArray ) => (fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray /** * 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: ReadonlyNonEmptyArray ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * 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: ReadonlyNonEmptyArray ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * 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) => ReadonlyNonEmptyArray ) => (ma: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * 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) => ReadonlyNonEmptyArray ) => (ma: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * Derivable from `Extend`. * * @category combinators * @since 2.5.0 */ export declare const duplicate: (ma: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray> /** * @category Extend * @since 2.5.0 */ export declare const extend: ( f: (fa: ReadonlyNonEmptyArray) => B ) => (ma: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * Derivable from `Monad`. * * @category combinators * @since 2.5.0 */ export declare const flatten: (mma: ReadonlyNonEmptyArray>) => ReadonlyNonEmptyArray /** * `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: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @category FunctorWithIndex * @since 2.5.0 */ export declare const mapWithIndex: ( f: (i: number, a: A) => B ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray /** * @category Foldable * @since 2.5.0 */ export declare const reduce: (b: B, f: (b: B, a: A) => B) => (fa: ReadonlyNonEmptyArray) => B /** * @category FoldableWithIndex * @since 2.5.0 */ export declare const reduceWithIndex: ( b: B, f: (i: number, b: B, a: A) => B ) => (fa: ReadonlyNonEmptyArray) => B /** * @category Foldable * @since 2.5.0 */ export declare const reduceRight: (b: B, f: (a: A, b: B) => B) => (fa: ReadonlyNonEmptyArray) => B /** * @category FoldableWithIndex * @since 2.5.0 */ export declare const reduceRightWithIndex: ( b: B, f: (i: number, a: A, b: B) => B ) => (fa: ReadonlyNonEmptyArray) => B /** * @since 2.6.3 */ export declare const traverse: PipeableTraverse1 /** * @since 2.6.3 */ export declare const sequence: Traversable1['sequence'] /** * @since 2.6.3 */ export declare const traverseWithIndex: PipeableTraverseWithIndex1 /** * @since 2.6.3 */ export declare const extract: Comonad1['extract'] /** * @category instances * @since 2.5.0 */ export declare const URI = 'ReadonlyNonEmptyArray' /** * @category instances * @since 2.5.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind { readonly [URI]: ReadonlyNonEmptyArray } } /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor1 /** * @category instances * @since 2.7.0 */ export declare const FunctorWithIndex: FunctorWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative1 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad1 /** * @category instances * @since 2.7.0 */ export declare const Foldable: Foldable1 /** * @category instances * @since 2.7.0 */ export declare const FoldableWithIndex: FoldableWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Traversable: Traversable1 /** * @category instances * @since 2.7.0 */ export declare const TraversableWithIndex: TraversableWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Alt: Alt1 /** * @category instances * @since 2.7.0 */ export declare const Comonad: Comonad1 /** * @category instances * @since 2.5.0 */ export declare const readonlyNonEmptyArray: Monad1 & Comonad1 & TraversableWithIndex1 & FunctorWithIndex1 & FoldableWithIndex1 & Alt1 /** * @since 2.9.0 */ export declare const Do: ReadonlyNonEmptyArray<{}> /** * @since 2.8.0 */ export declare const bindTo: ( name: N ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray<{ [K in N]: A }> /** * @since 2.8.0 */ export declare const bind: ( name: Exclude, f: (a: A) => ReadonlyNonEmptyArray ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @since 2.8.0 */ export declare const apS: ( name: Exclude, fb: ReadonlyNonEmptyArray ) => (fa: ReadonlyNonEmptyArray) => ReadonlyNonEmptyArray<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>