pact
pact copied to clipboard
Analysis of formatting decimals
We can't currently analyze formatting decimals due to the representation we use:
-- We model decimals as integers. The value of a decimal is the value of the
-- integer, shifted right 255 decimal places.
newtype Decimal = Decimal { unDecimal :: Integer }
Compare with these formatting examples:
pact> (format "{}" [1.5])
"1.5"
pact> (format "{}" [1.50])
"1.50"
It would be impossible to get these two different answers without explicitly tracking the decimal places a la Data.Decimal:
data DecimalRaw i = Decimal {
decimalPlaces :: ! Word8,
decimalMantissa :: ! i}
So, for this analysis we'll have to add a decimalPlaces field to our Decimal.