UNPKG

money-ts

Version:

TypeScript library for type-safe and lossless encoding and manipulation of world currencies and precious metals

29 lines (28 loc) 1.26 kB
import { Newtype } from 'newtype-ts'; import { Option } from 'fp-ts/lib/Option'; import { Setoid } from 'fp-ts/lib/Setoid'; import { Ord } from 'fp-ts/lib/Ord'; import { Integer } from './Integer'; import { BigInteger } from 'big-integer'; import { NonZeroInteger } from './NonZeroInteger'; /** A PositiveInteger is also an Integer */ export interface Natural extends Newtype<{ Integer: true; NonZero: true; Positive: true; }, BigInteger> { } export declare function wrap(x: BigInteger): Option<Natural>; export declare const unwrap: (x: Natural) => BigInteger; export declare function fromInteger(i: Integer): Option<Natural>; export declare const add: (x: Natural, y: Natural) => Natural; export declare const mul: (x: Natural, y: Natural) => Natural; export declare function sub(x: Natural, y: Natural): Option<Natural>; export declare const negate: (x: Natural) => NonZeroInteger; export declare const div: (x: Natural, y: Natural) => Natural; export declare const gcd: (x: Natural, y: Natural) => Natural; export declare const lcm: (x: Natural, y: Natural) => Natural; export declare const setoid: Setoid<Natural>; export declare const ord: Ord<Natural>; export declare const show: (x: Natural) => string; export declare const one: Natural;