OrderTypeLambdaType lambda for the Order type class, used internally for higher-kinded type operations.
When to use
Use when you need to abstract over Order in higher-kinded type code.
Details
This is type-level only, has no runtime representation, and is used internally by the Effect type system.
type lambdas
Source effect/Order.ts:723 lines
export interface OrderTypeLambda extends import TypeLambdaTypeLambda {
readonly OrderTypeLambda.type: Order<this["Target"]>type: 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<this["Target"]>
}