-
Notifications
You must be signed in to change notification settings - Fork 841
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
explore improvements to output (especially colors) #3354
explore improvements to output (especially colors) #3354
Conversation
src/Stack/PrettyPrint.hs
Outdated
indentAfterLabel = align | ||
|
||
wordDoc :: String -> [Doc a] | ||
wordDoc = map fromString . words |
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 think I'd prefer if this was pluralized, wordDocs
, since it returns multiple docs. As is, it looks like it might be treating the input as a single word.
src/main/Main.hs
Outdated
$logError "stack does not manage installations in global locations" | ||
$logError "The only global mutation stack performs is executable copying" | ||
$logError "For the default executable destination, please run 'stack path --local-bin'" | ||
$prettyErrorL . (++ [cmd]) . concatMap wordDoc $ |
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.
How about
$prettyErrorL
[ flow "stack does not manage installations in global locations."
, flow "The only global mutation stack performs is executable copying."
, flow "For the default executable destination, please run"
, shellColor "stack path --local-bin"
]
Where there'd be a new utility
flow :: String -> Doc a
flow = fillSep . wordDoc
No need to use fromString
explicitly since OverloadedStrings is on. I think it'd be good if most of the larger logging looked like this, because it's clear how to add some new Doc
to the middle of it. Whereas if concatMap flow
is used, things need to be refactored for it to be modified.
So, generally, when feasible I think $prettyErrorL should be directly applied to a list, though there are certainly cases where something more complicated makes sense.
Looks pretty good thanks for working on this! Good idea to check on it before re-applying the same pattern elsewhere. I'm fine doing this incrementally, may make sense to do it that way to avoid needing to review a huge change in one go. So, once these changes are ready, makes sense to merge it and then start applying it to more and more of the code. Awesome! |
@mgsloan Thanks a lot for the comments, those all sound like good suggestions. Will apply soon. Yeah, incremental is definitely a good idea. |
Went through and applied those changes, thanks again. Trying to come up with a hopefully short list of things to do before finishing this PR and working incrementally on further documentation changes:
Edit: do these later, in a different PR:
|
Looks good! A couple more comments on the style.
One thing to look for as you go is further uses of
Haven't compiled it, but I think this should work:
I was thinking about this too, did a bit of searching and found https://stackoverflow.com/a/12807521/1164871 . Could be worth just having this in a new module instead of depending on ncurses. Maybe depending on ncurses would be ok, depends on how problematic the 3rd party deps are, and other deps. If this is used by default, it should certainly be possible to override it. Also it makes sense to me to have a min bound and max bound on the width used. No point in laying things out at 30 char width, maybe 72 or 80. |
44d5d33
to
c4d1b5e
Compare
Thanks, that TH thing appeared to be the right idea. At least it compiles and appears to have the same behavior as before, heh. There's still some repetition, but it doesn't bother me personally anymore. re: display, Yeah good point, I'll be on the lookout for more display instances to create and more customized display* functions too. I'm sure there's a bunch of each needed. Hmm, that'd be nice if we don't actually have to add a real dependency for terminal detection, I'll try to explore that. |
So I think the problem I see with https://stackoverflow.com/a/12807521/1164871 is that that appears to be linux-only (or at least POSIX only). So that's not going to cover windows, right? Or does stack run under some kind of emulation thing and it'll magically work anyway? Assuming not: Trying to find if something similar exists in windows. I see some possible API calls and also some I might just run with POSIX-only and leave it to someone else to slip the windows part in. |
Yeah, since this is just an enhancement of output behavior, I think it's fine to omit on windows. |
bb9624a
to
ab89729
Compare
Ugh, I got tired of trying to figure out if cc-by-sa (what stackoverflow stuff seems to be licensed under) is compatible with BSD3. I'm just going to avoid reading that link any closer, wait a couple of days to forget it and then write my own version based on the ioctl docs and the usual FFI stuff. In the meantime I'll try to mess with the parts needed surrounding that. |
I think it makes sense to get this passing CI and merged soon, then continue with additional changes. Hmm, yeah seems like the opinions on cc-by-sa vary.
Sucks, it puzzles me that stackoverflow would have such a restrictive license. |
Yeah, planning on finishing up the last few things in the next couple of days (week at most). Or should I just clean up the current stuff, get it mergeable and do a PR for terminal detection separately? |
Up to you, but I think earlier is better than later to avoid merge conflicts. Inclined to do terminal detection separately. |
That works for me. Tonight, I'll add some docs to PrettyPrint and clean up with a rebase. Does sound like a better idea than doing everything in this PR. |
Avoids: - having to change them later when we change how something looks - using wrong names just because they look like you want
There's still some repetition, but I think it's quite a bit better repetition. At least it's shorter, and hopefully easier to see bugs/discepencies as these things possibly change later. Thanks @mgsloan for the TH help (any horribleness in applying it is my own fault :) p.s. I'm not usually a fan of the whole "align all the things" style, but here I think it's warranted to more easily see correspondences between the different line at a glance.
We'll probably later add some more markings around different kinds of semantic text, ie brakets of various kinds for emphasis.
589942f
to
5804b38
Compare
I think I'm done mucking about in this PR unless the CI fails or anyone sees any problems. I'll fire up another PR later for incrementally adding more prettyprinting in more places and for autodetection of terminal width and etc. (unless someone else does of course). |
Awesome, thanks! |
Trying to find ways to improve output of stack in various ways/places, especially using
$prettyWarn
and$prettyError
and etc.Very open to any comments and suggestions, even if it's just that certain things are a bad idea. Never used any of the Wadler/whatever prettyprinters before at all, so I'm pretty much just making it up as I go along.
related to issue #2650
p.s. Let me know if this shouldn't be a PR until it's further along, I'm fine with deleting it and just having a branch.