<A>(O: Order<A>): {
(that: A): (self: A) => boolean
(self: A, that: A): boolean
}Checks whether one value is less than or equal to another according to the given order.
When to use
Use when you need a boolean less-than-or-equal predicate using an Order.
Details
Returns true if the order returns -1 or 0, and returns false only if
the order returns 1.
Example (Checking less-than-or-equal comparisons)
import { Order } from "effect"
const isLessThanOrEqualToNumber = Order.isLessThanOrEqualTo(Order.Number)
console.log(isLessThanOrEqualToNumber(1, 2)) // true
console.log(isLessThanOrEqualToNumber(1, 1)) // true
console.log(isLessThanOrEqualToNumber(2, 1)) // falseexport const const isLessThanOrEqualTo: <A>(
O: Order<A>
) => {
(that: A): (self: A) => boolean
(self: A, that: A): boolean
}
Checks whether one value is less than or equal to another according to the given order.
When to use
Use when you need a boolean less-than-or-equal predicate using an Order.
Details
Returns true if the order returns -1 or 0, and returns false only if
the order returns 1.
Example (Checking less-than-or-equal comparisons)
import { Order } from "effect"
const isLessThanOrEqualToNumber = Order.isLessThanOrEqualTo(Order.Number)
console.log(isLessThanOrEqualToNumber(1, 2)) // true
console.log(isLessThanOrEqualToNumber(1, 1)) // true
console.log(isLessThanOrEqualToNumber(2, 1)) // false
isLessThanOrEqualTo = <function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A>(type O: Order<A>O: 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<function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A>): {
(that: Athat: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A): (self: Aself: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A) => boolean
(self: Aself: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A, that: Athat: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A): boolean
} => import dualdual(2, (self: Aself: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A, that: Athat: function (type parameter) A in <A>(O: Order<A>): {
(that: A): (self: A) => boolean;
(self: A, that: A): boolean;
}
A) => type O: Order<A>O(self: Aself, that: Athat) !== 1)