portray-pretty-0.1.0.0: "pretty" integration for "portray"
Safe HaskellNone
LanguageHaskell2010

Data.Portray.Pretty

Description

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

Pretty-Printing

showPortrayal :: Portray a => a -> String Source #

Pretty-print a value using its Portray instance.

pp :: Portray a => a -> IO () Source #

Pretty-print a value to stdout using its Portray instance.

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.

Constructors

WrappedPortray 

Fields

Instances

Instances details
Eq a => Eq (WrappedPortray a) Source # 
Instance details

Defined in Data.Portray.Pretty

Ord a => Ord (WrappedPortray a) Source # 
Instance details

Defined in Data.Portray.Pretty

Show a => Show (WrappedPortray a) Source # 
Instance details

Defined in Data.Portray.Pretty

Portray a => Pretty (WrappedPortray a) Source #

Provide an instance for Pretty by way of Portray.

Instance details

Defined in Data.Portray.Pretty

Rendering Functions

With Associativity

type DocAssocPrec = Assoc -> Rational -> Doc Source #

A Doc that varies according to associativity and precedence context.

toDocAssocPrec :: Portrayal -> DocAssocPrec Source #

Render a Portrayal to a Doc with support for operator associativity.

With Precedence

portrayalToDocPrec :: Portrayal -> PrettyLevel -> Rational -> Doc Source #

Render a Portrayal to a Doc with only operator precedence.

Convenience Functions

prettyShowPortrayal :: Portrayal -> String Source #

Convenience function for rendering a Portrayal to a String.

pPrintPortrayal :: PrettyLevel -> Rational -> Portrayal -> Doc Source #

portrayalToDocPrec with arguments ordered for use in pPrintPrec.