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

PositiveReal overview

This module implements a CVPositiveReal brand, i.e. a number greater than or equal to 0 (Infinity, NaN disallowed). Can be used to represent a price, a speed,… 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 CVPositiveReal 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 CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromBigDecimalOption

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>>
>

fromBigDecimalOrThrow

Constructs a CVPositiveReal 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 CVPositive._TypeId>
>

fromBigInt

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromBigIntOption

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>>
>

fromBigIntOrThrow

Constructs a CVPositiveReal from a BigInt if possible. Throws otherwise

Signature

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

fromNumber

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromNumberOption

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>>
>

fromNumberOrThrow

Constructs a CVPositiveReal from a number if possible. Throws otherwise

Signature

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

fromPositiveInteger

Constructs a CVPositiveReal from a CVPositiveInteger

Signature

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

fromReal

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>,
    Brand.Brand.BrandErrors
  >
>

fromRealOption

Tries to construct a CVPositiveReal 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 CVPositive._TypeId>>
>

fromRealOrThrow

Constructs a CVPositiveReal 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 CVPositive._TypeId>
>

unsafeFromBigDecimal

Constructs a CVPositiveReal from a BigDecimal without any checks

Signature

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

unsafeFromBigInt

Constructs a CVPositiveReal from a BigInt without any checks

Signature

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

unsafeFromNumber

Constructs a CVPositiveReal from a number without any verifications

Signature

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

unsafeFromReal

Constructs a CVPositiveReal from a CVReal without any checks

Signature

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

Models

Type (type alias)

CVPositiveReal Type

Signature

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

Module markers

moduleTag

Module tag

Signature

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