rivo
Version:
🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.
77 lines (72 loc) • 1.64 kB
TypeScript
import type AddFn from "./Add";
import type DecFn from "./Dec";
import type FromStrFn from "./FromStr";
import type FromStrUnsafeFn from "./FromStrUnsafe";
import type IncFn from "./Inc";
import type SubFn from "./Sub";
import type { PartialApply } from "../../HKT";
/**
* Alias for `number` to represent integers.
*/
export type Int = number;
/***********
* Methods *
***********/
/**
* Methods for `Int`.
*/
export namespace Int {
/**
* [Fn] Add 1 to an {@link Int}.
*
* Sig: `(n: Int) => Int`
*/
export type Inc = IncFn;
/**
* [Fn] Subtract 1 from an {@link Int}.
*
* Sig: `(n: Int) => Int`
*/
export type Dec = DecFn;
/**
* [Fn] Add two {@link Int}s.
*
* Sig: `(n: Int, m: Int) => Int`
*/
export type Add2 = AddFn;
/**
* [Fn] Add two {@link Int}s.
*
* Sig: `[m: Int](n: Int) => Int`
*/
export type Add<M extends Int> = PartialApply<AddFn, [M], "_1">;
/**
* [Fn] Subtract two {@link Int}s.
*
* Sig: `(n: Int, m: Int) => Int`
*/
export type Sub2 = SubFn;
/**
* [Fn] Subtract two {@link Int}s.
*
* Sig: `[m: Int](n: Int) => Int`
*/
export type Sub<M extends Int> = PartialApply<SubFn, [M], "_1">;
}
/******************
* Static members *
******************/
/**
* [Fn] Parse a string to an {@link Int}.
*
* Sig: `(s: string) => Result<Int, ParsingError>`
*/
export type Int$$FromStr = FromStrFn;
/**
* [Fn] Parse a string to an {@link Int}. Return `never` if the string is not a valid integer.
*
* Type safety is **not guaranteed**.
*
* Sig: `(s: string) => Int`
*/
export type Int$$FromStrUnsafe = FromStrUnsafeFn;