Hyperlinkv0.8.0-beta.28

Array

Array.NonEmptyReadonlyArraytypeeffect/Array.ts:84
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
Source effect/Array.ts:841 lines
export type NonEmptyReadonlyArray<A> = readonly [A, ...Array<A>]
Referenced by 153 symbols