Hyperlinkv0.8.0-beta.28

Order

Order.maxconsteffect/Order.ts:835
<A>(O: Order<A>): { (that: A): (self: A) => A; (self: A, that: A): A }

Returns the maximum of two values according to the given order. If they are equal, returns the first argument.

When to use

Use when you need to select the larger of two values according to an Order.

Details

Returns the value that compares as greater than or equal to the other value. If values are equal, the first argument is returned.

Example (Selecting the maximum value)

import { Order } from "effect"

const maxNumber = Order.max(Order.Number)

console.log(maxNumber(1, 2)) // 2
console.log(maxNumber(2, 1)) // 2
console.log(maxNumber(1, 1)) // 1
comparisonsminclamp
Source effect/Order.ts:8354 lines
export const max = <A>(O: Order<A>): {
  (that: A): (self: A) => A
  (self: A, that: A): A
} => dual(2, (self: A, that: A) => self === that || O(self, that) > -1 ? self : that)
Referenced by 6 symbols