Safe Haskell | None |
---|---|
Language | Haskell2010 |
Print fractions.
- class PositionalSystem s where
- class PositionalSystem s => BitSystem s where
- data Binary = Binary
- data Octal = Octal
- data Decimal = Decimal
- data Hexadecimal = Hexadecimal
- data LowHex = LowHex
- data UpHex = UpHex
- data Optional
- isOptional :: Optional -> Bool
- isRequired :: Optional -> Bool
- fraction' :: (PositionalSystem s, Real α, Printer p) => s -> p -> p -> p -> p -> Optional -> α -> p
- fraction :: (Real α, Printer p) => α -> p
Positional numeral systems
class PositionalSystem s where Source #
Positional numeral system.
systemName, radixIn, isDigitIn, isNzDigitIn, fromDigitIn, fromNzDigitIn, unsafeFromDigitIn, intToDigitIn
systemName :: s -> String Source #
The name of the system (e.g. "binary", "decimal").
radixIn :: Num α => s -> α Source #
The radix of the system.
isDigitIn :: s -> Char -> Bool Source #
Test if a character is a digit.
isNzDigitIn :: s -> Char -> Bool Source #
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 -> Char Source #
Map Int
values to the corresponding digits. Inputs must be
non-negative and less than the radix.
printDigitIn :: Printer p => s -> Char -> p Source #
Print a digit.
printZeroIn :: Printer p => s -> p Source #
class PositionalSystem s => BitSystem s where Source #
Positonal numeral system with a power of two radix.
digitBitsIn :: s -> Int Source #
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 -> α -> Int Source #
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.
Optionality characteristic
Optionality characteristic.
Fraction printers
:: (PositionalSystem s, Real α, Printer p) | |
=> s | |
-> p | Prefix for negative values |
-> p | Zero printer |
-> p | Prefix for positive values |
-> p | Numerator/denominator separator |
-> Optional | Whether to print invisible denominators |
-> α | |
-> p |
Print a fraction, writing the numerator and the denominator in the specified positional numeral system.