checked-literals
Safe HaskellNone
LanguageGHC2021

CheckedLiterals.Class.Integer

Description

Type classes and helper functions for checked integer literals.

Synopsis

Documentation

class CheckedPositiveIntegerLiteral (lit :: Nat) a Source #

Constraint used by the plugin to validate positive integer literals.

Instances

Instances details
Assert (lit <=? 32767) (PositiveSignedError lit Int16 32768 32767 :: Constraint) => CheckedPositiveIntegerLiteral lit Int16 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 2147483647) (PositiveSignedError lit Int32 2147483648 2147483647 :: Constraint) => CheckedPositiveIntegerLiteral lit Int32 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 9223372036854775807) (PositiveSignedError lit Int64 9223372036854775808 9223372036854775807 :: Constraint) => CheckedPositiveIntegerLiteral lit Int64 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 127) (PositiveSignedError lit Int8 128 127 :: Constraint) => CheckedPositiveIntegerLiteral lit Int8 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 65535) (PositiveUnsignedError lit Word16 65535 :: Constraint) => CheckedPositiveIntegerLiteral lit Word16 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 4294967295) (PositiveUnsignedError lit Word32 4294967295 :: Constraint) => CheckedPositiveIntegerLiteral lit Word32 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 18446744073709551615) (PositiveUnsignedError lit Word64 18446744073709551615 :: Constraint) => CheckedPositiveIntegerLiteral lit Word64 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 255) (PositiveUnsignedError lit Word8 255 :: Constraint) => CheckedPositiveIntegerLiteral lit Word8 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedPositiveIntegerLiteral lit Integer Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedPositiveIntegerLiteral lit Natural Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedPositiveIntegerLiteral lit Double Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedPositiveIntegerLiteral lit Float Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 9223372036854775807) (PositiveSignedError lit Int 9223372036854775808 9223372036854775807 :: Constraint) => CheckedPositiveIntegerLiteral lit Int Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 18446744073709551615) (PositiveUnsignedError lit Word 18446744073709551615 :: Constraint) => CheckedPositiveIntegerLiteral lit Word Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

type PositiveUnsignedError (lit :: t) (typ :: t1) (maxVal :: t2) = TypeError (((('Text "Literal " ':<>: 'ShowType lit) ':<>: 'Text " is out of bounds.") ':$$: ((('ShowType typ ':<>: 'Text " has bounds: [0 .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #

type PositiveSignedError (lit :: t) (typ :: t1) (minVal :: t2) (maxVal :: t3) = TypeError (((('Text "Literal " ':<>: 'ShowType lit) ':<>: 'Text " is out of bounds.") ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #

checkedPositiveIntegerLiteral :: forall (lit :: Nat) a. CheckedPositiveIntegerLiteral lit a => a -> a Source #

Identity helper that attaches a positive integer literal check.

class CheckedNegativeIntegerLiteral (lit :: Nat) a Source #

Constraint used by the plugin to validate negative integer literals.

Instances

Instances details
Assert (lit <=? 32768) (NegativeSignedError lit Int16 32768 32767 :: Constraint) => CheckedNegativeIntegerLiteral lit Int16 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 2147483648) (NegativeSignedError lit Int32 2147483648 2147483647 :: Constraint) => CheckedNegativeIntegerLiteral lit Int32 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 9223372036854775808) (NegativeSignedError lit Int64 9223372036854775808 9223372036854775807 :: Constraint) => CheckedNegativeIntegerLiteral lit Int64 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 128) (NegativeSignedError lit Int8 128 127 :: Constraint) => CheckedNegativeIntegerLiteral lit Int8 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeUnsignedError lit Word16 65535 :: Constraint) => CheckedNegativeIntegerLiteral lit Word16 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeUnsignedError lit Word32 4294967295 :: Constraint) => CheckedNegativeIntegerLiteral lit Word32 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeUnsignedError lit Word64 18446744073709551615 :: Constraint) => CheckedNegativeIntegerLiteral lit Word64 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeUnsignedError lit Word8 255 :: Constraint) => CheckedNegativeIntegerLiteral lit Word8 Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedNegativeIntegerLiteral lit Integer Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeNaturalError lit Natural :: Constraint) => CheckedNegativeIntegerLiteral lit Natural Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedNegativeIntegerLiteral lit Double Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

CheckedNegativeIntegerLiteral lit Float Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

Assert (lit <=? 9223372036854775808) (NegativeSignedError lit Int 9223372036854775808 9223372036854775807 :: Constraint) => CheckedNegativeIntegerLiteral lit Int Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

(NegativeUnsignedError lit Word 18446744073709551615 :: Constraint) => CheckedNegativeIntegerLiteral lit Word Source # 
Instance details

Defined in CheckedLiterals.Class.Integer

type NegativeNaturalError (lit :: t) (typ :: t1) = TypeError (((('Text "Literal -" ':<>: 'ShowType lit) ':<>: 'Text " is out of bounds.") ':$$: ('ShowType typ ':<>: 'Text " has bounds: [0 .. \8734].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #

type NegativeUnsignedError (lit :: t) (typ :: t1) (maxVal :: t2) = TypeError (((('Text "Literal -" ':<>: 'ShowType lit) ':<>: 'Text " is out of bounds.") ':$$: ((('ShowType typ ':<>: 'Text " has bounds: [0 .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #

type NegativeSignedError (lit :: t) (typ :: t1) (minVal :: t2) (maxVal :: t3) = TypeError (((('Text "Literal -" ':<>: 'ShowType lit) ':<>: 'Text " is out of bounds.") ':$$: ((((('ShowType typ ':<>: 'Text " has bounds: [-") ':<>: 'ShowType minVal) ':<>: 'Text " .. ") ':<>: 'ShowType maxVal) ':<>: 'Text "].")) ':$$: 'Text "Possible fix: use 'uncheckedLiteral' from 'CheckedLiterals' to bypass this check.") :: k Source #

checkedNegativeIntegerLiteral :: forall (lit :: Nat) a. CheckedNegativeIntegerLiteral lit a => a -> a Source #

Identity helper that attaches a negative integer literal check.