Hyperlinkv0.8.0-beta.28

Combiner

Combiner.minfunctioneffect/Combiner.ts:149
<A>(order: Order.Order<A>): Combiner<A>

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

When to use

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

Details

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

Example (Selecting the minimum of two numbers)

import { Combiner, Number } from "effect"

const Min = Combiner.min(Number.Order)

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

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