h*xq      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~1.0.0.0  Safe-Inferred 69:; PrettyBy ViaShow (PrettyAny a) where prettyBy ViaShow = pretty . show . unPrettyAny!prettyBy ViaShow $ PrettyAny TrueTrue0or you can use the type to via-derive instances: data D = D deriving stock (Show)4deriving via PrettyAny D instance PrettyBy ViaShow DprettyBy ViaShow DDOne important use case is handling sum-type configs. For example having two configs you can define their sum and derive A3 for the unified config in terms of its components:data UpperCase = UpperCasedata LowerCase = LowerCase=data Case = CaseUpperCase UpperCase | CaseLowerCase LowerCaseinstance (PrettyBy UpperCase a, PrettyBy LowerCase a) => PrettyBy Case (PrettyAny a) where prettyBy (CaseUpperCase upper) = prettyBy upper . unPrettyAny; prettyBy (CaseLowerCase lower) = prettyBy lower . unPrettyAny*Then having a data type implementing both PrettyBy UpperCase and PrettyBy LowerCase you can derive  PrettyBy Case for that data type: data D = D>instance PrettyBy UpperCase D where prettyBy UpperCase D = "D">instance PrettyBy LowerCase D where prettyBy LowerCase D = "d"1deriving via PrettyAny D instance PrettyBy Case DprettyBy UpperCase DDprettyBy LowerCase Dd Look into test/Universal.hs for an extended example.$prettyprinter-configurable"A newtype wrapper defined for its A& instance that allows to via-derive a A9 instance for a type supporting default pretty-printing.'prettyprinter-configurablePrettyDefaultBy config a is the same thing as PrettyBy config a, when a) supports default pretty-printing. Thus PrettyDefaultBy config a and PrettyBy config a are interchangeable constraints for such types, but the latter throws an annoying "this makes type inference for inner bindings fragile" warning, unlike the former. PrettyDefaultBy config a reads as "a supports default pretty-printing and can be pretty-printed via config? in either default or non-default manner depending on whether config# supports default pretty-printing".(prettyprinter-configurable A version of @< that is never stuck: it either immediately evaluates to a  or fails with a .)prettyprinter-configurableThe error thrown when HasPrettyDefaults config is stuck.*prettyprinter-configurableThrow err when b is stuck.+prettyprinter-configurable+ is a class for dispatching on HasPrettyDefaults config : if it's 'True, then , is instantiated as 2, otherwise as / (and similarly for -). I.e. depending on whether a config allows to pretty-print values using default pretty-printing, either the default or non-default pretty-printing strategy is used..prettyprinter-configurableA class for overriding default pretty-printing behavior for types having it. Read the docs of @ for how to use the class./prettyprinter-configurablePretty-print a value of a type supporting default pretty-printing in a possibly non-default way. The "possibly" is due to /% having a default implementation as 2. See docs for @ for details.0prettyprinter-configurable0 to C is what / to B.. Analogously, the default implementation is 3.1prettyprinter-configurableA class for pretty-printing values is some default manner. Basic example: data D = D0instance PrettyBy () D where prettyBy () D = "D"defaultPrettyBy () (Just D)D1 and A$ are mutually recursive in a sense: A delegates to 1 (provided the config supports defaults) when given a value of a type supporting default pretty-printing and 1 delegates back to A* for elements of a polymorphic container.It is possible to extend the set of types supporting default pretty-printing. If you have a newtype wrapping a type that already supports default pretty-printing, then "registering" that newtype= amounts to making a standalone newtype-deriving declaration:newtype AlsoInt = AlsoInt Intderiving newtype instance PrettyDefaultBy config Int => PrettyBy config AlsoIntprettyBy () (AlsoInt 42)420Note that you have to use standalone deriving as newtype AlsoInt = AlsoInt Int deriving newtype (PrettyBy config)doesn't please GHC.1It's also good practice to preserve coherence of  and A, so I'd also add deriving newtype (Pretty) to the definition of AlsoInt!, even though it's not necessary.When you want to extend the set of types supporting default pretty-printing with a data type that is a data rather than a newtype, you can directly implement 1 and and via-derive A: data D = Dinstance DefaultPrettyBy config D where defaultPrettyBy _ D = "D"deriving via PrettyCommon D instance PrettyDefaultBy config D => PrettyBy config D prettyBy () DD-But since it's best to preserve coherence of  and A for types supporting default pretty-printing, it's recommended (not mandatory) to define a  instance and anyclass-derive 1 in terms of it: data D = D&instance Pretty D where pretty D = "D"!instance DefaultPrettyBy config Dderiving via PrettyCommon D instance PrettyDefaultBy config D => PrettyBy config DprettyBy () [D, D, D] [D, D, D] Note that 1$ is specifically designed to handle all configs in its instances, i.e. you only specify a data type in a 1 instance and leave config universally quantified. This is because default pretty-printing behavior should be the same for all configs supporting default pretty-printing (it's the default after all). If you want to override the defaults, read the docs of @.Since config in a 12 instance is meant to be universally quantified, 2 (the main method of 1) has to ignore the config in the monomorphic case as it can't use it in any way anyway, i.e. in the monomorphic case 2# has the exact same info as simple ., which is another reason to anyclass-derive 1 in terms of .Like in the case of B , the default implementation of 2 for a  is E (and for a  -- F):1data Twice a = Twice a a deriving stock (Functor)instance Pretty a => Pretty (Twice a) where pretty (Twice x y) = pretty x <+> "&" <+> pretty y>instance PrettyBy config a => DefaultPrettyBy config (Twice a)deriving via PrettyCommon (Twice a) instance PrettyDefaultBy config (Twice a) => PrettyBy config (Twice a)prettyBy () (Twice True False) True & FalseSince preserving coherence of  and A is only a good practice and not mandatory, it's fine not to provide an instance for  . Then a 1 can be implemented directly:data Twice a = Twice a ainstance PrettyBy config a => DefaultPrettyBy config (Twice a) where defaultPrettyBy config (Twice x y) = prettyBy config x <+> "&" <+> prettyBy config yderiving via PrettyCommon (Twice a) instance PrettyDefaultBy config (Twice a) => PrettyBy config (Twice a)prettyBy () (Twice True False) True & FalseBut make sure that if both a  and a 1( instances exist, then they're in sync.2prettyprinter-configurablePretty-print a value of type a in some default manner. The default implementation works equally to the one of B.3prettyprinter-configurable3 to C is what 2 to B. The default implementation is "pretty-print the spine of a list the way 0 does that and pretty-print the elements using 2".4prettyprinter-configurableSame as ;, but for providing a # instance for anything that has a 14 instance. Needed for the default implementation of 3.6prettyprinter-configurableIntroducing a class just for the nice name of the method and in case the defaulting machinery somehow blows up in the user's face.8prettyprinter-configurable=This allows us to have different default implementations for B and 2 depending on whether a is a monomorphic type or a  or a . Read the docs of B for details.:prettyprinter-configurableReturn the longest sequence of Type in the kind (right-to-left) of the head of an application. (but no longer than Type -> Type -> Type*, because we can't support longer ones in 8).;prettyprinter-configurable=A config together with some value. The point is to provide a # instance for anything that has a PrettyBy config instance.=prettyprinter-configurableA newtype wrapper around a whose point is to provide a PrettyBy config# instance for anything that has a  instance.@prettyprinter-configurableDetermines whether a pretty-printing config allows default pretty-printing for types that support it. I.e. it's possible to create a new config and get access to pretty-printing for all types supporting default pretty-printing just by providing the right type instance. Example:data DefCfg = DefCfg.type instance HasPrettyDefaults DefCfg = 'True8prettyBy DefCfg (['a', 'b', 'c'], (1 :: Int), Just True)(abc, 1, True)The set of types supporting default pretty-printing is determined by the  prettyprinter library: whatever there has a  instance also supports default pretty-printing in this library and the behavior of pretty x and prettyBy config_with_defaults x must be identical when x is one of such types.It is possible to override default pretty-printing. For this you need to specify that @ is 'False# for your config and then define a NonDefaultPrettyBy config instance for each of the types supporting default pretty-printing that you want to pretty-print values of. Note that once @ is specified to be 'False, all defaults are lost for your config, so you can't override default pretty-printing for one type and keep the defaults for all the others. I.e. if you havedata NonDefCfg = NonDefCfg2type instance HasPrettyDefaults NonDefCfg = 'Falsethen you have no defaults available and an attempt to pretty-print a value of a type supporting default pretty-printing prettyBy NonDefCfg Trueresults in a type error: @ No instance for (NonDefaultPrettyBy NonDef Bool) arising from a use of @prettyBy@,As the error suggests you need to provide a . instance explicitly:instance NonDefaultPrettyBy NonDefCfg Bool where nonDefaultPrettyBy _ b = if b then "t" else "f"prettyBy NonDefCfg Truet:It is also possible not to provide any implementation for /, in which case it defaults to being the default pretty-printing for the given type. This can be useful to recover default pretty-printing for types pretty-printing of which you don't want to override:)instance NonDefaultPrettyBy NonDefCfg IntprettyBy NonDefCfg (42 :: Int)42 Look into test/NonDefault.hs for an extended example.We could give the user more fine-grained control over what defaults to override instead of requiring to explicitly provide all the instances whenever there's a need to override any default behavior, but that would complicate the library even more, so we opted for not doing that at the moment.Note that you can always override default behavior by wrapping a type in newtype and providing a PrettyBy config_name instance for that newtype.Also note that if you want to extend the set of types supporting default pretty-printing it's not enough to provide a  instance for your type (such logic is hardly expressible in present day Haskell). Read the docs of 1 for how to extend the set of types supporting default pretty-printing.Aprettyprinter-configurable PrettyBy ViaShow a where prettyBy ViaShow = pretty . showwith such an instance prettyBy ViaShow (1 :: Int)- throws an error about overlapping instances: @ Overlapping instances for PrettyBy ViaShow Int arising from a use of @prettyBy@ Matching instances: instance PrettyDefaultBy config Int => PrettyBy config Int instance [safe] Show a => PrettyBy ViaShow a There's a newtype5 provided specifically for the purpose of defining a A instance for any a: !=. Read its docs for details on when you might want to use it.The A instance for common types is defined in a way that allows to override default pretty-printing behaviour, read the docs of @ for details.Bprettyprinter-configurablePretty-print a value of type a the way a config. specifies it. The default implementation of B is in terms of , E or F depending on the kind of the data type that you're providing an instance for. For example, the default implementation of B for a monomorphic type is going to be "ignore the config and call  over the value":+newtype N = N Int deriving newtype (Pretty)instance PrettyBy () NprettyBy () (N 42)42The default implementation of B for a  is going to be in terms of E:newtype N a = N a deriving stock (Functor) deriving newtype (Pretty)+instance PrettyBy () a => PrettyBy () (N a)prettyBy () (N (42 :: Int))42It's fine for the data type to have a phantom parameter as long as the data type is still a ' (i.e. the parameter has to be of kind Type). Then E is used again:newtype N a = N Int deriving stock (Functor) deriving newtype (Pretty)instance PrettyBy () (N b)prettyBy () (N 42)42If the data type has a single parameter of any other kind, then it's not a functor and so like in the monomorphic case  is used:7newtype N (b :: Bool) = N Int deriving newtype (Pretty)instance PrettyBy () (N b)prettyBy () (N 42)42Same applies to a data type with two parameters: if both the parameters are of kind Type), then the data type is assumed to be a  and hence F- is used. If the right parameter is of kind Type and the left parameter is of any other kind, then we fallback to assuming the data type is a  and defining B as E). If both the parameters are not of kind Type, we fallback to implementing B in terms of  like in the monomorphic case.Note that in all those cases a  instance for the data type has to already exist, so that we can derive a A one in terms of it. If it doesn't exist or if your data type is not supported (for example, if it has three or more parameters of kind Type<), then you'll need to provide the implementation manually.Cprettyprinter-configurableC is used to define the default A instance for [a] and  NonEmpty a$. In normal circumstances only the B2 function is used. The default implementation of C is in terms of E.Dprettyprinter-configurablePass AttachPrettyConfig config to the continuation.Eprettyprinter-configurable+Default configurable pretty-printing for a  in terms of >. Attaches the config to each value in the functor and calls  over the result, i.e. the spine of the functor is pretty-printed the way the 8 class specifies it, while the elements are printed by B.Fprettyprinter-configurable+Default configurable pretty-printing for a  in terms of ? Attaches the config to each value in the bifunctor and calls  over the result, i.e. the spine of the bifunctor is pretty-printed the way the 8 class specifies it, while the elements are printed by B.prettyprinter-configurable prettyBy () works like pretty. for types supporting default pretty-printing.Kprettyprinter-configurabledata Cfg = Cfg data D = D2instance PrettyBy Cfg D where prettyBy Cfg D = "D"!pretty $ AttachPrettyConfig Cfg DDLprettyprinter-configurabledata Cfg = Cfg data D = D&instance Pretty D where pretty D = "D"#prettyBy Cfg $ IgnorePrettyConfig DDlprettyprinter-configurable By default a  [Maybe a] is converted to [a]$ first and only then pretty-printed. braces $ prettyBy () (Just True){True},braces $ prettyBy () (Nothing :: Maybe Bool){},prettyBy () [Just False, Nothing, Just True] [False, True]?;?;ABC=>?;?;?@AABBCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~9prettyprinter-configurable-1.0.0.0-BZMjkaVQ3exBAzHEKxM80wText.Fixity.Internal Text.FixityText.PrettyBy.InternalText.PrettyBy.DefaultText.PrettyBy.Internal.UtilsText.PrettyBy.MonadText.PrettyBy.Fixityprettyprinter-configurable Text.Pretty Text.PrettyByRenderContextOver RenderContext_renderContextDirection_renderContextFixity Direction ToTheLeft ToTheRight FixityOverFixity_fixityAssociativity_fixityPrecedence AssociativityLeftAssociativeRightAssociativeNonAssociative encloseIn$fShowRenderContextOver$fEqRenderContextOver$fShowDirection $fEqDirection$fShowFixityOver$fEqFixityOver$fShowAssociativity$fEqAssociativity Precedence botFixity juxtFixity unitFixity topFixitybotRenderContexttopRenderContext PrettyAny unPrettyAny PrettyCommonunPrettyCommonPrettyDefaultByNonStuckHasPrettyDefaultsHasPrettyDefaultsStuckError ThrowOnStuckDispatchPrettyDefaultBydispatchPrettyDefaultBydispatchPrettyDefaultListByNonDefaultPrettyBynonDefaultPrettyBynonDefaultPrettyListByDefaultPrettyBydefaultPrettyBydefaultPrettyListByAttachDefaultPrettyConfig DefaultFor defaultForDispatchDefaultFordispatchDefaultFor StarsOfHeadAttachPrettyConfigIgnorePrettyConfigunIgnorePrettyConfigHasPrettyDefaultsPrettyByprettyBy prettyListBywithAttachPrettyConfigdefaultPrettyFunctorBydefaultPrettyBifunctorBy&$fDispatchDefaultFortargetFUNconfigfab%$fDispatchDefaultFortargetFUNconfigfa%$fDispatchDefaultFortargetTYPEconfiga$fDefaultFortargetconfiga$fPrettyAttachPrettyConfig"$fPrettyByconfigIgnorePrettyConfig$fDefaultPrettyByconfigNonEmpty$fDefaultPrettyByconfigList$fDefaultPrettyByconfigMaybe$fDefaultPrettyByconfigChar$fDefaultPrettyByconfig(,,)$fDefaultPrettyByconfig(,)$fDefaultPrettyByconfigConst$fDefaultPrettyByconfigIdentity$fDefaultPrettyByconfigText$fDefaultPrettyByconfigText0$fDefaultPrettyByconfigDouble$fDefaultPrettyByconfigFloat$fDefaultPrettyByconfigWord64$fDefaultPrettyByconfigWord32$fDefaultPrettyByconfigWord16$fDefaultPrettyByconfigWord8$fDefaultPrettyByconfigWord$fDefaultPrettyByconfigInt64$fDefaultPrettyByconfigInt32$fDefaultPrettyByconfigInt16$fDefaultPrettyByconfigInt8$fDefaultPrettyByconfigInt$fDefaultPrettyByconfigInteger$fDefaultPrettyByconfigNatural$fDefaultPrettyByconfigBool$fDefaultPrettyByconfig()$fDefaultPrettyByconfigVoid!$fPrettyAttachDefaultPrettyConfig%$fDispatchPrettyDefaultByFalseconfiga$$fDispatchPrettyDefaultByTrueconfiga$fPrettyByconfigPrettyCommon$fPrettyByconfigMaybe$fPrettyByconfigChar$fPrettyByconfigNonEmpty$fPrettyByconfigList$fPrettyByconfigConst$fPrettyByconfig(,,)$fPrettyByconfig(,)$fPrettyByconfigIdentity$fPrettyByconfigText$fPrettyByconfigText0$fPrettyByconfigDouble$fPrettyByconfigFloat$fPrettyByconfigWord64$fPrettyByconfigWord32$fPrettyByconfigWord16$fPrettyByconfigWord8$fPrettyByconfigWord$fPrettyByconfigInt64$fPrettyByconfigInt32$fPrettyByconfigInt16$fPrettyByconfigInt8$fPrettyByconfigInt$fPrettyByconfigInteger$fPrettyByconfigNatural$fPrettyByconfigBool$fPrettyByconfig()$fPrettyByconfigVoidRenderrender layoutDefdisplay displayBy $fRenderText $fRenderText0 $fRenderListview MonadPrettyHasPrettyConfig prettyConfigprettyMdisplayMAnyToDoc InContextM unInContextMSoleunSoleMonadPrettyContextHasRenderContext renderContext runInContextM inContextMencloseM withPrettyIn withPrettyAtunitDocM compoundDocM sequenceDocM infixDocM juxtPrettyM#$fHasRenderContextRenderContextOver$fHasPrettyConfigSoleconfig$fIsStringInContextM$fFunctorInContextM$fApplicativeInContextM$fMonadInContextM$fMonadReaderSoleInContextMghc-prim GHC.ClassesOrd*prettyprinter-1.7.1-5e7OiMaiyLWFEOfH8r8oT4Prettyprinter.InternalDocPrettypretty prettyListSimpleDocStreamSCharSFailSEmptySTextSLineSAnnPushSAnnPop LayoutOptionslayoutPageWidth PageWidthAvailablePerLine Unbounded FusionDepthDeepShallowgroupbaseGHC.Base<>fillPrettyprinter.Symbols.Asciiparenslist<+>annotatesemicommacolonspaceequalslparenrparenlbracerbracebracketsbraceshcathsepvcatnesthang punctuatesepcatindentviaShow unsafeViaShowemptyDoclineline'softline softline'hardlineflatAltalign encloseSeptupled concatWithvsepfillSepfillCatcolumnnestingwidth pageWidth fillBreakpluralenclosesurround unAnnotate reAnnotatealterAnnotations unAnnotateS reAnnotateSalterAnnotationsSfuseremoveTrailingWhitespacedefaultLayoutOptions layoutPretty layoutSmart layoutCompactsquotesdquotesanglessquotedquotelangleranglelbracketrbracketdotslash backslashpipe GHC.TypesBool GHC.TypeError TypeErrorFunctorData.Bifunctor Bifunctor ghc-bignumGHC.Num.IntegerIntegerD:R:HasPrettyDefaults()StringMonad