-
Notifications
You must be signed in to change notification settings - Fork 217
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
Quieten show
output for API types.
#2762
Merged
iohk-bors
merged 4 commits into
master
from
jonathanknowles/quieten-api-newtype-show-instances
Jul 16, 2021
Merged
Quieten show
output for API types.
#2762
iohk-bors
merged 4 commits into
master
from
jonathanknowles/quieten-api-newtype-show-instances
Jul 16, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jonathanknowles
changed the title
Quieten
Quieten Jul 15, 2021
Show
instances for API types.show
output for API types.
Deriving a `Show` instance for newtype `T` via `Quiet T` allows the deconstructor function for `T` to be omitted in the output of `show`. With stock deriving, we often obtain very verbose output, similar to the following: ```hs derivationPath = ApiT { getApiT = DerivationIndex { getDerivationIndex = 2147485500 } } :| [ ApiT { getApiT = DerivationIndex { getDerivationIndex = 2147485463 } } , ApiT { getApiT = DerivationIndex { getDerivationIndex = 2147483648 } } , ApiT { getApiT = DerivationIndex { getDerivationIndex = 0 } } , ApiT { getApiT = DerivationIndex { getDerivationIndex = 4 } } ] ``` This occasionally causes integration test error output to be extremely verbose. But when deriving via `Quiet`, the above output becomes: ```hs derivationPath = ApiT (DerivationIndex 2147485500) :| [ ApiT (DerivationIndex 2147485463) , ApiT (DerivationIndex 2147483648) , ApiT (DerivationIndex 0) , ApiT (DerivationIndex 4) ] ```
jonathanknowles
force-pushed
the
jonathanknowles/quieten-api-newtype-show-instances
branch
from
July 15, 2021 04:16
e768de4
to
1e85bd1
Compare
These types are widely used in API types, so it makes sense to quieten the output of `show` for these types too. Before: ```hs amount = Quantity { getQuantity = 100000000000 } ``` After: ```hs amount = Quantity 100000000000 ```
Anviking
approved these changes
Jul 15, 2021
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.
Yay!
This type often appear in API types, and consequently in integration test failures, so it makes sense to make the output of `show` less verbose.
bors r+ |
Build succeeded: |
iohk-bors
bot
deleted the
jonathanknowles/quieten-api-newtype-show-instances
branch
July 16, 2021 07:11
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Number
None. (Produced while debugging test failures for #2741)
Overview
Integration test failures occasionally produce very verbose output, similar to the
following (an extract from a multi-page error):
Most of the above output is boilerplate: the
getApiT
andgetDerivationIndex
deconstructor field names are not necessary to understand the output, as each of these types is just a wrapper type with exactly one field.We can remove this boilerplate by deriving our
Show
instances for newtypes viaQuiet
, which produces output similar to the following:Real log output, demonstrating the difference in verbosity:
451 1451 23191 verbose.log
337 1027 16641 concise.log