-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Pretty printing of Haskell-Tools AST
--   
--   Converts the Haskell-Tools AST to text. Prepares the AST for this
--   conversion. If the AST was created from the GHC AST this pretty
--   printing will result in the original source code. Generated AST parts
--   will get the default formatting. Works using the source annotations
--   that are present in the AST. Creates a rose tree first to simplify the
--   conversion.
@package haskell-tools-prettyprint
@version 1.0.1.1


-- | A module for preparing the representation of the AST for pretty
--   printing.
module Language.Haskell.Tools.PrettyPrint.Prepare

-- | Prepares the AST for pretty printing
prepareAST :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage
prepareASTCpp :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage

-- | Puts comments in the nodes they should be attached to. Watches for
--   lexical tokens that may divide the comment and the supposed element.
--   Leaves the AST in a state where parent nodes does not contain all of
--   their children.
placeComments :: RangeInfo stage => Map ApiAnnKey [SrcSpan] -> Map SrcSpan [Located AnnotationComment] -> Ann UModule dom stage -> Ann UModule dom stage
getNormalComments :: Map SrcSpan [Located AnnotationComment] -> Map SrcSpan [Located AnnotationComment]
getPragmaComments :: Map SrcSpan [Located AnnotationComment] -> Map String [Located String]
child :: SpanInfo SrcTemplateStage
opt :: OptionalInfo SrcTemplateStage
list :: ListInfo SrcTemplateStage

-- | Put the given string before the element if it is not empty
after :: AfterBefore i => String -> i -> i

-- | The given string should follow the element if it is not empty
followedBy :: AfterBefore i => String -> i -> i

-- | The element should be indented relatively to its parent
relativeIndented :: RelativeIndent i => Int -> i -> i

-- | The elements should be indented at least to the given number of spaces
minimumIndented :: MinimumIndent i => Int -> i -> i

-- | The elements of the list should be separated by the given string by
--   default (might be overridden)
separatedBy :: String -> ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage

-- | The elements of the list should be indented on the same column
indented :: ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage

-- | Concatenates two source templates to produce a new template with all
--   child elements.
(<>) :: SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage
sourceTemplateNodeRange :: Simple Lens (SpanInfo SrcTemplateStage) SrcSpan
sourceTemplateNodeElems :: Simple Lens (SpanInfo SrcTemplateStage) [SourceTemplateElem]
sourceTemplateListRange :: Simple Lens (ListInfo SrcTemplateStage) SrcSpan
srcTmpListBefore :: Simple Lens (ListInfo SrcTemplateStage) String
srcTmpListAfter :: Simple Lens (ListInfo SrcTemplateStage) String
srcTmpDefaultSeparator :: Simple Lens (ListInfo SrcTemplateStage) String
srcTmpIndented :: Simple Lens (ListInfo SrcTemplateStage) (Maybe [Bool])
srcTmpSeparators :: Simple Lens (ListInfo SrcTemplateStage) [([SourceTemplateTextElem], SrcSpan)]
sourceTemplateOptRange :: Simple Lens (OptionalInfo SrcTemplateStage) SrcSpan
srcTmpOptBefore :: Simple Lens (OptionalInfo SrcTemplateStage) String
srcTmpOptAfter :: Simple Lens (OptionalInfo SrcTemplateStage) String

-- | An element of a source template for a singleton AST node.
data SourceTemplateElem

-- | Source text belonging to the current node
TextElem :: [SourceTemplateTextElem] -> SrcSpan -> SourceTemplateElem
[_sourceTemplateTextElem] :: SourceTemplateElem -> [SourceTemplateTextElem]
[_sourceTemplateTextRange] :: SourceTemplateElem -> SrcSpan

-- | Placeholder for the next children of the node
ChildElem :: SourceTemplateElem
sourceTemplateTextElem :: Partial SourceTemplateElem SourceTemplateElem [SourceTemplateTextElem] [SourceTemplateTextElem]
sourceTemplateTextRange :: Partial SourceTemplateElem SourceTemplateElem SrcSpan SrcSpan
data SourceTemplateTextElem
NormalText :: String -> SourceTemplateTextElem
[_sourceTemplateText] :: SourceTemplateTextElem -> String
StayingText :: String -> String -> SourceTemplateTextElem
[_sourceTemplateText] :: SourceTemplateTextElem -> String
[_lineEndings] :: SourceTemplateTextElem -> String
sourceTemplateText :: Lens SourceTemplateTextElem SourceTemplateTextElem String String
lineEndings :: Partial SourceTemplateTextElem SourceTemplateTextElem String String
isStayingText :: SourceTemplateTextElem -> Bool
rangeToSource :: SourceInfoTraversal node => StringBuffer -> Ann node dom RngTemplateStage -> Ann node dom SrcTemplateStage

-- | Modifies ranges to contain their children
fixRanges :: SourceInfoTraversal node => Ann node dom RangeStage -> Ann node dom NormRangeStage

-- | Creates a source template from the ranges and the input file. All
--   source ranges must be good ranges.
cutUpRanges :: forall node dom. SourceInfoTraversal node => Ann node dom NormRangeStage -> Ann node dom RngTemplateStage

-- | Assigns an index (in the order they are used) for each range
getLocIndices :: SourceInfoTraversal e => Ann e dom RngTemplateStage -> Set (RealSrcLoc, Int)

-- | Partitions the source file in the order where the parts are used in
--   the AST
mapLocIndices :: Ord k => StringBuffer -> Set (RealSrcLoc, k) -> Map k String
fixMainRange :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom RangeStage

-- | Marks template elements in the AST that should always be present in
--   the source code, regardless of their containing elements being
--   deleted. Currently it recognizes CPP pragmas (lines starting with #)
--   This function should only be applied to an AST if CPP is enabled.
extractStayingElems :: SourceInfoTraversal node => Ann node dom SrcTemplateStage -> Ann node dom SrcTemplateStage
sourceTemplateMinimalIndent :: Simple Lens (SpanInfo SrcTemplateStage) Int
srcTmpListMinimalIndent :: Simple Lens (ListInfo SrcTemplateStage) Int
srcTmpOptMinimalIndent :: Simple Lens (OptionalInfo SrcTemplateStage) Int
data TransformationProblem
TransformationProblem :: String -> TransformationProblem
data BreakUpProblem
BreakUpProblem :: RealSrcSpan -> SrcSpan -> [SrcSpan] -> BreakUpProblem
[bupOuter] :: BreakUpProblem -> RealSrcSpan
[bupInner] :: BreakUpProblem -> SrcSpan
[bupSiblings] :: BreakUpProblem -> [SrcSpan]


-- | Pretty printing the AST
module Language.Haskell.Tools.PrettyPrint

-- | Pretty prints an AST by using source templates stored as node info
prettyPrint :: (SourceInfoTraversal node) => node dom SrcTemplateStage -> String

-- | Transforms the heterogeneous AST into a homogeneous representation for
--   pretty printing
toRoseTree :: (SourceInfoTraversal n) => n dom st -> RoseTree st
data PrettyPrintProblem
PrettyPrintProblem :: String -> PrettyPrintProblem
