Hyperlinkv0.8.0-beta.28

Combiner

Combiner.flipfunctioneffect/Combiner.ts:113
<A>(combiner: Combiner<A>): Combiner<A>

Reverses the argument order of a combiner'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 combiner such as string concatenation.

Details

Returns a new Combiner where combine(self, that) calls the original combiner as combine(that, self).

Example (Reversing string concatenation)

import { Combiner, String } from "effect"

const Prepend = Combiner.flip(String.ReducerConcat)

console.log(Prepend.combine("a", "b"))
// Output: "ba"
combinatorsmake
export function flip<A>(combiner: Combiner<A>): Combiner<A> {
  return make((self, that) => combiner.combine(that, self))
}