Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Uses the specification for string conversions given in the General Decimal Arithmetic Specification to convert strings to an abstract syntax tree. The specification for string conversions is at
http://speleotrove.com/decimal/daconvs.html
The functions and types in this module fall into two groups. The
first group converts a string to a NumericString
, which is an
abstract representation of the grammar given in the General
Decimal Arithmetic Specification. These functions use Parsec to
parse the string. The second group transforms the
NumericString
to an Abstract
, a form which more closely
aligns with the abstract representation given at
http://speleotrove.com/decimal/damodel.html.
You can transform an Abstract
to a numeric string; no
functions are provided to transform a NumericString
directly
back to a string.
- sign :: Parser Sign
- optSign :: Parser Sign
- digit :: Parser Decem
- indicator :: Parser ()
- digits :: Parser [Decem]
- data DecimalPart
- decimalPart :: Parser DecimalPart
- data ExponentPart = ExponentPart {}
- exponentPart :: Parser ExponentPart
- infinity :: Parser ()
- nanId :: Parser Noisy
- data NaN = NaN Noisy [Decem]
- nan :: Parser NaN
- data NumericValue
- numericValue :: Parser NumericValue
- data NumericString = NumericString {}
- numericString :: Parser NumericString
- parseNumericString :: String -> Either String NumericString
- numericStringToAbstract :: NumericString -> Abstract
- nanToAbstract :: NaN -> NonNum
- finiteToAbstract :: DecimalPart -> Maybe ExponentPart -> (Coefficient, Exponent)
- givenExponent :: Maybe ExponentPart -> Integer
- actualExponent :: DecimalPart -> Integer -> Integer
- abstractExponent :: Integer -> Exponent
- abstractCoeff :: DecimalPart -> Coefficient
- stringToAbstract :: String -> Either String Abstract
- decToAbstract :: Dec -> Abstract
Documentation
data DecimalPart Source
data NumericValue Source
data NumericString Source
nanToAbstract :: NaN -> NonNum Source
finiteToAbstract :: DecimalPart -> Maybe ExponentPart -> (Coefficient, Exponent) Source
givenExponent :: Maybe ExponentPart -> Integer Source
A numeric value for the exponent that was given in the input string.
:: DecimalPart | |
-> Integer | Output from |
-> Integer |
The number of digits after the decimal point, subtracted from the numeric value for the exponent given in the string
:: Integer | The output from |
-> Exponent |
decToAbstract :: Dec -> Abstract Source
Transforms a Dec
to an Abstract
.