deka-0.6.0.2: Decimal floating point arithmetic

Safe HaskellSafe-Inferred
LanguageHaskell2010

Deka.Native.FromString

Description

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.

Synopsis

Documentation

data NaN Source

Constructors

NaN A.Noisy [A.Decem] 

Instances

givenExponent :: Maybe ExponentPart -> Integer Source

A numeric value for the exponent that was given in the input string.

actualExponent Source

Arguments

:: DecimalPart 
-> Integer

Output from givenExponent

-> Integer 

The number of digits after the decimal point, subtracted from the numeric value for the exponent given in the string

stringToAbstract Source

Arguments

:: 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.