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

exact (multicommodity, total) assertions #902

Closed
wants to merge 7 commits into from

Conversation

ag-eitilt
Copy link
Contributor

@ag-eitilt ag-eitilt commented Oct 12, 2018

More focused PR derived from #871, containing only the changes required to allow assertions over the entire contents of an account. Written primarily as groundwork and proof-of-concept for #556.

Copy link
Owner

@simonmichael simonmichael left a comment

Choose a reason for hiding this comment

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

Otherwise, looking pretty good! Nice tests and docs.

char '='
pure sourcepos
sourcepos <- genericSourcePos <$> lift getSourcePos
char '='
Copy link
Owner

Choose a reason for hiding this comment

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

Having a hard time understanding this commit.. is it incomplete ? Message needs clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly, it doesn't change anything about the behaviour, just the code structure. These particular lines of code move the skipping of spaces and the optional call out to JournalReader.hs, to better reflect that the parse function relates to the assertion itself rather than encoding surrounding file structure as well (which brings it in line with some other parsers in the file). More generally, that commit just changes BalanceAssertion from being a typedef'ed tuple to being a standalone datatype.

Yeah, that could probably be merged with behavioural changes, but this way the foundation is separate from the exact assertions; I could create a new branch off of this commit adding sub-account-inclusive assertions without anything related to commodity-exclusive assertions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, which message were you referring to? I'm happy enough to try to clarify that, but I'm too close to the code to realize which one seems confusing from the outside.

baposition :: GenericSourcePos
} deriving (Eq,Typeable,Data,Generic,Show)

instance NFData BalanceAssertion

data AssertionFlags = AssertionFlags {
afexact :: Bool
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 some docs, eg -- ^ Does this assertion check the full multi-commodity balance or only one commodity ?

Copy link
Owner

Choose a reason for hiding this comment

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

Also for BalanceAssertion, eg -- | A statement about the expected account balance after a particular posting.

Copy link
Owner

Choose a reason for hiding this comment

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

PS I'd be fine with inlining the flags in BalanceAssertion, your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. The Types module in general could use better docs, but that's no reason to compound the issue. And I'm not entirely sure why I wasn't inlining the flags to begin with, thanks!

@simonmichael simonmichael added journal The journal file format, and its features. needs:clarification To unblock: needs to be simplified/clarified/explained/demoed needs:changes To unblock: needs some changes made, in line with recommendations labels Oct 12, 2018
@simonmichael
Copy link
Owner

simonmichael commented Oct 12, 2018 via email

@ag-eitilt ag-eitilt force-pushed the exact-assertion branch 3 times, most recently from 9052257 to ea2ec38 Compare October 13, 2018 05:02
@simonmichael
Copy link
Owner

I've lost track of this a bit. Can I ask for some review from others ? Go/no-go for merge ?

@simonmichael simonmichael added needs:value-proposition To unblock: needs clearer justification, review of benefits vs costs needs:impact-analysis To unblock: needs analysis of interactions with other features, users, ecosystem needs:review To unblock: needs more code/docs/design review by someone and removed needs:changes To unblock: needs some changes made, in line with recommendations needs:clarification To unblock: needs to be simplified/clarified/explained/demoed labels Oct 16, 2018
@simonmichael simonmichael requested review from awjchen, adept and ony October 16, 2018 16:03
@simonmichael
Copy link
Owner

simonmichael commented Oct 16, 2018

For reference, here's my summary of the earlier PR, with related discussion below it:
#871 (comment)

A discussion I've lost makes me think this also changes

  a     = $1

to be a multicommodity assignment, so a's dollar balance is set to 1 but now also any other commodities it may contain are set to 0. This seems like a change to existing semantics, unlike the rest of this PR (IIRC).

@simonmichael
Copy link
Owner

(PS and this part is not in the proposed docs yet, unless I've misplaced it.)

@simonmichael
Copy link
Owner

A discussion I've lost makes me think this also changes

  a     = $1

I misspoke, I think it doesn't change that. It allows new multicommodity/exact assignments:

  a    == $1

@ag-eitilt
Copy link
Contributor Author

Yeah, if it does change a = $1, it's a bug and needs to be fixed; it should just add the second form. You are right about me forgetting to add that to the docs, though. Thanks for the catch!

@simonmichael
Copy link
Owner

Sorry for the slow response. Getting ready to merge this. I will combine "lib: Changes shared between expressions/exact assertions" (2f9db90) into the next commit for clarity.

@simonmichael simonmichael removed needs:impact-analysis To unblock: needs analysis of interactions with other features, users, ecosystem needs:review To unblock: needs more code/docs/design review by someone needs:value-proposition To unblock: needs clearer justification, review of benefits vs costs labels Oct 22, 2018
@simonmichael simonmichael changed the title Exact assertions multi-commodity assertions Oct 22, 2018
@simonmichael
Copy link
Owner

simonmichael commented Oct 22, 2018

Merged, thank you very much!

(I renamed the PR to "multi-commodity assertions" for posterity, I prefer that slightly so as not to suggest that exactness/accuracy is exceptional for us :)

@simonmichael simonmichael changed the title multi-commodity assertions exact (multicommodity, total) assertions Oct 30, 2018
@simonmichael
Copy link
Owner

Still chewing on what we should call these. "multicommodity" could still be ambiguous it (you could imagine a multicommodity assertion that still allows additional unasserted commodities). Complete assertions ? Total assertions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
journal The journal file format, and its features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants