Ord型クラス
全順序を付けられる型
Eq型クラスを継承する
methods
(>), (<), (>=), (<=)
code:hs
class Eq a => Ord a where
compare :: a -> a -> Ordering
(<), (<=), (>), (>=) :: a -> a -> Bool
max, min :: a -> a -> a
compare
fp-ts ref
code:ts
import { Eq } from 'fp-ts/lib/Eq'
type Ordering = -1 | 0 | 1
interface Ord<A> extends Eq<A> {
readonly compare: (first: A, second: A) => Ordering
}
Ordering
first > secondなら-1
first == secondなら0
first < secondなら1
https://dev.to/gcanti/getting-started-with-fp-ts-ord-5f1e
https://kazchimo.com/2021/05/31/fp-ts-ord/