[ANN] text-display A typeclass for user-facing output

Hi everyone, I am proud to release the first version of text-display, a typeclass for user-facing output.

Display is a typeclass that doesn’t abide by the rules of Show & Read, and brings with it a nice and ergonomic way to derive instances through DerivingVia when they already have a Show instance:

{-# LANGUAGE DerivingVia #-}
data AutomaticallyDerived = AD
  -- We derive 'Show'
  deriving Show 
  -- We take advantage of the 'Show' instance to derive 'Display' from it
  deriving Display
    via (ShowInstance AutomaticallyDerived) 

But let’s say you want to redact an instance of Display? You can do it locally, through
the OpaqueInstance helper. It is most useful to hide tokens or passwords:

data UserToken = UserToken UUID                           
 deriving Display                                         
   via (OpaqueInstance "[REDACTED]" UserToken)            
display $ UserToken "7a01d2ce-31ff-11ec-8c10-5405db82c3cd"
-- => "[REDACTED]"                                              

I hope you will have fun with this library! :rainbow:


Useful, usable, lovely unicode chars in the docs. Well done!


Thank you very much. :slight_smile:

Didn’t realize I was missing icons in haddock pages so much.

Also @Kleidukos , incidentally the other day I found a general pretty-printing library from Google GitHub - google/hs-portray which relies on DerivingVia like yours. Now we have even more standards to choose from ! \o/

Ohh I hadn’t heard about that one! :slight_smile: Thank you @ocramz