-
Notifications
You must be signed in to change notification settings - Fork 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
Proposal: Add PrettyAnn typeclass #222
Comments
Thank you for bringing this up, I think it's a good proposal if we want to introduce minimal disruption whilst allowing to retain annotations. |
@BinderDavid Could you clarify which instances you think are obvious? I imagine that users would want to use concrete annotations for certain primitive types. Wouldn't this be inhibited by the instances that we could provide from |
My original idea was that for every instance of Whether this is desirable depends, of course, on the way the prettyprinter library is used. Personally, I always have newtype wrappers like
I wrote this proposal to see whether there is some general interest in adding such a typeclass. If there is some favorable reception of the idea, I could implement a PR which can be the basis of a discussion of details. |
As discussed in #102, there is currently no way to use the
Pretty
typeclass in combination with annotations. In that issue, several alternatives were discussed, which were either backwards incompatible or otherwise potentially computationally expensive.But the first issue also mentioned the "obvious" version of the
Pretty
typeclass. Namely:But changing the definition of the typeclass would be obviously backwards incompatible.
So I propose the following change:
Add a PrettyAnn typeclass
Add the following typeclass to the library
together with the obvious instances for primitives, strings, text etc. Just like for
Pretty
right now.I see the following benefits:
unAnnotate
or similar functions which traverse the Doc.And the following downsides:
Pretty
for prettyprinting without annotations, andPrettyAnn
for prettyprinting with annotations.Pretty
class is left as a historical wart, instead of being a special case ofPrettyAnn a Void
The text was updated successfully, but these errors were encountered: