Link Search Menu Expand Document

Positive overview

Added in v1.0.0


Table of contents


utils

Positive (type alias)

The type of values greater than zero

Signature

export type Positive<A> = A & NonNegative<A> & NonZero<A>

Added in v1.0.0

arbitraryPositive

Signature

export declare function arbitraryPositive<A>(
  T: Ord<A> & HasZero<A>
): (arb: fc.Arbitrary<A>) => fc.Arbitrary<Positive<A>>

Added in v1.0.0

isPositive

Signature

export declare function isPositive<A>(T: Ord<A> & HasZero<A>)

Added in v1.0.0

toPositive

Either validates that a value is positive or attempts to flip its sign to positive by subtracting it from zero. Since flipping the sign of some numbers can cause overflow/wrapping back to negative, we can’t always produce a positive number, hence the Option.

Signature

export declare function toPositive<A>(T: Ord<A> & HasZero<A> & HasSub<A>): (a: A) => Option<Positive<A>>

Added in v1.0.0