effect-io-ai

Package: effect
Module: Reducer

Reducer.flip

Reverses the argument order of a reducer’s combine method.

When to use

Use when you want the right-hand value to act as the accumulator, or need to reverse a non-commutative reducer such as string concatenation.

Details

Example (Reversing string concatenation)

import { Reducer, String } from "effect"

const Prepend = Reducer.flip(String.ReducerConcat)

console.log(Prepend.combine("a", "b"))
// Output: "ba"

console.log(Prepend.combineAll(["a", "b", "c"]))
// Output: "cba"

See

Signature

declare const flip: <A>(reducer: Reducer<A>) => Reducer<A>

Source

Since v4.0.0