-
Notifications
You must be signed in to change notification settings - Fork 4
Deduplicate, reorder displayException
impl
#36
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
Deduplicate, reorder displayException
impl
#36
Conversation
The default `displayException = show` implementation is often used, leading to duplicated output in the `AnnotatedException` `displayException` implementation. Here we make a couple tweaks to that implementation: 1. If `show` and `displayException` return the same output, only one is used. 2. If only the `displayException` output is shown, it's not indented. 3. If both the `displayException` and `show` output is shown, the `displayException` output is shown first. 4. There is a blank line before the "Annotations:" section, to match the blank line between the `displayException` and `show` output. 5. There is a blank line before the call stack section.
callStackMessage = | ||
[ "" |
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.
Extra newline before the callstack section to match the newline between the displayException
and show
sections.
anns -> | ||
"Annotations:\n" | ||
<> unlines (map (\ann -> "\t * " <> show ann) anns) | ||
[ "" |
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.
Extra newline before the "Annotations:" section to match the newline between the displayException
and show
sections.
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.
hell yeah!!!
In parsonsmatt#36, I restructured the `AnnotatedException` `displayException` implementation so that instead of being of the form: displayException = unlines [ ... ] <> callStackMessage where callStackMessage = prettyCallStack frames It was of the form: displayException = unlines $ [ ... ] <> callStackMessage where callStackMessage = [prettyCallStack frames] I didn't realize that `unlines` adds a trailing newline, which is generally the wrong behavior for `displayException` instances. This change replaces `unlines` with `concat . intersperse "\n"` in order to regain the correct behavior.
* displayException: Remove trailing newline In #36, I restructured the `AnnotatedException` `displayException` implementation so that instead of being of the form: displayException = unlines [ ... ] <> callStackMessage where callStackMessage = prettyCallStack frames It was of the form: displayException = unlines $ [ ... ] <> callStackMessage where callStackMessage = [prettyCallStack frames] I didn't realize that `unlines` adds a trailing newline, which is generally the wrong behavior for `displayException` instances. This change replaces `unlines` with `concat . intersperse "\n"` in order to regain the correct behavior. * 0.3.0.3 -> 0.3.0.4
The default
displayException = show
implementation is often used, leading to duplicated output in theAnnotatedException
displayException
implementation.Here we make a couple tweaks to that implementation:
show
anddisplayException
return the same output, only one is used.displayException
output is shown, it's not indented.displayException
andshow
output is shown, thedisplayException
output is shown first.displayException
andshow
output.Before submitting your PR, check that you've:
@since
declarations to the Haddock.stylish-haskell
and otherwise adhered to the style guide.After submitting your PR: