-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
These functions just throw away the annotations:
pretty/src/Text/PrettyPrint/Annotated/HughesPJ.hs
Lines 959 to 967 in 8242baf
| -- | Render the @Doc@ to a String using the default @Style@ (see 'style'). | |
| render :: Doc a -> String | |
| render = fullRender (mode style) (lineLength style) (ribbonsPerLine style) | |
| txtPrinter "" | |
| -- | Render the @Doc@ to a String using the given @Style@. | |
| renderStyle :: Style -> Doc a -> String | |
| renderStyle s = fullRender (mode s) (lineLength s) (ribbonsPerLine s) | |
| txtPrinter "" |
Their type signatures are too general, one can shoot oneself in the foot (esp. when using AI for coding).
Their types should be limited to
Doc Void, making sure there are no annotations in these documents in the first place. So before their use, the user has to consciously convert Doc ann -> Doc Void to be aware of throwing away annotations.Or these functions should not be there in the first place, so that the user has to convert to a standard unannotated
Doc first and then render this.
Either would be a breaking change so I don't know how practical that is.
Also, I don't know whether a zero-cost implementation
removeAnn :: Doc ann -> Doc Void
removeAnn= coerce
is safe.
The alternative to Void would be () which is safe (use void) but not entirely correct, because in Doc () one can still have annotations (albeit only a single kind of annotation).
Metadata
Metadata
Assignees
Labels
No labels