Skip to main content Link Search Menu Expand Document (external link)

PositiveInteger overview

This module implements a CVPositiveInteger brand, i.e. a number that represents an integer greater than or equal to 0 (Infinity, NaN disallowed). Can be used to represent an age, a quantity,… See the Effect documentation about Branding (https://effect.website/docs/code-style/branded-types/) if you are not familiar with this concept.


Table of contents


Constructors

fromBigDecimal

Tries to construct a CVPositiveInteger from a BigDecimal. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromBigDecimal: MTypes.OneArgFunction<
  BigDecimal.BigDecimal,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromBigDecimalOption

Tries to construct a CVPositiveInteger from a BigDecimal. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromBigDecimalOption: MTypes.OneArgFunction<
  BigDecimal.BigDecimal,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromBigDecimalOrThrow

Constructs a CVPositiveInteger from a BigDecimal if possible. Throws otherwise

Signature

export declare const fromBigDecimalOrThrow: MTypes.OneArgFunction<
  BigDecimal.BigDecimal,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

fromBigInt

Tries to construct a CVPositiveInteger from a BigInt. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromBigInt: MTypes.OneArgFunction<
  bigint,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromBigIntOption

Tries to construct a CVPositiveInteger from a BigInt. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromBigIntOption: MTypes.OneArgFunction<
  bigint,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromBigIntOrThrow

Constructs a CVPositiveInteger from a BigInt if possible. Throws otherwise

Signature

export declare const fromBigIntOrThrow: MTypes.OneArgFunction<
  bigint,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

fromInteger

Tries to construct a CVPositiveInteger from a CVInteger. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromInteger: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId>,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromIntegerOption

Tries to construct a CVPositiveInteger from a CVInteger. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromIntegerOption: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId>,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromIntegerOrThrow

Constructs a CVPositiveInteger from a CVInteger if possible. Throws otherwise

Signature

export declare const fromIntegerOrThrow: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId>,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

fromNumber

Tries to construct a CVPositiveInteger from a number. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromNumber: MTypes.OneArgFunction<
  number,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromNumberOption

Tries to construct a CVPositiveInteger from a number. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromNumberOption: MTypes.OneArgFunction<
  number,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromNumberOrThrow

Constructs a CVPositiveInteger from a number if possible. Throws otherwise

Signature

export declare const fromNumberOrThrow: MTypes.OneArgFunction<
  number,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

fromPositiveReal

Tries to construct a CVPositiveInteger from a CVPositiveReal. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromPositiveReal: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromPositiveRealOption

Tries to construct a CVPositiveInteger from a CVPositiveReal. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromPositiveRealOption: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromPositiveRealOrThrow

Constructs a CVPositiveInteger from a CVPositiveReal if possible. Throws otherwise

Signature

export declare const fromPositiveRealOrThrow: MTypes.OneArgFunction<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

fromReal

Tries to construct a CVPositiveInteger from a CVReal. Returns a Right if the conversion can be performed, a Left otherwise

Signature

export declare const fromReal: MTypes.OneArgFunction<
  CVReal.Type,
  Either.Either<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromRealOption

Tries to construct a CVPositiveInteger from a CVReal. Returns a Some if the conversion can be performed, a None otherwise

Signature

export declare const fromRealOption: MTypes.OneArgFunction<
  CVReal.Type,
  Option.Option<
    number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
  >
>

fromRealOrThrow

Constructs a CVPositiveInteger from a CVReal if possible. Throws otherwise

Signature

export declare const fromRealOrThrow: MTypes.OneArgFunction<
  CVReal.Type,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

unsafeFromBigDecimal

Constructs a CVPositiveInteger from a BigDecimal without any checks

Signature

export declare const unsafeFromBigDecimal: MTypes.OneArgFunction<
  BigDecimal.BigDecimal,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

unsafeFromBigInt

Constructs a CVPositiveInteger from a BigInt without any checks

Signature

export declare const unsafeFromBigInt: MTypes.OneArgFunction<
  bigint,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

unsafeFromNumber

Constructs a CVPositiveInteger from a number without any verifications

Signature

export declare const unsafeFromNumber: Brand.Brand.Constructor<
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

unsafeFromReal

Constructs a CVPositiveInteger from a CVReal without any checks

Signature

export declare const unsafeFromReal: MTypes.OneArgFunction<
  CVReal.Type,
  number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof _TypeId> & Brand.Brand<typeof CVPositive._TypeId>
>

Models

Type (type alias)

CVPositiveInteger type

Signature

export type Type = Brand.Brand.FromConstructor<typeof constructor>

Module markers

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/conversions/PositiveInteger/"