Hyperlinkv0.8.0-beta.28

Tuple

Tuple.appendElementsconsteffect/Tuple.ts:240
<const T2 extends ReadonlyArray<unknown>>(that: T2): <
  const T1 extends ReadonlyArray<unknown>
>(
  self: T1
) => [...T1, ...T2]
<
  const T1 extends ReadonlyArray<unknown>,
  const T2 extends ReadonlyArray<unknown>
>(
  self: T1,
  that: T2
): [...T1, ...T2]

Concatenates two tuples into a single tuple.

When to use

Use to append all elements from one tuple to another tuple.

Details

The result type is [...T1, ...T2], preserving all element types from both tuples. Neither input tuple is mutated; a fresh tuple is returned.

Example (Concatenating tuples)

import { pipe, Tuple } from "effect"

const result = pipe(Tuple.make(1, 2), Tuple.appendElements(["a", "b"] as const))
console.log(result) // [1, 2, "a", "b"]
combiningappendElement
Source effect/Tuple.ts:24012 lines
export const appendElements: {
  <const T2 extends ReadonlyArray<unknown>>(
    that: T2
  ): <const T1 extends ReadonlyArray<unknown>>(self: T1) => [...T1, ...T2]
  <const T1 extends ReadonlyArray<unknown>, const T2 extends ReadonlyArray<unknown>>(self: T1, that: T2): [...T1, ...T2]
} = dual(
  2,
  <T1 extends ReadonlyArray<unknown>, T2 extends ReadonlyArray<unknown>>(
    self: T1,
    that: T2
  ): [...T1, ...T2] => [...self, ...that]
)