ghc-exactprint-1.10.0.0: ExactPrint for GHC
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Utils

Synopsis

Documentation

debugEnabledFlag :: Bool Source #

Global switch to enable debug tracing in ghc-exactprint Delta / Print

debug :: c -> String -> c Source #

Provide a version of trace that 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 #

captureOrderBinds :: [LHsDecl GhcPs] -> AnnSortKey BindTag Source #

notDocDecl :: LHsDecl GhcPs -> Bool Source #

notIEDoc :: LIE GhcPs -> Bool Source #

isGoodDelta :: DeltaPos -> Bool Source #

A good delta has no negative values.

ss2delta :: Pos -> RealSrcSpan -> DeltaPos Source #

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

ss2deltaEnd :: RealSrcSpan -> RealSrcSpan -> DeltaPos Source #

create a delta from the end of a current span. The +1 is because the stored position ends up one past the span, this is prior to that adjustment

ss2deltaStart :: RealSrcSpan -> RealSrcSpan -> DeltaPos Source #

create a delta from the start of a current span. The +1 is because the stored position ends up one past the span, this is prior to that adjustment

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

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

undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn Source #

adjustDeltaForOffset :: LayoutStartCol -> DeltaPos -> DeltaPos Source #

ss2pos :: RealSrcSpan -> Pos Source #

ss2posEnd :: RealSrcSpan -> Pos Source #

ss2range :: SrcSpan -> (Pos, Pos) Source #

rs2range :: RealSrcSpan -> (Pos, Pos) Source #

rs :: SrcSpan -> RealSrcSpan Source #

range2rs :: (Pos, Pos) -> RealSrcSpan Source #

badRealSrcSpan :: RealSrcSpan Source #

spanLength :: RealSrcSpan -> Int Source #

eloc2str :: EpaLocation -> String Source #

Useful for debug dumps

isPointSrcSpan :: RealSrcSpan -> Bool Source #

Checks whether a SrcSpan has zero length.

commentOrigDelta :: LEpaComment -> LEpaComment Source #

A GHC comment includes the span of the preceding token. Take an original comment, and convert the 'Anchor to have a have a MovedAnchor operation based on the original location, only if it does not already have one.

origDelta :: RealSrcSpan -> RealSrcSpan -> DeltaPos Source #

needsWhere :: forall (p :: Pass). DataDefnCons (LConDecl (GhcPass p)) -> Bool Source #

insertCppComments :: ParsedSource -> [LEpaComment] -> ParsedSource Source #

Insert the comments at the appropriate places in the AST

workInComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments Source #

insertTopLevelCppComments :: HsModule GhcPs -> [LEpaComment] -> (HsModule GhcPs, [LEpaComment]) Source #

data SplitWhere Source #

Constructors

Before 
After 

splitOnWhere :: SplitWhere -> [AddEpAnn] -> [LEpaComment] -> ([LEpaComment], [LEpaComment]) Source #

balanceFirstLocatedAComments :: [LocatedA a] -> ([LocatedA a], [LEpaComment]) Source #

priorCommentsDeltas' :: RealSrcSpan -> [LEpaComment] -> [(Int, LEpaComment)] Source #

allocatePriorComments :: Pos -> [LEpaComment] -> ([LEpaComment], [LEpaComment]) Source #

insertRemainingCppComments :: ParsedSource -> [LEpaComment] -> ParsedSource Source #

ghcCommentText :: LEpaComment -> String Source #

tokComment :: LEpaComment -> [Comment] Source #

hsDocStringComments :: Anchor -> RealSrcSpan -> HsDocString -> [Comment] Source #

dedentDocChunk :: LHsDocStringChunk -> LHsDocStringChunk Source #

dedentDocChunkBy :: Int -> LHsDocStringChunk -> LHsDocStringChunk Source #

epaCommentsBalanced :: [LEpaComment] -> [LEpaComment] -> EpAnnComments Source #

mkEpaComments :: [Comment] -> [Comment] -> EpAnnComments Source #

mkLEpaComment :: String -> NoCommentsLocation -> RealSrcSpan -> LEpaComment Source #

mkComment :: String -> NoCommentsLocation -> RealSrcSpan -> Comment Source #

normaliseCommentText :: String -> String Source #

cmpComments :: Comment -> Comment -> Ordering Source #

Must compare without span filenames, for CPP injected comments with fake filename

sortComments :: [Comment] -> [Comment] Source #

Sort, comparing without span filenames, for CPP injected comments with fake filename

sortEpaComments :: [LEpaComment] -> [LEpaComment] Source #

Sort, comparing without span filenames, for CPP injected comments with fake filename

mkKWComment :: AnnKeywordId -> NoCommentsLocation -> Comment Source #

Makes a comment which originates from a specific keyword.

sortAnchorLocated :: [GenLocated Anchor a] -> [GenLocated Anchor a] Source #

dpFromString :: String -> DeltaPos Source #

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

isSymbolRdrName :: RdrName -> Bool Source #

rdrName2String :: RdrName -> String Source #

name2String :: Name -> String Source #

trailingAnnLoc :: TrailingAnn -> EpaLocation Source #

setTrailingAnnLoc :: TrailingAnn -> EpaLocation -> TrailingAnn Source #

addEpAnnLoc :: AddEpAnn -> EpaLocation Source #

type DeclsByTag a = Map DeclTag [(RealSrcSpan, a)] Source #

orderedDecls :: AnnSortKey DeclTag -> DeclsByTag a -> [(RealSrcSpan, a)] Source #

hsDeclsClassDecl :: TyClDecl GhcPs -> [LHsDecl GhcPs] Source #

replaceDeclsClassDecl :: TyClDecl GhcPs -> [LHsDecl GhcPs] -> TyClDecl GhcPs Source #

partitionWithSortKey :: [LHsDecl GhcPs] -> ([DeclTag], LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs], [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs]) Source #

orderedDeclsBinds :: AnnSortKey BindTag -> [LHsDecl GhcPs] -> [LHsDecl GhcPs] -> [LHsDecl GhcPs] Source #

hsDeclsLocalBinds :: HsLocalBinds GhcPs -> [LHsDecl GhcPs] Source #

hsDeclsValBinds :: HsValBindsLR GhcPs GhcPs -> [LHsDecl GhcPs] Source #

decl2Bind :: LHsDecl GhcPs -> [LHsBind GhcPs] Source #

Pure function to convert a LHsDecl to a LHsBind. This does nothing to any annotations that may be attached to either of the elements. It is used as a utility function in replaceDecls

decl2Sig :: LHsDecl GhcPs -> [LSig GhcPs] Source #

Pure function to convert a LSig to a LHsBind. This does nothing to any annotations that may be attached to either of the elements. It is used as a utility function in replaceDecls

wrapSig :: LSig GhcPs -> LHsDecl GhcPs Source #

Convert a LSig into a LHsDecl

wrapDecl :: LHsBind GhcPs -> LHsDecl GhcPs Source #

Convert a LHsBind into a LHsDecl

showAst :: Data a => a -> String Source #