(self: boolean, that: boolean): OrderingProvides an Order instance for boolean that allows comparing and sorting boolean values.
In this ordering, false is considered less than true.
When to use
Use when you need to sort or compare boolean values through APIs that accept
an ordering instance where false comes before true.
Example (Comparing booleans)
import { Boolean } from "effect"
console.log(Boolean.Order(false, true)) // -1 (false < true)
console.log(Boolean.Order(true, false)) // 1 (true > false)
console.log(Boolean.Order(true, true)) // 0 (true === true)export const const Order: order.Order<boolean>Provides an Order instance for boolean that allows comparing and sorting boolean values.
In this ordering, false is considered less than true.
When to use
Use when you need to sort or compare boolean values through APIs that accept
an ordering instance where false comes before true.
Example (Comparing booleans)
import { Boolean } from "effect"
console.log(Boolean.Order(false, true)) // -1 (false < true)
console.log(Boolean.Order(true, false)) // 1 (true > false)
console.log(Boolean.Order(true, true)) // 0 (true === true)
Order: import orderorder.interface Order<in A>Represents a total ordering for values of type A.
When to use
Use when you need to define how values of a type are compared.
Details
An order returns -1 when the first value is less than the second, 0 when
the values are equal according to this ordering, and 1 when the first value
is greater than the second. It must satisfy total ordering laws: totality,
antisymmetry, and transitivity.
Example (Defining a custom Order)
import { Order } from "effect"
const byAge: Order.Order<{ name: string; age: number }> = (self, that) => {
if (self.age < that.age) return -1
if (self.age > that.age) return 1
return 0
}
const person1 = { name: "Alice", age: 30 }
const person2 = { name: "Bob", age: 25 }
console.log(byAge(person1, person2)) // 1
Order<boolean> = import orderorder.const Boolean: Order<boolean>Order instance for booleans where false is considered less than true.
When to use
Use when you need boolean ordering where false comes before true.
Details
false is less than true, and equal values return 0.
Example (Ordering booleans)
import { Order } from "effect"
console.log(Order.Boolean(false, true)) // -1
console.log(Order.Boolean(true, false)) // 1
console.log(Order.Boolean(true, true)) // 0
Boolean