Hyperlinkv0.8.0-beta.28

Order

Order.flipfunctioneffect/Order.ts:269
<A>(O: Order<A>): Order<A>

Creates a new Order that reverses the comparison order of the input Order.

When to use

Use when you need the reverse of an existing order.

Details

Returns a new order that swaps the arguments before comparison. If the original order returns -1, the flipped order returns 1, and vice versa. Equal comparisons remain 0.

Example (Reversing an Order)

import { Order } from "effect"

const flip = Order.flip(Order.Number)

console.log(flip(1, 2)) // 1
console.log(flip(2, 1)) // -1
console.log(flip(1, 1)) // 0
combinatorscombine
Source effect/Order.ts:2693 lines
export function flip<A>(O: Order<A>): Order<A> {
  return make((self, that) => O(that, self))
}