Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Parsers for fractions.
Synopsis
- 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
- data Binary = Binary
- data Octal = Octal
- data Decimal = Decimal
- data Hexadecimal = Hexadecimal
- data UpHex = UpHex
- data LowHex = LowHex
- data Sign
- applySign :: Num α => Sign -> α -> α
- optMinus :: CharParsing μ => μ Sign
- optSign :: CharParsing μ => μ Sign
- data Optional
- isOptional :: Optional -> Bool
- isRequired :: Optional -> Bool
- optSlash :: (Monad μ, CharParsing μ) => μ Optional
- fraction' :: (PositionalSystem s, Fractional α, Monad μ, CharParsing μ) => μ Sign -> s -> μ Optional -> μ α
- fraction :: (Fractional α, Monad μ, CharParsing μ) => μ α
- decExpSign :: (Monad μ, CharParsing μ) => μ (Maybe Sign)
- hexExpSign :: (Monad μ, CharParsing μ) => μ (Maybe Sign)
- fractional' :: (PositionalSystem s, Fractional α, Monad μ, CharParsing μ) => μ Sign -> s -> Optional -> μ () -> μ (Maybe Sign) -> μ α
- fractional :: (Monad μ, Fractional α, CharParsing μ) => μ α
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 #
Instances
The binary numeral system.
Instances
Generic Binary | |
Read Binary | |
Show Binary | |
Eq Binary | |
Ord Binary | |
BitSystem Binary | |
Defined in Text.Printer.Integral | |
PositionalSystem Binary | |
Defined in Text.Printer.Integral systemName :: Binary -> String Source # radixIn :: Num α => Binary -> α Source # isDigitIn :: Binary -> Char -> Bool Source # isNzDigitIn :: Binary -> Char -> Bool Source # fromDigitIn :: Num α => Binary -> Char -> Maybe α Source # fromNzDigitIn :: Num α => Binary -> Char -> Maybe α Source # unsafeFromDigitIn :: Num α => Binary -> Char -> α Source # intToDigitIn :: Binary -> Int -> Char Source # printDigitIn :: Printer p => Binary -> Char -> p Source # printZeroIn :: Printer p => Binary -> p Source # | |
type Rep Binary | |
The octal numeral system.
Instances
Generic Octal | |
Read Octal | |
Show Octal | |
Eq Octal | |
Ord Octal | |
BitSystem Octal | |
Defined in Text.Printer.Integral | |
PositionalSystem Octal | |
Defined in Text.Printer.Integral systemName :: Octal -> String Source # radixIn :: Num α => Octal -> α Source # isDigitIn :: Octal -> Char -> Bool Source # isNzDigitIn :: Octal -> Char -> Bool Source # fromDigitIn :: Num α => Octal -> Char -> Maybe α Source # fromNzDigitIn :: Num α => Octal -> Char -> Maybe α Source # unsafeFromDigitIn :: Num α => Octal -> Char -> α Source # intToDigitIn :: Octal -> Int -> Char Source # printDigitIn :: Printer p => Octal -> Char -> p Source # printZeroIn :: Printer p => Octal -> p Source # | |
type Rep Octal | |
The decimal numeral system.
Instances
Generic Decimal | |
Read Decimal | |
Show Decimal | |
Eq Decimal | |
Ord Decimal | |
PositionalSystem Decimal | |
Defined in Text.Printer.Integral systemName :: Decimal -> String Source # radixIn :: Num α => Decimal -> α Source # isDigitIn :: Decimal -> Char -> Bool Source # isNzDigitIn :: Decimal -> Char -> Bool Source # fromDigitIn :: Num α => Decimal -> Char -> Maybe α Source # fromNzDigitIn :: Num α => Decimal -> Char -> Maybe α Source # unsafeFromDigitIn :: Num α => Decimal -> Char -> α Source # intToDigitIn :: Decimal -> Int -> Char Source # printDigitIn :: Printer p => Decimal -> Char -> p Source # printZeroIn :: Printer p => Decimal -> p Source # | |
type Rep Decimal | |
data Hexadecimal Source #
The hexadecimal numeral system.
Instances
The hexadecimal numeral system, using upper case digits.
Instances
Generic UpHex | |
Read UpHex | |
Show UpHex | |
Eq UpHex | |
Ord UpHex | |
BitSystem UpHex | |
Defined in Text.Printer.Integral | |
PositionalSystem UpHex | |
Defined in Text.Printer.Integral systemName :: UpHex -> String Source # radixIn :: Num α => UpHex -> α Source # isDigitIn :: UpHex -> Char -> Bool Source # isNzDigitIn :: UpHex -> Char -> Bool Source # fromDigitIn :: Num α => UpHex -> Char -> Maybe α Source # fromNzDigitIn :: Num α => UpHex -> Char -> Maybe α Source # unsafeFromDigitIn :: Num α => UpHex -> Char -> α Source # intToDigitIn :: UpHex -> Int -> Char Source # printDigitIn :: Printer p => UpHex -> Char -> p Source # printZeroIn :: Printer p => UpHex -> p Source # | |
type Rep UpHex | |
The hexadecimal numeral system, using lower case digits.
Instances
Generic LowHex | |
Read LowHex | |
Show LowHex | |
Eq LowHex | |
Ord LowHex | |
BitSystem LowHex | |
Defined in Text.Printer.Integral | |
PositionalSystem LowHex | |
Defined in Text.Printer.Integral systemName :: LowHex -> String Source # radixIn :: Num α => LowHex -> α Source # isDigitIn :: LowHex -> Char -> Bool Source # isNzDigitIn :: LowHex -> Char -> Bool Source # fromDigitIn :: Num α => LowHex -> Char -> Maybe α Source # fromNzDigitIn :: Num α => LowHex -> Char -> Maybe α Source # unsafeFromDigitIn :: Num α => LowHex -> Char -> α Source # intToDigitIn :: LowHex -> Int -> Char Source # printDigitIn :: Printer p => LowHex -> Char -> p Source # printZeroIn :: Printer p => LowHex -> p Source # | |
type Rep LowHex | |
Sign
applySign :: Num α => Sign -> α -> α Source #
Negate the supplied value if the sign is NonPositive
and return it
as it is otherwise.
optMinus :: CharParsing μ => μ Sign Source #
Optional minus sign.
optSign :: CharParsing μ => μ Sign Source #
Optional minus or plus sign.
Optionality characteristic
Optionality characteristic.
Instances
Bounded Optional | |
Enum Optional | |
Generic Optional | |
Ix Optional | |
Defined in Text.Printer.Fractional | |
Read Optional | |
Show Optional | |
Eq Optional | |
Ord Optional | |
Defined in Text.Printer.Fractional | |
type Rep Optional | |
Fraction parsers
:: (PositionalSystem s, Fractional α, Monad μ, CharParsing μ) | |
=> μ Sign | Sign parser |
-> s | |
-> μ Optional | Numerator/denominator separator parser |
-> μ α |
Parse a fraction. The numerator and the denominator are expected to be written in the specified positional numeral system.
fraction :: (Fractional α, Monad μ, CharParsing μ) => μ α Source #
s-fraction parsers
decExpSign :: (Monad μ, CharParsing μ) => μ (Maybe Sign) Source #
Start of a decimal exponent. Accepts e
or E
followed by
an optional sign. Otherwise Nothing
is returned.
hexExpSign :: (Monad μ, CharParsing μ) => μ (Maybe Sign) Source #
Start of a hexadecimal exponent. Accepts p
or P
followed by
an optional sign. Otherwise Nothing
is returned.
:: (PositionalSystem s, Fractional α, Monad μ, CharParsing μ) | |
=> μ Sign | Sign parser. |
-> s | |
-> Optional | Whether the integer part is optional. |
-> μ () | Dot parser. |
-> μ (Maybe Sign) | Exponent start parser. |
-> μ α |
s-fraction parser.
fractional :: (Monad μ, Fractional α, CharParsing μ) => μ α Source #
Decimal fraction parser.