ghc-exactprint-0.1.0.1: ExactPrint for GHC

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Utils

Contents

Synopsis

Documentation

organiseAnns :: Anns -> OrganisedAnns Source

Re-arrange the annotations to make it clearer for users how they hang together.

undelta :: Pos -> DeltaPos -> Int -> Pos Source

Apply the delta to the current position, taking into account the current column offset

undeltaComment :: Pos -> Int -> DComment -> Comment Source

Apply the delta to the current position, taking into account the current column offset

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

Show a GHC API structure

merge :: Ord a => [a] -> [a] -> [a] Source

Merge two sorted lists into a single, sorted whole.

Example:

merge [1,3,5] [1,2,4,6] -> [1,1,2,3,4,5,6]

QuickCheck test property:

prop_merge xs ys = merge (sort xs) (sort ys) == sort (xs ++ ys) where types = xs :: [Int]

For tests

debug :: c -> String -> c Source

runAP :: AP () -> ApiAnns -> Anns Source

newtype AP x Source

Type used in the AP Monad. The state variables maintain - the current SrcSpan and the constructor of the thing it encloses as a stack to the root of the AST as it is traversed, - the srcspan of the last thing annotated, to calculate delta's from - extra data needing to be stored in the monad - the annotations provided by GHC

Constructors

AP ([(SrcSpan, AnnConName)] -> SrcSpan -> Extra -> ApiAnns -> (x, [(SrcSpan, AnnConName)], SrcSpan, Extra, ApiAnns, ([(AnnKey, Annotation)], [(AnnKeyF, [DeltaPos])]))) 

getSrcSpanAP :: AP SrcSpan Source

Note: assumes the SrcSpan stack is nonempty

addAnnotationsAP :: Annotation -> AP () Source

Add some annotation to the currently active SrcSpan

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

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

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

gfromJust :: [Char] -> Maybe a -> a Source