
From what I can see from the various typeclasses that exist: HaTeX's Render https://hackage.haskell.org/package/HaTeX-3.22.3.0/docs/Text-LaTeX-Base-Rend...:
Class of values that can be transformed to |Text https://hackage.haskell.org/package/HaTeX-3.22.3.0/docs/Text-LaTeX-Base-Rend...|.
Types which can be rendered "prettily", that is, formatted by a
core-text's Render https://hackage.haskell.org/package/core-text-0.3.0.0/docs/Core-Text-Utiliti...: pretty printer and embossed with beautiful ANSI colours when printed to the terminal. ttc's Render https://hackage.haskell.org/package/ttc-1.1.0.1/docs/Data-TTC.html#t:Render:
The Render type class renders a data type as a textual data type.
When defining such classes, people don't seem to enforce much, and on the opposite seem to loosely define the requirements, allowing for ANSI colours for instance. Since we have a mechanism to produce our own instances through newtype wrappers and use Generalised Newtype Deriving or Deriving Via, I don't see much of a problem at this point (of course I only ask to be proven wrong). One example in another language is Rust, which has the Debug https://doc.rust-lang.org/core/fmt/trait.Debug.html and Display https://doc.rust-lang.org/core/fmt/trait.Display.html traits, Debug being akin to our Show, and Display having the following property
Display is similar to Debug, but Display is for user-facing output, and so cannot be derived.
It also interesting to note that these traits belong to a wider family of formatting traits https://doc.rust-lang.org/core/fmt/index.html used with their built-in syntax of formatting (Binary, Debug, Lower & Upper Hex, Display, Octal, Write, etc). ––– Henning, you are right, `printf` does exist, and it looks pretty rich in terms of features and customisation. I acknowledge that not using it is mostly a cultural matter, and that it can be fixed by improving our current pedagogical material. If we decide as a community that a typeclass is actually not the proper tool to get away from Show instances, then I will welcome with open arms blog posts & tutorials to guide our community towards this solution, and promote them. Le 08/07/2021 à 20:25, Henning Thielemann a écrit :
On Thu, 8 Jul 2021, 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'.
chessai: Could the CLC appoint someone to start working on something? This would be pretty useful to unify the ecosystem (instead of having custom Outputable, Render, etc).
The question is, whether such a one-fits-all library actually serves the needs of the users. Actually there is already 'printf' which is intended for formatting end-user output. You can write your own PrintfArg instances. Today I am using custom Format classes per project.
-- Hécate ✨ 🐦: @TechnoEmpress IRC: Hecate WWW: https://glitchbra.in RUN: BSD