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
- Packageprettyprinter-configurable-1.36.0.0
- Exports15
- LanguageHaskell2010
- LicenceNONE
- SourceFixity.hs
module Text.Fixity
module Text.PrettyBy.Monad
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.
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).
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.
Pretty-print two things with a space between them. The fixity of the context in which the arguments get pretty-printed is set to juxtFixity.
Run InContextM by supplying a config.
Call encloseM on unitFixity.
Instantiate a supplied continuation with a precedence-aware pretty-printer.
The type of a general config-based pretty-printer.
A constraint for "RenderContext is a part of config".
Methods
renderContext :: Lens' config RenderContext
Instances1HasRenderContext
HasRenderContext RenderContextDefined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.Fixity
A monad for precedence-aware pretty-printing.
Constructors
InContextMunInContextM :: Reader (Sole config) a
Instances5Monad, Functor, Applicative, MonadReader, IsString
Monad (InContextM config)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.FixityFunctor (InContextM config)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.FixityApplicative (InContextM config)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.FixityMonadReader (Sole config) (InContextM config)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.Fixity(HasRenderContext config, doc ~ Doc ann) => IsString (InContextM config doc)Defined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.FixityA string written in the InContextM monad gets enclosed with unitDocM automatically.
type MonadPrettyContext config env (m :: Type -> Type) = (MonadPretty config env m, HasRenderContext config)A constraint for "m is a Monad supporting configurable precedence-aware pretty-printing".
A newtype wrapper around a introduced for its HasPrettyConfig instance.
Instances2HasPrettyConfig, MonadReader
HasPrettyConfig (Sole config) configDefined in prettyprinter-configurable-1.36.0.0 · Text.PrettyBy.FixityIt'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