Skip to content
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

use default commodity and commodity directives when inferring decimal point/digit group separator #635

Merged

Conversation

ony
Copy link
Collaborator

@ony ony commented Oct 28, 2017

Trust latest commodity or D (default commodity) directives in case of ambiguity in parsing number.

This kinda resolves #399 and its duplicate #487. We still may get issues caused by misinterpreting numbers 1,000 and 1.0 both as 1 if no commodity directive or default commodity D directive were provided in same journal file earlier.

@ony ony force-pushed the bug/487-digits-groups-separator-ambiguity branch 2 times, most recently from 61265d2 to 0a73008 Compare October 28, 2017 21:14
@ony ony force-pushed the bug/487-digits-groups-separator-ambiguity branch 3 times, most recently from fe9df19 to 4297b95 Compare November 1, 2017 08:22
@ony ony requested review from cocreature and removed request for cocreature November 1, 2017 09:25
@ony ony force-pushed the bug/487-digits-groups-separator-ambiguity branch from 4297b95 to 75decad Compare November 2, 2017 22:50
@ony ony force-pushed the bug/487-digits-groups-separator-ambiguity branch from 7d83698 to e42fbd3 Compare November 27, 2017 20:36
@ony ony added needs:rebase To unblock: needs to be rebased against latest master branch and removed needs:rebase To unblock: needs to be rebased against latest master branch labels Nov 27, 2017
@simonmichael
Copy link
Owner

I trust your judgement that this works better. We should have haddocks for the two get*Style functions, and an update to the manual explaining how things work now.

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features. needs:docs To unblock: needs corresponding documentation or doc updates labels Nov 27, 2017
@@ -145,6 +146,12 @@ setDefaultCommodityAndStyle cs = modify' (\j -> j{jparsedefaultcommodity=Just cs
getDefaultCommodityAndStyle :: JournalParser m (Maybe (CommoditySymbol,AmountStyle))
getDefaultCommodityAndStyle = jparsedefaultcommodity `fmap` get

getDefaultDecimalHint :: JournalParser m (Maybe Char)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add short haddocks explaining what these do.

@ony
Copy link
Collaborator Author

ony commented Nov 27, 2017

@simonmichael , as you probably noticed expecting that format directive will affect interpretation is natural. But actual behavior is pretty hard to document. Because mostly it something like:
"If you have issue with misinterpreting decimals try putting commodity directive in the begining of the file" and that was a first thought of me, and as I remember yours also.

If you think we should have a separate directive for that (probably still currency-specific) it should be easy to add that.

- Hunt down adjacent punctuations with altering char.
- Add some tests dedicated to parsing amounts.
Make use of commodity format directive as a hint for parsing amount.

Kinda resolves simonmichael#487
If appropriate commodity directive is missing fallback to default
commodity directive to get number representation style.
Use whole AmountStyle in process of resolving decimal/groups separator
ambiguity.

Resolve simonmichael#399
@ony ony force-pushed the bug/487-digits-groups-separator-ambiguity branch from e42fbd3 to 6f25bd1 Compare November 27, 2017 23:04
@simonmichael
Copy link
Owner

The doc looks reasonable to me. Merging, thank you!

@simonmichael simonmichael merged commit 9df985f into simonmichael:master Nov 27, 2017
@simonmichael simonmichael changed the title Bug/487 digits groups separator ambiguity use default commodity and commodity directives when inferring decimal point/digit group separator Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features. needs:docs To unblock: needs corresponding documentation or doc updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't Use Thousand Separators Without Using A Decimal Separator
2 participants