Hyperlinkv0.8.0-beta.28

Combiner

Combiner.maxfunctioneffect/Combiner.ts:185
<A>(order: Order.Order<A>): Combiner<A>

Creates a Combiner that returns the larger of two values according to the provided Order.

When to use

Use when you want to accumulate the maximum value across a collection or build a Reducer that tracks the running maximum.

Details

The combiner compares values using the given Order. When values are equal, it returns that (the second argument).

Example (Selecting the maximum of two numbers)

import { Combiner, Number } from "effect"

const Max = Combiner.max(Number.Order)

console.log(Max.combine(3, 1))
// Output: 3

console.log(Max.combine(1, 3))
// Output: 3
constructorsmin
export function max<A>(order: Order.Order<A>): Combiner<A> {
  return make((self, that) => order(self, that) === 1 ? self : that)
}
Referenced by 2 symbols