effect-io-ai

Package: effect
Module: Combiner

Combiner.Combiner

Represents a strategy for combining two values of the same type A. A Combiner contains a single combine method that takes two values and returns a merged result. It does not include an identity/empty value; use Reducer when you need one.

When to use

Use when you need to describe how two values of the same type merge, pass a reusable combining strategy to library functions like Struct.makeCombiner or Option.makeCombinerFailFast, or define the combining step for a Reducer.

Example (Combining numbers with addition)

import { Combiner } from "effect"

const Sum = Combiner.make<number>((self, that) => self + that)

console.log(Sum.combine(3, 4))
// Output: 7

See

Signature

export interface Combiner<A> {
  /**
   * Combines two values into a new value.
   *
   * **When to use**
   *
   * Use to merge two values according to this combining strategy.
   */
  readonly combine: (self: A, that: A) => A
}

Source

Since v4.0.0