-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Double in CellValue by Scientific #177
base: master
Are you sure you want to change the base?
Conversation
add CellDecimal constructor and make CellDouble a pattern synonym
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks fine but let's at least fix the tests.
I'm OK with publishing as version 1.2
@@ -105,5 +106,5 @@ fillCacheFieldsFromRecords fields recs = | |||
then field {cfItems = mapMaybe recToCellValue recVals} | |||
else field | |||
recToCellValue (CacheText t) = Just $ CellText t | |||
recToCellValue (CacheNumber n) = Just $ CellDouble n | |||
recToCellValue (CacheNumber n) = Just $ CellDecimal (fromFloatDigits n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use Scientific in CacheNumber as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I don't understand what CacheNumber is, I trust in your judgement here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically as far as I remember it's the same thing but for pivot table cache
@@ -105,6 +105,7 @@ Library | |||
, network-uri | |||
, old-locale >= 1.0.0.5 | |||
, safe >= 0.3 | |||
, scientific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding some reasonable bounds, e.g. >= 0.3.6 (the version where Hashable was fixed)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we'e only relying on
Fractional
instance ofScientific
,- the
toRealFloat
function
actually a quite low version bound could suffice. 0.3.0.0 appears to be the birth version of toRealFloat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the safer bound
Fixed the test suite. Note that the code base may have some |
Would you mind checking my comments on the PR? And it would be great to add the test you proposed as well. As for unforseen corner case - let's take a chance and fix problems when we see some. |
@olafklinke it looks like the |
Ah yes, the manually defined |
Thanks for fixing that, could you also address my other comments? BTW it would be neat to squash the commits |
What is left unaddressed? |
This looks like this uncovers the problem with the PR - it doesn't fix the writer as a result saving and reading will be not idempotent :-
so I suppose we could use it as a guide here. Does this sound fine with you? Also let's add a bound on scientific |
There are two idempotency issues here: The immediate Haskell idempotency issue is that In fact, even the current published version of Summary: If the OOXML standard really forces all decimals in XLSX to be IEEE-754 doubles, then #176 has no basis, as all double precision floating point numbers do have an exact representation in scientific notation, and a slightly improved |
As I said in the other doc it seems that I was extrapolating too much, cell values are not |
The XML contains decimal values, which are accurately represented by
Scientific
but not byDouble
as in theCellDouble
constructor ofCellValue
. This PR makesCellDouble
a pattern synonym and replaces the old constructor by a new constuctorCellDecimal
which holds aScientific
value.For motivation, see this issue.