߆      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ $The core of the Final Pretty Printer<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DIT0QThe current state of the pretty printer consists of the line under consideration.4The dynamic context of a pretty printing computationThe maximum page width to use>The maximum amount of non-indentation space to use on one lineThe current indentation level/Whether lines are presently being broken or not NWhether there is a failure handler waiting to backgrack from laying out a line =A stack of formatting codes to be combined with the monoid op aA means of formatting annotations during rendering. This provides an opportunity for annotations to affect aspects of the output, like font selection, that can have an impact on the width. If this does not agree with the formatting chosen in the final display, then odd things might happen, so the same information should be used here if possible. GIs there a failure handler to allow backtracking from the current line?@Is the pretty printer attempting to put things on one long line?0Pretty printing can be done in any pretty monad.4Pretty monads have an additional law: failure (from .) must undo the writer and state effects. So RWST applied to Maybe is fine, but MaybeT of RWS is not.Monad m can measure lines formatted by fmt, getting width w.;For example, monospaced pretty printing can be measured in  , using an * character count. For proportional fonts, w# will typically be something like , and m will be @ to support observing the behavior of a font rendering library.Measure a particular line;Pretty printer output represents a single annotated string.The empty output Atomic outputAn annotated region of output The concatenation of two outputs:A current line under consideration for insertion of breaks/Atomic pieces of output from the pretty printerInclusion of chunksNewlines to be displayed+Strings or horizontal space to be displayedxAn atomic string. Should not contain formatting spaces or newlines (semantic/object-level spaces OK, but not newlines) (An amount of horizontal space to insert.!+Locally change the maximum horizontal space"Group a collection of pretty-printer actions, undoing their newlines if possible. If m is [], grouping has a distributive Hughes-style semantics, and if m is Maybe, then grouping has a Wadler-style left-zero semantics. The identity monad gives no grouping.#&Include a Text string in the document.$+Include a single character in the document.%1Include a space of a given width in the document.&!A line break that ignores nesting'!A lie break that respects nesting(yIncrease the nesting level to render some argument, which will result in the document being indented following newlines.)MConditionally render documents based on whether grouping is undoing newlines.,Unconditionally undo newlines in a document.*Vertically align documents.+Add a semantic annotation to a document. These annotations are converted into the output stream's notion of decoration by the renderer.,:Separate a collection of documents with a space character.-1Separate a collection of documents with newlines..8Measure a string in the current pretty printing context.Make sure to measure the text in the same dynamic context where its width is to be used, to make sure the right formatting options are applied./0Measure the width of a space in the current font04Measure the width of a capital M in the current font1WSeparate a collection of documents with a space (if there's room) or a newline if not.2Separate a collection of documents with no space if they can be on the same line, or with the width of a space character in when they cannot.3sSeparate a collection of documents with no space if they can be on the same line, or with newlines if they cannot.4)Print a collection in comma-initial form.For sub-documents d1, d2, d3, flat mode is:  [d1, d2, d3]and multi-line mode is: [ d1 , d2 , d3 ]53Align and group a subdocument, similar to Wadler's group combinator.L  !"#$%&'()*+,-./012345676   !"#$%&'()*+,-./0123456#$%+'&)"*(5./0,-1234 !  5   !"#$%&'()*+,-./01234567DA pretty printer extension for tracking precedence and associativity<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DITE2A monad transformer that adds a precedence effectsH4A pretty monad that can read precedence environmentsIPrecedence follows the structure of a document, so a Reader provides the appropriate dynamic extent of precedence information.J1What is the current precedence environment? (see )K>Override the precedence environment in a subcomputation. (see )LjA precedence environment contains enough information to determine whether parentheses should be inserted.N+The current precedence level of the contextOEA tiebreaker used to distinguish left- and right-associative contextsPNWhat to show for a left parenthesis. The optional annotation will be applied.QOWhat to show for a right parenthesis. The optional annotation will be applied.R[An initial precedence environment that works for languages with parentheses as delimiters.S%What is the current precedence level?T6Run a subcomputation with a modified precedence level.U&Is the current precedence bumped? See L.V2Put a subdocument in the lowest precedence context.Close a context with left and right delimiters>Close a context with the configured left and right parenthesesW5Run a subcomputation at a particular precedence level.Bump the precedence to implement associativity>Display a non-associative infix operator at a precedence levelX?Display a left-associative infix operator at a precedence levelY@Display a right-associative infix operator at a precedence level/Display a prefix operator at a precedence level0Display a postfix operator at a precedence levelZ7Perform function application with precedence level <100Lay out a collection like 4!, but reset the precedence level.[ERun a precedence transformer with some initial precedence environment\"Transform the value returned by a E&EFGHIJKLMNOPQRSTUVWXYZ[\]^EFGHIJKLMPQNORSTUVWXYZ[\LMNOPQRSTXYWVZUIJKHEFG[\EFGHIJKLMNOPQRSTUVWXYZ[\]^0Lexical scope tracking for final pretty printers<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DITfJA transformer that adds a reader effect, distinguished by the newtype tag.iPretty monads that can read environments. Use this to implement lexical scope in your pretty printer, because the dynamic extent of pretty monad computations typically corresponds to the scope of a binder.jA reader of environmentskSee lSee m.Run a pretty printer in an initial environmentn(Transform the result of a pretty printerfghijklmnopqrs fghijklmn ijklfghmn fghijklmnopqrs2A renderer for colored monospace text on a console<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DIT{ Render a  in some monad.|(Dump pretty printer output to a console.In ( to support rendering colors on Windows.{3How to transform a rendering based on an annotationHow to output an atomic stringThe document to render|{|{|{|None 29:;<=?DIT-Monospaced text output to be included in HTML<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DIT}sRender an document to a string suitable for inclusion in HTML. The HTML should use a monospaced font for the code.}}}} None 29:;<=?DIT>  ,  55669 ,Plain-text output from final pretty printers<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DIT~ Send pretty printer output to a  *Save pretty printer output to a named fileKSave pretty printer output to temporary file. Useful for performance tests.  ~~~  ~&Convenient helpers for pretty printing<(c) David Darais, David Christiansen, and Weixi Ma 2016-2017MITdavid.darais@gmail.com experimentalPortableNone 29:;<=?DITThe equals signWrap a document in parenthesesWrap a document in bracesA single colonA single comma       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMMNOPQRSSTUVWXYZ[\]^_`abcdefghijkllmnopqrstuvwxyz{|}~<                         3final-pretty-printer-0.1.0.0-9V1poGsOGbgG2t54ArxBfnText.PrettyPrint.Final,Text.PrettyPrint.Final.Extensions.Precedence-Text.PrettyPrint.Final.Extensions.Environment(Text.PrettyPrint.Final.Rendering.Console%Text.PrettyPrint.Final.Rendering.HTML*Text.PrettyPrint.Final.Rendering.PlainTextText.PrettyPrint.Final.Words%Text.PrettyPrint.Final.Demos.ListDemo%Text.PrettyPrint.Final.Demos.STLCDemoPStatecurLinePEnvmaxWidth maxRibbonnestinglayoutfailure formatting formatAnnFailureCanFailCantFailLayoutFlatBreak MonadPrettyMeasuremeasurePOutPNullPAtomPAnnPSeqLineAtomAChunkANewlineChunkCTextCSpace localMaxWidthgroupedtextcharspacehardLinenewlinenestifFlatalignannotatehsepvsep measureText spaceWidthemWidthhvsep hsepTight hvsepTight collectionexpr$fMeasureInt()Identity $fMonoidPOut $fEqChunk $fOrdChunk$fEqAtom $fOrdAtom$fEqPOut $fOrdPOut $fFunctorPOut $fEqLayout $fOrdLayout $fEqFailure $fOrdFailure $fEqPState $fOrdPStatePrecTunPrecTMonadPrettyPrecMonadReaderPrec askPrecEnv localPrecEnvPrecEnvlevelbumpedlparenrparenprecEnv0askLevel localLevel askBumpedbotLevelatLevelinflinfrapprunPrecTmapPrecT$fMonadReaderPrecannPrecT$fMonadReaderrPrecT$fFunctorPrecT $fMonadPrecT$fApplicativePrecT$fAlternativePrecT$fMonadTransPrecT$fMonadStatePrecT$fMonadWriterPrecTEnvTunEnvTMonadPrettyEnvMonadReaderEnvaskEnvlocalEnvrunEnvTmapEnvT$fMonadReaderPrecannEnvT$fMonadReaderEnvenvEnvT$fMonadPrettywannfmtEnvT$fMeasurewfmtEnvT$fMonadReaderrEnvT $fFunctorEnvT $fMonadEnvT$fApplicativeEnvT$fAlternativeEnvT$fMonadTransEnvT$fMonadStateEnvT$fMonadWriterEnvTrenderdumpDochPutDocsaveDoctempDocequalsparensbracescoloncommabaseGHC.Base AlternativeData.Functor.IdentityIdentityghc-prim GHC.TypesIntDoubleIOmakeFlat askMaxWidth askMaxRibbon askNesting localNesting askFormat localFormat pushFormat askFormatAnnlocalFormatAnn askLayout localLayout askFailure localFailure getCurLine putCurLinemeasureCurLine modifyLinechunk allowFail mtl-2.2.1-6qsR1PHUy5lL47Hpoa4jCMControl.Monad.Reader.Classasklocalclosedbumpinfprepost localBumped askLParen localLParen askRParen localRParen renderChunk renderAtomPrettyprettyDocDocMunDocMHsAnnCtorStxenv0state0runDocMexecDoctoSGR updateColoropenTagcloseTagrenderAnnotationdumpList shortListlongList $fPretty[] $fPrettyText$fMeasureInt()DocM $fPrettyDocM $fMonoidDocM$fIsStringDocM$fMonadPrettyIntHsAnn()DocMTEnvExpLitBinIfzVarLamAppRawOpPlusMinusTimesDivTyArrAnnClassTooltip/+//-//*/////@/litvarpunbdrkwdoprtEnv0askTEnv localTEnvftTyppOpppExp precDebuge1e2main $fPrettyExp $fShowDocM$fMonadPrettyEnvMapIntAnn()DocM$fMonadPrettyPrecIntAnn()DocM$fMonadPrettyIntAnn()DocMGHC.IO.Handle.TypesHandle hRenderChunk hRenderAtom