prettyprinter
prettyprinter copied to clipboard
A version of Terminal.renderIO that checks ANSI support?
This is a common pattern in dhall
:
do
supportsANSI <- System.Console.ANSI.hSupportsANSI System.IO.stdout
Pretty.Terminal.renderIO
System.IO.stdout
(if supportsANSI
then docStream
else (Pretty.unAnnotateS docStream))
Could prettyprinter-ansi-terminal
export a version of renderIO
so I could write something like this instead?
Pretty.Terminal.renderIOCheck System.IO.stdout docStream
In a way it could, but I think there are too many easily implemented combinations for rendering already – renderIO, putDoc, hPutDoc, … – they all combine small basic functions for convenience.
However, the combinations are neither exhaustive, nor are the existing ones very memorable. I’d rather like to remove some of these functions one day, and have users implement their own versions. Is there a reason you need this in the library, and don’t want to simply add this to Dhall’s source?
However, the combinations are neither exhaustive, nor are the existing ones very memorable. I’d rather like to remove some of these functions one day, and have users implement their own versions.
As a user, I appreciate libraries that provide useful combinations, even if they aren't very memorable. If I know which library to look at, I can find them. The value of such utilities is that I don't have to define them myself, I don't have to find a place to put them, and I don't have to maintain them.
Is there a reason you need this in the library, and don’t want to simply add this to Dhall’s source?
"need" is a bit much, it's more of a desire or a wish. :)
For what it's worth, I have also needed such a function.
As a user, I appreciate libraries that provide useful combinations, even if they aren't very memorable.
I would strongly second this, especially when the useful combination allows me to avoid adding yet another build dependency to my .cabal
file.
If we can find a good name for this function, I'd be in favor of adding it. Name suggestions / PRs welcome! :)