UNPKG

rivo

Version:

🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.

44 lines (38 loc) • 1.46 kB
import type { Option, OptionL } from "."; import type { None, Some } from "./core"; import type { Args, Cons, Fn1, Fn2 } from "../HKT"; import type { EQ, GT, LT, Ord, Ord$GetConstruct, Ordering, TypeClass$$Ord } from "../typeclass"; import type { Compare } from "../typeclass/Ord/Compare"; declare module "../typeclass/Ord" { interface OrdImpl { Option: ImplOrdForGeneric<OptionL<OrdL>, Option$$Ord$$Relaxer, Option$$Ord$$Builder>; } } interface Option$$Ord$$Relaxer extends Fn1<Option<Ord>, Option<Cons<Ord>>> { def: ([o]: Args<this>) => typeof o extends None ? Option<Ord> : typeof o extends Option<infer O extends Ord> ? Option<Ord$GetConstruct<O>> : never; } interface Option$$Ord$$Builder extends Fn1<Option<Cons<Ord>>, Option$$Ord<Cons<Ord>>> { def: ([oCons]: Args<this>) => typeof oCons extends Option<infer O extends Cons<Ord>> ? Option$$Ord<O> : never; } /** * Implementation of the {@link Ord} type class for {@link Option}. */ export interface Option$$Ord<O extends Ord> extends TypeClass$$Ord<Option<O>> { Compare: Option$$Ord$Compare<O>; } interface Option$$Ord$Compare<O extends Ord> extends Fn2<Option<O>, Option<O>, Ordering> { def: ([o1, o2]: Args<this>) => typeof o2 extends None ? typeof o1 extends None ? EQ : GT : typeof o1 extends None ? LT : typeof o2 extends Some<infer O2 extends Ord> ? typeof o1 extends Some<infer O1 extends Ord> ? Compare<O1, O2> : never : never; }