h&$V"      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU Hcate Moonlight, 2021MIThecate@glitchbra.instable Safe-Inferred"15?K* text-display2This wrapper allows you to rely on a pre-existing V instance in order to derive   from it.Example data AutomaticallyDerived = AD -- We derive 'Show' deriving stock Show -- We take advantage of the 'Show' instance to derive 'Display' from it deriving Display via (ShowInstance AutomaticallyDerived) text-displayThis wrapper allows you to create an opaque instance for your type, useful for redacting sensitive content like tokens or passwords.Example data UserToken = UserToken UUID deriving Display via (OpaqueInstance "[REDACTED]" UserToken) display $ UserToken "7a01d2ce-31ff-11ec-8c10-5405db82c3cd" "[REDACTED]"  text-display  text-display#A typeclass for user-facing output.  text-display?Implement this method to describe how to convert your value to W.  text-display The method   is provided to allow for a specialised way to render lists of a certain value. This is used to render the list of X as a string of characters enclosed in double quotes, rather than between square brackets and separated by commas.Example import qualified Data.Text.Lazy.Builder as TB instance Display Char where displayBuilder c = TB.fromText $ T.singleton c displayList cs = TB.fromText $ T.pack cs instance (Display a) => Display [a] where -- In this instance, 'displayBuilder' is defined in terms of 'displayList', which for most types -- is defined as the default written in the class declaration. -- But when a ~ Char, there is an explicit implementation that is selected instead, which -- provides the rendering of the character string between double quotes. displayBuilder = displayList How implementations are selected displayBuilder ([1,2,3] :: [Int]) C displayBuilder @[Int] = displayBuilderList @Int C Default `displayList` displayBuilder ("abc" :: [Char]) C displayBuilder @[Char] = displayBuilderList @Char C Custom `displayList`  text-display The method   allows you to write instances that require nesting. The precedence parameter can be thought of as a suggestion coming from the surrounding context for how tightly to bind. If the precedence parameter is higher than the precedence of the operator (or constructor, function, etc.) being displayed, then that suggests that the output will need to be surrounded in parentheses in order to bind tightly enough (see ).For example, if an operator constructor is being displayed, then the precedence requirement for its arguments will be the precedence of the operator. Meaning, if the argument binds looser than the surrounding operator, then it will require parentheses.Note that function/constructor application has an effective precedence of 10.Examples instance (Display a) => Display (Maybe a) where -- In this instance, we define 'displayPrec' rather than 'displayBuilder' as we need to decide -- whether or not to surround ourselves in parentheses based on the surrounding context. -- If the precedence parameter is higher than 10 (the precedence of constructor application) -- then we indeed need to surround ourselves in parentheses to avoid malformed outputs -- such as @Just Just 5@. -- We then set the precedence parameter of the inner 'displayPrec' to 11, as even -- constructor application is not strong enough to avoid parentheses. displayPrec _ Nothing = "Nothing" displayPrec prec (Just a) = displayParen (prec > 10) $ "Just " <> displayPrec 11 a data Pair a b = a :*: b infix 5 :*: -- arbitrary choice of precedence instance (Display a, Display b) => Display (Pair a b) where displayPrec prec (a :*: b) = displayParen (prec > 5) $ displayPrec 6 a <> " :*: " <> displayPrec 6 b text-displayConvert a value to a readable Y.Examples display 3"3" display True"True" text-display,A utility function that surrounds the given W with parentheses when the Bool parameter is True. Useful for writing instances that may require nesting. See the  % documentation for more information. text-display text-display text-display text-display text-display text-display text-displayStrict Y text-displayLazy Z text-display ! is overloaded, so that when the  Display [a] instance calls  , we end up with a nice string instead of a list of chars between brackets.display [1, 2, 3] "[1,2,3]"!display ['h', 'e', 'l', 'l', 'o']"hello" text-display* You should not try to display functions!  Write a  'newtype' wrapper that represents your domain more accurately. If you are not consciously trying to use  on a function, make sure that you are not missing an argument somewhere. text-display1 You should not try to display lazy ByteStrings!, Always provide an explicit encoding. Use  or  to convert from UTF-8 text-display3 You should not try to display strict ByteStrings!, Always provide an explicit encoding. Use  or  to convert from UTF-8 text-displayThis wrapper allows you to create an opaque instance for your type, useful for redacting sensitive content like tokens or passwords. text-display2This wrapper allows you to rely on a pre-existing V instance in order to derive   from it.. text-display/ text-display0 text-display1 text-display2 text-display3 text-display4 text-display5 text-display6 text-display7 text-display8 text-display9 text-display: text-display; text-display< text-display= text-display> text-display? text-display@ text-display  text-display9The precedence level passed in by the surrounding context    Jonathan Lorimer, 2023MITjonathanlorimer@pm.mestableNone"/1?!A text-display Constraint to prevent misuse of D deriving via mechanism.Example data MySum = A | B | C deriving stock (Generic) deriving (Display) via (RecordInstance MySum)  @  Cannot derive Display instance for MySum via RecordInstance due to sum type  Sum types should use a manual instance or derive one via ShowInstance. @ When deriving the instance for (Display MySum)C text-displayThis type family is lifted from generic-data. We use it to prevent the user from deriving a D for sum typesD text-display%This wrapper allows you to create an   instance for a record, so long as all the record fields have a   instance as well.Example data Password = Password deriving Display via (OpaqueInstance "[REDACTED]" Password) data MyRecord = MyRecord { fieldA :: String , fieldB :: Maybe String , fieldC :: Int , pword :: Password } deriving stock (Generic) deriving (Display) via (RecordInstance MyRecord) putStrLn . Data.Text.unpack . display $ MyRecord "hello" (Just "world") 22 Password MyRecord { fieldA = hello , fieldB = Just world , fieldC = 22 , pword = [REDACTED] }G text-displayGeneric typeclass machinery for inducting on the structure of the type, such that we can thread   instances through the structure of the type. The primary use case is for implementing D, which does this "threading" for record fields. This machinery does, crucially, depend on child types (i.e. the type of a record field) having a   instance.O text-displayThis is the most important instance, it can be considered as the "base case". It requires a non-generic   instance. All this generic machinery can be conceptualized as distributing these   calls across a product type.U text-displayWe leverage the  AssertNoSum type family to prevent consumers from deriving instances for sum types. Sum types should use a manual instance or derive one via . ABCDFEGHI GHIDFECBA Hcate Moonlight, 2021MIThecate@glitchbra.instable Safe-Inferred"o  DEF  DEF       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHHIJKLMNOPQRSTUVWXYZ[\]^_`a\bc\dc+text-display-0.0.5.1-J1K6rTA3PzJ6tDSQT8ZyA2Data.Text.Display.CoreData.Text.Display.GenericData.Text.Encoding decodeUtf8'decodeUtf8WithData.Text.DisplayDisplayRealFloatDisplayDecimal ShowInstanceOpaqueInstanceOpaqueCannotDisplayByteStringsCannotDisplayBareFunctionsDisplaydisplayBuilder displayList displayPrecdisplay displayParen$fDisplay(,,,) $fDisplay(,,) $fDisplay(,)$fDisplayMaybe$fDisplayNonEmpty $fDisplay[] $fDisplayText$fDisplayText0 $fDisplayChar $fDisplayFUN$fDisplayByteString$fDisplayByteString0$fDisplayOpaqueInstance$fDisplayShowInstance$fDisplayDisplayDecimal$fDisplayDisplayRealFloat$fRealFloatDisplayRealFloat$fRealFracDisplayRealFloat$fRealDisplayRealFloat$fOrdDisplayRealFloat$fEqDisplayRealFloat$fNumDisplayRealFloat$fFractionalDisplayRealFloat$fFloatingDisplayRealFloat$fIntegralDisplayDecimal$fRealDisplayDecimal$fEnumDisplayDecimal$fOrdDisplayDecimal$fNumDisplayDecimal$fEqDisplayDecimal$fShowShowInstance$fDisplaySomeException$fDisplayIOException$fDisplayWord64$fDisplayWord32$fDisplayWord16$fDisplayWord8 $fDisplayWord$fDisplayInteger$fDisplayInt64$fDisplayInt32$fDisplayInt16 $fDisplayInt8 $fDisplayInt$fDisplayFloat$fDisplayDouble $fDisplayBool $fDisplayVoid $fDisplay()AssertNoSumRecordInstanceAssertHasSumRecordInstanceunDisplayProduct GDisplay1gdisplayBuilder1gdisplayBuilderDefault$fGDisplay1:+:$fGDisplay1:*: $fGDisplay1M1$fGDisplay1M10$fGDisplay1M11 $fGDisplay1K1 $fGDisplay1U1 $fGDisplay1V1$fGenericRecordInstance$fAssertFalsemsg$fAssertTruemsg$fDisplayRecordInstancebaseGHC.ShowShowtext-2.1-9HM8jbghPTNGoq78q5e19bData.Text.Internal.BuilderBuilderghc-prim GHC.TypesCharData.Text.InternalTextData.Text.Internal.Lazy