Add non-escaping show functions

Kai Ma justksqsf at gmail.com
Sun Dec 19 14:38:09 UTC 2021


Hello Francesco,

> Just to check if I understood correctly: only ghci will benefit from this
> proposal, right? Are there other place where printNE/showNE could be useful?

The motivation is to enhance the experience of ghci, but IMO there are a few other places it can be useful. Off the top of my head are:

1. Some development tools, like IHP’s tool, can use `showNE` in place of `show` to directly output Unicode strings.
2. At least Text (and perhaps ByteString) can make use of `showNE`.

> Why not a new typeclass instead of modifying the venerable `Show`?


People are deriving Show for their types today, so adding methods to Show is a non-intrusive and backward-compatible way to update old code smoothly.

Of course, an alternative way is to make GHC derive two instances simultaneously, for Show and for (say) ShowNE, but I’m not entirely sure whether it’s good practice. I agree adding a new class is better if deriving two instances is allowed.


Kai


More information about the Libraries mailing list