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 A.Abstract
, a form which more closely
aligns with the abstract representation given at
http://speleotrove.com/decimal/damodel.html.
You can transform an A.Abstract
to a numeric string; no
functions are provided to transform a NumericString
directly
back to a string.
- sign :: Parser D.Sign
- optSign :: Parser D.Sign
- digit :: Parser A.Decem
- indicator :: Parser ()
- digits :: Parser [A.Decem]
- data DecimalPart
- decimalPart :: Parser DecimalPart
- data ExponentPart = ExponentPart {}
- exponentPart :: Parser ExponentPart
- infinity :: Parser ()
- nanId :: Parser A.Noisy
- data NaN = NaN A.Noisy [A.Decem]
- nan :: Parser NaN
- data NumericValue
- numericValue :: Parser NumericValue
- data NumericString = NumericString {}
- numericString :: Parser NumericString
- parseNumericString :: String -> Either String NumericString
- numericStringToAbstract :: NumericString -> A.Abstract
- nanToAbstract :: NaN -> A.NonNum
- finiteToAbstract :: DecimalPart -> Maybe ExponentPart -> (A.Coefficient, A.Exponent)
- givenExponent :: Maybe ExponentPart -> Integer
- actualExponent :: DecimalPart -> Integer -> Integer
- abstractExponent :: Integer -> A.Exponent
- abstractCoeff :: DecimalPart -> A.Coefficient
- stringToAbstract :: String -> Either String A.Abstract
- decToAbstract :: D.Dec -> A.Abstract
Documentation
data DecimalPart Source
data NumericValue Source
data NumericString Source
nanToAbstract :: NaN -> A.NonNum 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 |
-> A.Exponent |
:: String | Input string |
-> Either String A.Abstract | Returns a Right with the abstract representation of the input string, if the input conformed to the numeric string specification given in the General Decimal Arithmetic Specification. Otherwise, returns a Left with an error message. |
decToAbstract :: D.Dec -> A.Abstract Source
Transforms a Dec
to an Abstract
.