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

Real overview

This module implements a CVReal brand, i.e. a number that disallows Infinity and NaN. Can be used to represent a temperature, a height from sea-level,… 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 CVReal 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<Type, Brand.Brand.BrandErrors>
>

fromBigDecimalOption

Tries to construct a CVReal 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<Type>>

fromBigDecimalOrThrow

Constructs a CVReal from a BigDecimal if possible. Throws otherwise

Signature

export declare const fromBigDecimalOrThrow: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>

fromBigInt

Tries to construct a CVReal 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<Type, Brand.Brand.BrandErrors>>

fromBigIntOption

Tries to construct a CVReal 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<Type>>

fromBigIntOrThrow

Constructs a CVReal from a BigInt if possible. Throws otherwise

Signature

export declare const fromBigIntOrThrow: MTypes.OneArgFunction<bigint, Type>

fromNumber

Tries to construct a CVReal 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<Type, Brand.Brand.BrandErrors>>

fromNumberOption

Tries to construct a CVReal 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<Type>>

fromNumberOrThrow

Constructs a CVReal from a number if possible. Throws otherwise

Signature

export declare const fromNumberOrThrow: MTypes.OneArgFunction<number, Type>

unsafeFromBigDecimal

Constructs a CVReal from a BigDecimal without any checks

Signature

export declare const unsafeFromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>

unsafeFromBigInt

Constructs a CVReal from a BigInt without any checks

Signature

export declare const unsafeFromBigInt: MTypes.OneArgFunction<bigint, Type>

unsafeFromNumber

Constructs a CVReal from a number without any verifications

Signature

export declare const unsafeFromNumber: Brand.Brand.Constructor<Type>

Models

Type (type alias)

CVReal type

Signature

export type Type = Brand.Branded<number, _TypeId>

Module markers

TypeId

Module TypeId

Signature

export declare const TypeId: typeof TypeId

moduleTag

Module tag

Signature

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