[A, ...A[]]A mutable array guaranteed to have at least one element.
When to use
Use when mutation is acceptable and non-emptiness must be tracked at the type level.
Details
This is the mutable counterpart of NonEmptyReadonlyArray. Most Array
module functions return NonEmptyArray when the result is guaranteed
non-empty.
Example (Typing a mutable non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyArray<number> = [1, 2, 3]
nonEmpty.push(4)Source effect/Array.ts:1151 lines
export type type NonEmptyArray<A> = [A, ...A[]]A mutable array guaranteed to have at least one element.
When to use
Use when mutation is acceptable and non-emptiness must be tracked at the type
level.
Details
This is the mutable counterpart of
NonEmptyReadonlyArray
. Most Array
module functions return NonEmptyArray when the result is guaranteed
non-empty.
Example (Typing a mutable non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyArray<number> = [1, 2, 3]
nonEmpty.push(4)
NonEmptyArray<function (type parameter) A in type NonEmptyArray<A>A> = [function (type parameter) A in type NonEmptyArray<A>A, ...interface Array<T>Array<function (type parameter) A in type NonEmptyArray<A>A>]Referenced by 74 symbols
Array.ReadonlyArrayArray.appendArray.appendAllArray.chopArray.chunksOfArray.copyArray.dedupeArray.dedupeWithArray.flatMapArray.groupArray.groupByArray.groupWithArray.insertAtArray.intersperseArray.isArrayNonEmptyArray.makeArray.makeByArray.modifyHeadNonEmptyArray.modifyLastNonEmptyArray.ofArray.prependArray.prependAllArray.rangeArray.replicateArray.reverseArray.rotateArray.scanArray.scanRightArray.setHeadNonEmptyArray.setLastNonEmptyArray.sortArray.sortByArray.sortWithArray.splitAtNonEmptyArray.unionArray.unionWithArray.unzipArray.zipArray.zipWithChunk.Chunk+34 more