ghc-exactprint-0.5.0.0: ExactPrint for GHC

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Utils

Contents

Synopsis

Manipulating Positons

undelta :: Pos -> DeltaPos -> LayoutStartCol -> Pos Source

Apply the delta to the current position, taking into account the current column offset if advancing to a new line

isPointSrcSpan :: SrcSpan -> Bool Source

Checks whether a SrcSpan has zero length.

pos2delta :: Pos -> Pos -> DeltaPos Source

Convert the start of the second Pos to be an offset from the first. The assumption is the reference starts before the second Pos

ss2delta :: Pos -> SrcSpan -> DeltaPos Source

Create a delta from the current position to the start of the given SrcSpan.

addDP :: DeltaPos -> DeltaPos -> DeltaPos Source

Add together two DeltaPos taking into account newlines

DP (0, 1) `addDP` DP (0, 2) == DP (0, 3)
DP (0, 9) `addDP` DP (1, 5) == DP (1, 5)
DP (1, 4) `addDP` DP (1, 3) == DP (2, 3)

isGoodDelta :: DeltaPos -> Bool Source

A good delta has no negative values.

Manipulating Comments

mkKWComment :: AnnKeywordId -> SrcSpan -> Comment Source

Makes a comment which originates from a specific keyword.

dpFromString :: String -> DeltaPos Source

Calculates the distance from the start of a string to the end of a string.

GHC Functions

Manipulating Annotations

annTrueEntryDelta :: Annotation -> DeltaPos Source

The "true entry" is the distance from the last concrete element to the start of the current element.

annCommentEntryDelta :: Annotation -> DeltaPos -> DeltaPos Source

Take an annotation and a required "true entry" and calculate an equivalent one relative to the last comment in the annPriorComments.

annLeadingCommentEntryDelta :: Annotation -> DeltaPos Source

Return the DP of the first item that generates output, either a comment or the entry DP

General Utility

orderByKey :: [(SrcSpan, a)] -> [SrcSpan] -> [a] Source

Given a list of items and a list of keys, returns a list of items ordered by their position in the list of keys.

For tests

debug :: c -> String -> c Source

Provide a version of trace the comes at the end of the line, so it can easily be commented out when debugging different things.

debugM :: Monad m => String -> m () Source

warn :: c -> String -> c Source

showGhc :: Outputable a => a -> String Source

Show a GHC.Outputable structure

showAnnData :: Data a => Anns -> Int -> a -> String Source

Show a GHC AST with interleaved Annotation information.

ghead :: String -> [a] -> a Source

glast :: String -> [a] -> a Source

gtail :: String -> [a] -> [a] Source