| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
CheckedLiterals.Class.Rational
Description
Type classes and helper functions for checked rational literals.
Synopsis
- class CheckedPositiveRationalLiteral (literalAsString :: Symbol) (numerator :: Nat) (denominator :: Nat) a
- type FixedRoundingError (str :: t) (fixedType :: t1) (resolution :: t2) = TypeError (((((((('Text "Literal " ':<>: 'ShowType str) ':<>: 'Text " requires rounding for ") ':<>: 'ShowType fixedType) ':<>: 'Text " (resolution 1/") ':<>: 'ShowType resolution) ':<>: 'Text ").") ':$$: 'Text "The literal cannot be represented exactly without rounding.") ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
- checkedPositiveRationalLiteral :: forall (fixed :: Symbol) (num :: Nat) (den :: Nat) a. CheckedPositiveRationalLiteral fixed num den a => a -> a
- class CheckedNegativeRationalLiteral (str :: Symbol) (numerator :: Nat) (denominator :: Nat) a
- checkedNegativeRationalLiteral :: forall (fixed :: Symbol) (num :: Nat) (den :: Nat) a. CheckedNegativeRationalLiteral fixed num den a => a -> a
- type PositiveUnsignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (maxVal :: t3) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((('ShowType typ ':<>: 'Text " has bounds: [0 .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
- type PositiveSignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (minVal :: t3) (maxVal :: t4) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
- type NegativeNaturalRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) typ = TypeError ((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (-") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType (Ratio typ)) ':<>: 'Text ".") ':$$: ('ShowType typ ':<>: 'Text " has bounds: [0 .. \8734].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
- type NegativeUnsignedRatioNotRepresentable (str :: Symbol) (num :: k1) (den :: k2) typ (maxVal :: k3) = TypeError (((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType (Ratio typ)) ':<>: 'Text ".") ':$$: ('ShowType typ ':<>: 'Text " cannot represent negative numbers.")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
- type NegativeSignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (minVal :: t3) (maxVal :: t4) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (-") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k
Documentation
class CheckedPositiveRationalLiteral (literalAsString :: Symbol) (numerator :: Nat) (denominator :: Nat) a Source #
Constraint used by the plugin to validate positive rational literals.
Instances
type FixedRoundingError (str :: t) (fixedType :: t1) (resolution :: t2) = TypeError (((((((('Text "Literal " ':<>: 'ShowType str) ':<>: 'Text " requires rounding for ") ':<>: 'ShowType fixedType) ':<>: 'Text " (resolution 1/") ':<>: 'ShowType resolution) ':<>: 'Text ").") ':$$: 'Text "The literal cannot be represented exactly without rounding.") ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #
checkedPositiveRationalLiteral :: forall (fixed :: Symbol) (num :: Nat) (den :: Nat) a. CheckedPositiveRationalLiteral fixed num den a => a -> a Source #
Identity helper that attaches a positive rational literal check.
class CheckedNegativeRationalLiteral (str :: Symbol) (numerator :: Nat) (denominator :: Nat) a Source #
Constraint used by the plugin to validate negative rational literals.
Instances
checkedNegativeRationalLiteral :: forall (fixed :: Symbol) (num :: Nat) (den :: Nat) a. CheckedNegativeRationalLiteral fixed num den a => a -> a Source #
Identity helper that attaches a negative rational literal check.
type PositiveUnsignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (maxVal :: t3) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((('ShowType typ ':<>: 'Text " has bounds: [0 .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #
type PositiveSignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (minVal :: t3) (maxVal :: t4) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #
type NegativeNaturalRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) typ = TypeError ((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (-") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType (Ratio typ)) ':<>: 'Text ".") ':$$: ('ShowType typ ':<>: 'Text " has bounds: [0 .. \8734].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #
type NegativeUnsignedRatioNotRepresentable (str :: Symbol) (num :: k1) (den :: k2) typ (maxVal :: k3) = TypeError (((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType (Ratio typ)) ':<>: 'Text ".") ':$$: ('ShowType typ ':<>: 'Text " cannot represent negative numbers.")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #
type NegativeSignedRatioNotRepresentable (str :: Symbol) (num :: t) (den :: t1) (typ :: t2) (minVal :: t3) (maxVal :: t4) = TypeError (((((((((((('Text "Literal " ':<>: 'Text str) ':<>: 'Text " (-") ':<>: 'ShowType num) ':<>: 'Text " % ") ':<>: 'ShowType den) ':<>: 'Text ")") ':<>: 'Text " cannot be represented by ") ':<>: 'ShowType typ) ':<>: 'Text ".") ':$$: (('Text "Make sure both the numerator and the denominator fit " ':<>: 'ShowType typ) ':<>: 'Text ".")) ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #