HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduleprettyprinter-configurable-1.36.0.0Haskell2010

Text.PrettyBy.Fixity

Configurable precedence-aware pretty-printing.

Look into test/Expr.hs for an extended example.

  • 4 types
  • 1 class
  • 10 values
valueencloseM
  1. :: MonadPrettyContext config env m
  2. => Fixity
  3. -> Doc ann
  4. -> m (Doc ann)
#

Enclose a Doc in parentheses if required or leave it as is. The need for enclosing is determined from an outer RenderContext (stored in the environment of the monad) and the inner fixity provided as an argument.

valueinContextM :: (a -> InContextM config (Doc ann)) -> config -> a -> Doc ann
#

Takes a monadic pretty-printer and turns it into one that receives a config explicitly. Useful for defining instances of PrettyBy monadically when writing precedence-aware pretty-printing code (and since all functions below are monadic, it's currenty the only option).

valueinfixDocM
  1. :: MonadPrettyContext config env m
  2. => Fixity
  3. -> AnyToDoc config ann -> AnyToDoc config ann -> Doc ann
  4. -> m (Doc ann)
#

Instantiate a supplied continuation with two pretty-printers (one is going in the ToTheLeft direction, the other is in the ToTheRight direction) specialized to supplied Fixity and apply encloseM, specialized to the same fixity, to the result. The idea is that to the outside an infix operator has the same inner fixity as it has the outer fixity to inner subexpressions.

typetype AnyToDoc config ann = forall a. PrettyBy config a => a -> Doc ann
#

The type of a general config-based pretty-printer.

newtypenewtype InContextM config a
#

A monad for precedence-aware pretty-printing.

Constructors

Instances5Monad, Functor, Applicative, MonadReader, IsString
newtypenewtype Sole a
#

A newtype wrapper around a introduced for its HasPrettyConfig instance.

Constructors

Instances2HasPrettyConfig, MonadReader
  • HasPrettyConfig (Sole config) configDefined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.Fixity

    It's not possible to have HasPrettyConfig config config, because that would mean that every environment is a pretty-printing config on its own, which doesn't make sense. We could have an OVERLAPPABLE instance, but I'd rather not.

  • MonadReader (Sole config) (InContextM config)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.Fixity