Safe Haskell | None |
---|
Print integral numbers in common positional numeral systems.
- class PositionalSystem s where
- systemName :: s -> String
- radixIn :: Num α => s -> α
- isDigitIn :: s -> Char -> Bool
- isNzDigitIn :: s -> Char -> Bool
- fromDigitIn :: Num α => s -> Char -> Maybe α
- fromNzDigitIn :: Num α => s -> Char -> Maybe α
- unsafeFromDigitIn :: Num α => s -> Char -> α
- intToDigitIn :: s -> Int -> Char
- printDigitIn :: Printer p => s -> Char -> p
- printZeroIn :: Printer p => s -> p
- class PositionalSystem s => BitSystem s where
- digitBitsIn :: s -> Int
- digitMaskIn :: Num α => s -> α
- lastDigitIn :: Bits α => s -> α -> Int
- data Binary = Binary
- data Octal = Octal
- data Decimal = Decimal
- data Hexadecimal = Hexadecimal
- data LowHex = LowHex
- data UpHex = UpHex
- nonNegative :: (PositionalSystem s, Integral α, Printer p) => s -> α -> p
- nnBinary :: (Integral α, Printer p) => α -> p
- nnOctal :: (Integral α, Printer p) => α -> p
- nnDecimal :: (Integral α, Printer p) => α -> p
- nnLowHex :: (Integral α, Printer p) => α -> p
- nnUpHex :: (Integral α, Printer p) => α -> p
- nnBits :: (BitSystem s, Num α, Bits α, Printer p) => s -> α -> p
- nnBinaryBits :: (Num α, Bits α, Printer p) => α -> p
- nnOctalBits :: (Num α, Bits α, Printer p) => α -> p
- nnLowHexBits :: (Num α, Bits α, Printer p) => α -> p
- nnUpHexBits :: (Num α, Bits α, Printer p) => α -> p
- nonPositive :: (PositionalSystem s, Integral α, Printer p) => s -> α -> p
- npBinary :: (Integral α, Printer p) => α -> p
- npOctal :: (Integral α, Printer p) => α -> p
- npDecimal :: (Integral α, Printer p) => α -> p
- npLowHex :: (Integral α, Printer p) => α -> p
- npUpHex :: (Integral α, Printer p) => α -> p
- npBits :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> α -> p
- npBinaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- npOctalBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- npLowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- npUpHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- number' :: (PositionalSystem s, Ord α, Integral α, Printer p) => s -> p -> p -> p -> α -> p
- number :: (PositionalSystem s, Ord α, Integral α, Printer p) => s -> α -> p
- binary' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p
- binary :: (Ord α, Integral α, Printer p) => α -> p
- octal' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p
- octal :: (Ord α, Integral α, Printer p) => α -> p
- decimal' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p
- decimal :: (Ord α, Integral α, Printer p) => α -> p
- lowHex' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p
- lowHex :: (Ord α, Integral α, Printer p) => α -> p
- upHex' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p
- upHex :: (Ord α, Integral α, Printer p) => α -> p
- bits' :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> p -> p -> p -> α -> p
- bits :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> α -> p
- binaryBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p
- binaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- octalBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p
- octalBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- lowHexBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p
- lowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
- upHexBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p
- upHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p
Positional systems
class PositionalSystem s whereSource
Positional numeral system.
systemName :: s -> StringSource
The name of the system (e.g. "binary", "decimal").
radixIn :: Num α => s -> αSource
The radix of the system.
isDigitIn :: s -> Char -> BoolSource
Test if a character is a digit.
isNzDigitIn :: s -> Char -> BoolSource
Test if a character is a non-zero digit.
fromDigitIn :: Num α => s -> Char -> Maybe αSource
Map digits to the corresponding numbers. Return Nothing
on
other inputs.
fromNzDigitIn :: Num α => s -> Char -> Maybe αSource
Map non-zero digits to the corresponding numbers. Return Nothing
on
other inputs.
unsafeFromDigitIn :: Num α => s -> Char -> αSource
Map digits to the corresponding numbers. No checks are performed.
intToDigitIn :: s -> Int -> CharSource
Map Int
values to the corresponding digits. Inputs must be
non-negative and less than the radix.
printDigitIn :: Printer p => s -> Char -> pSource
Print a digit.
printZeroIn :: Printer p => s -> pSource
class PositionalSystem s => BitSystem s whereSource
Positonal numeral system with a power of two radix.
digitBitsIn :: s -> IntSource
Numer of bits occupied by a digit.
digitMaskIn :: Num α => s -> αSource
The number that has digitBitsIn
least significant bits set to ones
and all the other bits set to zeroes.
lastDigitIn :: Bits α => s -> α -> IntSource
Map the last digit of a number to the corresponding Int
value.
The binary numeral system.
The octal numeral system.
The decimal numeral system.
data Hexadecimal Source
The hexadecimal numeral system.
The hexadecimal numeral system, using lower case digits.
The hexadecimal numeral system, using upper case digits.
Numeral printers
nonNegative :: (PositionalSystem s, Integral α, Printer p) => s -> α -> pSource
Print a non-negative number in the specified positional numeral system.
nnBinary :: (Integral α, Printer p) => α -> pSource
Print a non-negative number in the binary numeral system.
nnOctal :: (Integral α, Printer p) => α -> pSource
Print a non-negative number in the octal numeral system.
nnDecimal :: (Integral α, Printer p) => α -> pSource
Print a non-negative number in the decimal numeral system.
nnLowHex :: (Integral α, Printer p) => α -> pSource
Print a non-negative number in the hexadecimal numeral system using lower case digits.
nnUpHex :: (Integral α, Printer p) => α -> pSource
Print a non-negative number in the hexadecimal numeral system using upper case digits.
nnBits :: (BitSystem s, Num α, Bits α, Printer p) => s -> α -> pSource
Print a non-negative binary number in the specified positional numeral system.
nnBinaryBits :: (Num α, Bits α, Printer p) => α -> pSource
Print a non-negative binary number in the binary numeral system.
nnOctalBits :: (Num α, Bits α, Printer p) => α -> pSource
Print a non-negative binary number in the octal numeral system.
nnLowHexBits :: (Num α, Bits α, Printer p) => α -> pSource
Print a non-negative binary number in the hexadecimal numeral system using lower case digits.
nnUpHexBits :: (Num α, Bits α, Printer p) => α -> pSource
Print a non-negative binary number in the hexadecimal numeral system using upper case digits.
nonPositive :: (PositionalSystem s, Integral α, Printer p) => s -> α -> pSource
Print a non-positive number in the specified positional numeral system.
For example,
would print "123".
nonPositive
Decimal
(-123)
npBinary :: (Integral α, Printer p) => α -> pSource
Print a non-positive number in the binary numeral system.
npOctal :: (Integral α, Printer p) => α -> pSource
Print a non-positive number in the octal numeral system.
npDecimal :: (Integral α, Printer p) => α -> pSource
Print a non-positive number in the decimal numeral system.
npLowHex :: (Integral α, Printer p) => α -> pSource
Print a non-positive number in the hexadecimal numeral system using lower case digits.
npUpHex :: (Integral α, Printer p) => α -> pSource
Print a non-positive number in the hexadecimal numeral system using upper case digits.
npBinaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a non-positive binary number in the binary numeral system.
npOctalBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a non-positive binary number in the octal numeral system.
npLowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a non-positive binary number in the hexadecimal numeral system using lower case digits.
npUpHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a non-positive binary number in the hexadecimal numeral system using upper case digits.
:: (PositionalSystem s, Ord α, Integral α, Printer p) | |
=> s | |
-> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the specified positional numeral system.
number :: (PositionalSystem s, Ord α, Integral α, Printer p) => s -> α -> pSource
Print a number in the specified positional numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Integral α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the binary numeral system.
binary :: (Ord α, Integral α, Printer p) => α -> pSource
Print a number in the binary numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Integral α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the octal numeral system.
octal :: (Ord α, Integral α, Printer p) => α -> pSource
Print a number in the octal numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Integral α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the decimal numeral system.
decimal :: (Ord α, Integral α, Printer p) => α -> pSource
Print a number in the decimal numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Integral α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the hexadecimal numeral system using lower case digits.
lowHex :: (Ord α, Integral α, Printer p) => α -> pSource
Print a number in the hexadecimal numeral system using lower case digits. Negative values are prefixed with a minus sign.
:: (Ord α, Integral α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a number in the hexadecimal numeral system using upper case digits.
upHex :: (Ord α, Integral α, Printer p) => α -> pSource
Print a number in the hexadecimal numeral system using upper case digits. Negative values are prefixed with a minus sign.
:: (BitSystem s, Ord α, Num α, Bits α, Printer p) | |
=> s | |
-> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a binary number in the specified positional numeral system.
bits :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> α -> pSource
Print a binary number in the specified positional numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Num α, Bits α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a binary number in the binary numeral system.
binaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a binary number in the binary numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Num α, Bits α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a binary number in the octal numeral system.
octalBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a binary number in the octal numeral system. Negative values are prefixed with a minus sign.
:: (Ord α, Num α, Bits α, Printer p) | |
=> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> α | |
-> p |
Print a binary number in the hexadecimal numeral system using lower case digits.
lowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> pSource
Print a binary number in the hexadecimal numeral system using lower case digits. Negative values are prefixed with a minus sign.