readonly [A, ...A[]]A readonly array guaranteed to have at least one element.
When to use
Use when non-emptiness must be tracked at the type level while preventing mutation. Many Array module functions accept or return this type.
Example (Typing a non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyReadonlyArray<number> = [1, 2, 3]
const head: number = nonEmpty[0] // guaranteed to existSource effect/Array.ts:841 lines
export type type NonEmptyReadonlyArray<A> = readonly [
A,
...A[]
]
A readonly array guaranteed to have at least one element.
When to use
Use when non-emptiness must be tracked at the type level while preventing mutation.
Many Array module functions accept or return this type.
Example (Typing a non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyReadonlyArray<number> = [1, 2, 3]
const head: number = nonEmpty[0] // guaranteed to exist
NonEmptyReadonlyArray<function (type parameter) A in type NonEmptyReadonlyArray<A>A> = readonly [function (type parameter) A in type NonEmptyReadonlyArray<A>A, ...interface Array<T>Array<function (type parameter) A in type NonEmptyReadonlyArray<A>A>]Referenced by 153 symbols
Array.ReadonlyArrayArray.appendAllArray.chopArray.chunksOfArray.copyArray.dedupeArray.dedupeWithArray.flatMapArray.groupArray.groupWithArray.headNonEmptyArray.initNonEmptyArray.intersperseArray.isReadonlyArrayNonEmptyArray.lastNonEmptyArray.matchArray.maxArray.minArray.modifyHeadNonEmptyArray.modifyLastNonEmptyArray.prependAllArray.reverseArray.rotateArray.setHeadNonEmptyArray.setLastNonEmptyArray.someArray.sortArray.sortByArray.sortWithArray.splitAtNonEmptyArray.tailNonEmptyArray.unappendArray.unionArray.unionWithArray.unprependArray.unzipArray.zipArray.zipWithChannel.bufferArrayChannel.callbackArray+113 more