Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides rendering of Portrayal
to Doc
.
The primary intended use of this module is to import WrappedPortray
and
use it to derive Pretty
instances:
data MyRecord = MyRecord { anInt :: Int, anotherRecord :: MyRecord } deriving Generic deriving Portray via Wrapped Generic MyRecord deriving Pretty via WrappedPortray MyRecord
This module also exports the underlying rendering functionality in a variety of forms for more esoteric uses.
Synopsis
- showPortrayal :: Portray a => a -> String
- pp :: Portray a => a -> IO ()
- showDiff :: Diff a => a -> a -> String
- ppd :: Diff a => a -> a -> IO ()
- newtype WrappedPortray a = WrappedPortray {
- unWrappedPortray :: a
- type DocAssocPrec = Assoc -> Rational -> Doc
- toDocAssocPrecF :: PortrayalF DocAssocPrec -> DocAssocPrec
- toDocAssocPrec :: Portrayal -> DocAssocPrec
- portrayalToDocPrecF :: PortrayalF DocAssocPrec -> PrettyLevel -> Rational -> Doc
- portrayalToDocPrec :: Portrayal -> PrettyLevel -> Rational -> Doc
- portrayalToDoc :: Portrayal -> Doc
- prettyShowPortrayal :: Portrayal -> String
- pPrintPortrayal :: PrettyLevel -> Rational -> Portrayal -> Doc
Pretty-Printing
Diffing
showDiff :: Diff a => a -> a -> String Source #
Pretty-print a diffe between to values using a Diff
instance.
ppd :: Diff a => a -> a -> IO () Source #
Pretty-print a diff between two values to stdout using a Diff
instance.
DerivingVia wrapper
newtype WrappedPortray a Source #
A newtype providing a Pretty
instance via Portray
, for DerivingVia
.
Sadly we can't use Wrapped
since it would be an orphan instance. Oh well.
We'll just define a unique WrappedPortray
newtype in each
pretty-printer-integration package.
Instances
Rendering Functions
With Associativity
type DocAssocPrec = Assoc -> Rational -> Doc Source #
A Doc
that varies according to associativity and precedence context.
toDocAssocPrecF :: PortrayalF DocAssocPrec -> DocAssocPrec Source #
Render one layer of PortrayalF
to DocAssocPrec
.
With Precedence
portrayalToDocPrecF :: PortrayalF DocAssocPrec -> PrettyLevel -> Rational -> Doc Source #
Render a PortrayalF
to a Doc
.
portrayalToDocPrec :: Portrayal -> PrettyLevel -> Rational -> Doc Source #
Convenience Functions
pPrintPortrayal :: PrettyLevel -> Rational -> Portrayal -> Doc Source #
portrayalToDocPrec
with arguments ordered for use in pPrintPrec
.