-
Notifications
You must be signed in to change notification settings - Fork 21
Add functionality to render diagnostics with user provided Docs #21
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
Conversation
This reverts commit add174dbc07990ea993902bc9bddd6d5b64a6ca3.
|
This issue was already brought up to my attention in #15, and at that time we didn't think there was a good solution for this.
I think this is not a good solution as we lose the semantics of the annotation type: instead of just describing the style of the document, we now have to worry about things which aren't style (and user-defined
I think we could do the same for the colors switch too, but this is a very minor change as the colors are already separated from the rendering logic. Now here are my thoughts: originally, in #15, we debated whether it would be a good thing to have functions converting message type into
This should work, and we could have two versions of
This seems to me a better solution to the problem than the one you propose, and also should involve less changes in the codebase (basically, we only have to pass the prettifying function everywhere, why not as an implicit parameter, and it should mostly be all the changes required). Let's discuss this more thoroughly before merging this PR (I also don't like merging PR knowing that we have a very big change coming soon, see #14; there are still a few more things to change before publishing a new version unfortunately). |
|
Thank you for taking the time to write up your thoughts.
Specifically what semantics are these? Whatever they are can't they be retained by a clause saying "If the
Indeed, however I think that being able to pass in
It's true that we're only using
(The specific issue with these constructions is that if one renders (The absolute correct fix here would be to remove
TBH I don't think such an interface should be exposed if it's not possible to correctly use it, in that case only allow passing in
I should probably split this one up into the miscellaneous tidyings, the actual relevant change is not big (just changing the type sigs throughout |
Alright, a took a better look at the code (more specifically how
That's something that I never considered, hence the simpler interface with booleans (which, in the case of colors, was only useful to remove all annotations, which is what a style can do).
Fortunately, we require
I'm not sure that I entirely follow this, but from what I understand, having a two-layer rendering (rendering each individual block, e.g. the source code, the messages with the "arrows", the side rule, etc.) would be a lot better to create new layouts (which is the point of the issue/PR linked earlier, to allow for user-defined layouts), as one would simply need to write the logic for placing blocks and some default color style, and all blocks would be placed accordingly by the "compositing engine". |
Great :)
What I mean is that even the {-# LANGUAGE OverloadedStrings #-}
module A where
import Error.Diagnose
import Prettyprinter
data MyMsg = MyMsg
instance Pretty MyMsg where
pretty MyMsg = nest 2 (vsep ["foo", "bar", "baz"])
main :: IO ()
main =
printDiagnostic stderr True True 2 defaultStyle $
def `addReport` Err Nothing MyMsg [(Position (1, 3) (1, 8) "some_test.txt", This MyMsg)] [Note MyMsg]If nothing else, then this patch fixes this bug. |
|
Ah yeah, indeed. I never thought about this case. Instead of continuing on a half broken base, perhaps we should investigate directly on the alternative of the compositing engine? |
|
Honestly, I would rather see this merged as-is, as I think it's a clear improvement over the status-quo. Having said that, the way I would implement such a compositing engine would be:
|
|
Hey, is there anything else that you'd be willing to include in the PR or can it be merged? |
|
I think it should be good to go. I've been using it for a bit without any obvious issues. |
|
Thanks! |

I originally implemented it with the user supplying a function
Annotation -> annalong with theirDoc anns. This made it certain that Diagnose wasn't messing with the user's types, however the implementation was much more clunky so I went with the simpler solution of adding another case toAnnotation.Here are two examples of: colorful user portions of messages and newlines + indentation in one of the messages
Also included:
printDiagnosticinterface slightly less difficult.