
On Fri, Jul 09, 2021 at 08:04:40AM +0900, Travis Cardwell via Libraries wrote:
On Fri, Jul 9, 2021 at 3:18 AM Hécate wrote:
I guess this is the perfect time to come up with a Render typeclass that targets end-users rather than satisfying 'read . show = id'.
This is the primary motivation of the TTC (Textual Type Classes) library: https://hackage.haskell.org/package/ttc.
It provides a Render type class that is analogous to Show and a Parse type class that is analogous to Read. No instances are declared so that users of the library can implement instances as required for each application, but default instances for core types are available.
One promising feature of this is that the target type is not restricted to just `String`, but rather `Render` produces a `Textual` value, which can be a String, Text, ByteString, or a Text or Binary `builder`. I would prefer to also see a ByteString `Builder` as an option, but the high level design feels sound. -- Viktor.