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

-- | ExactPrint for GHC
--   
--   Using the API Annotations available from GHC 7.10.2, this library
--   provides a means to round trip any code that can be compiled by GHC,
--   currently excluding lhs files.
--   
--   It does this with a phased approach
--   
--   
--   
- Delta - converts GHC API Annotations into relative offsets,
--   indexed by SrcSpan
--   
- Transform - functions to facilitate changes to the AST, adjusting
--   the annotations generated in the Delta phase to suit the changes.
--   
- Print - converts an AST and its annotations to properly formatted
--   source text.
--   
- Pretty - adds annotations to an AST (fragment) so that the output
--   can be parsed back to the same AST.
--   
--   
--   Note: requires GHC 7.10.2 or later
@package ghc-exactprint
@version 0.6.2

module Language.Haskell.GHC.ExactPrint.Types

-- | This structure holds a complete set of annotations for an AST
type Anns = Map AnnKey Annotation
emptyAnns :: Anns
data Annotation
Ann :: !DeltaPos -> ![(Comment, DeltaPos)] -> ![(Comment, DeltaPos)] -> ![(KeywordId, DeltaPos)] -> !Maybe [SrcSpan] -> !Maybe AnnKey -> Annotation

-- | Offset used to get to the start of the SrcSpan, from whatever the
--   prior output was, including all annPriorComments (field below).
[annEntryDelta] :: Annotation -> !DeltaPos

-- | Comments coming after the last non-comment output of the preceding
--   element but before the SrcSpan being annotated by this Annotation. If
--   these are changed then annEntryDelta (field above) must also change to
--   match.
[annPriorComments] :: Annotation -> ![(Comment, DeltaPos)]

-- | Comments coming after the last output for the element subject to this
--   Annotation. These will only be added by AST transformations, and care
--   must be taken not to disturb layout of following elements.
[annFollowingComments] :: Annotation -> ![(Comment, DeltaPos)]

-- | Annotations associated with this element.
[annsDP] :: Annotation -> ![(KeywordId, DeltaPos)]

-- | Captures the sort order of sub elements. This is needed when the
--   sub-elements have been split (as in a HsLocalBind which holds separate
--   binds and sigs) or for infix patterns where the order has been
--   re-arranged. It is captured explicitly so that after the Delta phase a
--   SrcSpan is used purely as an index into the annotations, allowing
--   transformations of the AST including the introduction of new Located
--   items or re-arranging existing ones.
[annSortKey] :: Annotation -> !Maybe [SrcSpan]

-- | Occasionally we must calculate a SrcSpan for an unlocated list of
--   elements which we must remember for the Print phase. e.g. the
--   statements in a HsLet or HsDo. These must be managed as a group
--   because they all need eo be vertically aligned for the Haskell layout
--   rules, and this guarantees this property in the presence of AST edits.
[annCapturedSpan] :: Annotation -> !Maybe AnnKey
annNone :: Annotation

-- | The different syntactic elements which are not represented in the AST.
data KeywordId

-- | A normal keyword
G :: AnnKeywordId -> KeywordId

-- | A separating comma
AnnSemiSep :: KeywordId

-- | Visible type application annotation
AnnTypeApp :: KeywordId
AnnComment :: Comment -> KeywordId

-- | Used to pass information from Delta to Print when we have to work out
--   details from the original SrcSpan.
AnnString :: String -> KeywordId

-- | A Haskell comment. The AnnKeywordId is present if it has been
--   converted from an AnnKeywordId because the annotation must be
--   interleaved into the stream and does not have a well-defined position
data Comment
Comment :: !String -> !SrcSpan -> !Maybe AnnKeywordId -> Comment

-- | The contents of the comment including separators
[commentContents] :: Comment -> !String

-- | Needed to uniquely identify two comments with the same contents
[commentIdentifier] :: Comment -> !SrcSpan

-- | We sometimes turn syntax into comments in order to process them
--   properly.
[commentOrigin] :: Comment -> !Maybe AnnKeywordId
type Pos = (Int, Int)

-- | A relative positions, row then column
newtype DeltaPos
DP :: (Int, Int) -> DeltaPos
deltaRow :: DeltaPos -> Int
deltaColumn :: DeltaPos -> Int

-- | For every Located a, use the SrcSpan and constructor
--   name of a as the key, to store the standard annotation. These are used
--   to maintain context in the AP and EP monads
data AnnKey
AnnKey :: SrcSpan -> AnnConName -> AnnKey

-- | Make an unwrapped AnnKey for the LHsDecl case, a
--   normal one otherwise.
mkAnnKey :: Constraints a => a -> AnnKey
data AnnConName
CN :: String -> AnnConName
[unConName] :: AnnConName -> String
annGetConstr :: Data a => a -> AnnConName
data Rigidity
NormalLayout :: Rigidity
RigidLayout :: Rigidity
data AstContext
LambdaExpr :: AstContext
CaseAlt :: AstContext
NoPrecedingSpace :: AstContext
HasHiding :: AstContext
AdvanceLine :: AstContext
NoAdvanceLine :: AstContext
Intercalate :: AstContext
InIE :: AstContext
PrefixOp :: AstContext
PrefixOpDollar :: AstContext
InfixOp :: AstContext
ListStart :: AstContext
ListItem :: AstContext
TopLevel :: AstContext
NoDarrow :: AstContext
AddVbar :: AstContext
Deriving :: AstContext
Parens :: AstContext
ExplicitNeverActive :: AstContext
InGadt :: AstContext
InRecCon :: AstContext
InClassDecl :: AstContext
InSpliceDecl :: AstContext
LeftMost :: AstContext
InTypeApp :: AstContext
CtxOnly :: AstContext
CtxFirst :: AstContext
CtxMiddle :: AstContext
CtxLast :: AstContext
CtxPos :: Int -> AstContext
FollowingLine :: AstContext
type AstContextSet = ACS' AstContext
defaultACS :: AstContextSet
data ACS' a
ACS :: !Map a Int -> ACS' a

-- | how many levels each AstContext should propagate down the AST. Removed
--   when it hits zero
[acs] :: ACS' a -> !Map a Int
data ListContexts
LC :: !Set AstContext -> ListContexts
[lcOnly, lcInitial, lcMiddle, lcLast] :: ListContexts -> !Set AstContext
type Constraints a = (Data a, Data (SrcSpanLess a), HasSrcSpan a)
type GhcPs = GhcPs
type GhcRn = GhcRn
type GhcTc = GhcTc

-- | Marks the start column of a layout block.
newtype LayoutStartCol
LayoutStartCol :: Int -> LayoutStartCol
[getLayoutStartCol] :: LayoutStartCol -> Int
declFun :: (forall a. Data a => Located a -> b) -> LHsDecl GhcPs -> b
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.ListContexts
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.ListContexts
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.AstContext
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.AstContext
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.AstContext
instance GHC.Show.Show a => GHC.Show.Show (Language.Haskell.GHC.ExactPrint.Types.ACS' a)
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.Rigidity
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.Rigidity
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.Rigidity
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.Annotation
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Types.KeywordId
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.KeywordId
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.KeywordId
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Types.AnnKey
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.AnnKey
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.AnnKey
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Types.AnnConName
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.AnnConName
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.AnnConName
instance GHC.Num.Num Language.Haskell.GHC.ExactPrint.Types.LayoutStartCol
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.LayoutStartCol
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Types.DeltaPos
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.DeltaPos
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.DeltaPos
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.DeltaPos
instance GHC.Classes.Ord Language.Haskell.GHC.ExactPrint.Types.Comment
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Types.Comment
instance GHC.Classes.Eq Language.Haskell.GHC.ExactPrint.Types.Comment
instance GHC.Base.Semigroup (Language.Haskell.GHC.ExactPrint.Types.ACS' Language.Haskell.GHC.ExactPrint.Types.AstContext)
instance GHC.Base.Monoid (Language.Haskell.GHC.ExactPrint.Types.ACS' Language.Haskell.GHC.ExactPrint.Types.AstContext)
instance GHC.Show.Show a => Outputable.Outputable (Language.Haskell.GHC.ExactPrint.Types.ACS' a)
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.Annotation
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.Annotation
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.KeywordId
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.KeywordId
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.AnnKey
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.AnnKey
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.AnnConName
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.AnnConName
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.LayoutStartCol
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.DeltaPos
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Types.Comment
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Types.Comment

module Language.Haskell.GHC.ExactPrint.Lookup

-- | Maps AnnKeywordId to the corresponding String representation.
--   There is no specific mapping for the following constructors.
--   AnnOpen, AnnClose, AnnVal,
--   AnnPackageName, AnnHeader, AnnFunId,
--   AnnInfix
keywordToString :: KeywordId -> String

-- | annotate is a function which given a GHC AST fragment,
--   constructs a syntax tree which indicates which annotations belong to
--   each specific part of the fragment.
--   
--   Delta and Print provide two interpreters for this
--   structure. You should probably use those unless you know what you're
--   doing!
--   
--   The functor AnnotationF has a number of constructors which
--   correspond to different sitations which annotations can arise. It is
--   hoped that in future versions of GHC these can be simplified by making
--   suitable modifications to the AST.
module Language.Haskell.GHC.ExactPrint.AnnotateTypes

-- | 
--   
- MarkPrim The main constructor. Marks that a specific
--   AnnKeywordId could appear with an optional String which is used when
--   printing.
--   
- MarkPPOptional Used to flag elements, such as
--   optional braces, that are not used in the pretty printer. This
--   functions identically to MarkPrim for the other
--   interpreters.
--   
- MarkEOF Special constructor which marks the end of
--   file marker.
--   
- MarkExternal TODO
--   
- MarkOutside A AnnKeywordId which is
--   precisely located but not inside the current context. This is usually
--   used to reassociated located RdrName which are more naturally
--   associated with their parent than in their own annotation.
--   
- MarkInside The dual of MarkOutside. If we wish to
--   mark a non-separating comma or semi-colon then we must use this
--   constructor.
--   
- MarkMany Some syntax elements allow an arbritary
--   number of puncuation marks without reflection in the AST. This
--   construction greedily takes all of the specified
--   AnnKeywordId.
--   
- MarkOffsetPrim Some syntax elements have repeated
--   AnnKeywordId which are seperated by different
--   AnnKeywordId. Thus using MarkMany is unsuitable and instead
--   we provide an index to specify which specific instance to choose each
--   time.
--   
- WithAST TODO
--   
- CountAnns Sometimes the AST does not reflect the
--   concrete source code and the only way to tell what the concrete source
--   was is to count a certain kind of AnnKeywordId.
--   
- WithSortKey There are many places where the
--   syntactic ordering of elements is thrown away by the AST. This
--   constructor captures the original ordering and reflects any changes in
--   ordered as specified by the annSortKey field in
--   Annotation.
--   
- SetLayoutFlag It is important to know precisely
--   where layout rules apply. This constructor wraps a computation to
--   indicate that LayoutRules apply to the corresponding construct.
--   
- StoreOriginalSrcSpan TODO
--   
- GetSrcSpanFromKw TODO
--   
- StoreString TODO
--   
- AnnotationsToComments Used when the AST is
--   sufficiently vague that there is no other option but to convert a
--   fragment of source code into a comment. This means it is impossible to
--   edit such a fragment but means that processing files with such
--   fragments is still possible.
--   
data AnnotationF next
[MarkPrim] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkPPOptional] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkEOF] :: next -> AnnotationF next
[MarkExternal] :: SrcSpan -> AnnKeywordId -> String -> next -> AnnotationF next
[MarkInstead] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkOutside] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkInside] :: AnnKeywordId -> next -> AnnotationF next
[MarkMany] :: AnnKeywordId -> next -> AnnotationF next
[MarkManyOptional] :: AnnKeywordId -> next -> AnnotationF next
[MarkOffsetPrim] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[MarkOffsetPrimOptional] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[WithAST] :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> Annotated b -> next -> AnnotationF next
[CountAnns] :: AnnKeywordId -> (Int -> next) -> AnnotationF next
[WithSortKey] :: [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[SetLayoutFlag] :: Rigidity -> Annotated () -> next -> AnnotationF next
[MarkAnnBeforeAnn] :: AnnKeywordId -> AnnKeywordId -> next -> AnnotationF next
[StoreOriginalSrcSpan] :: SrcSpan -> AnnKey -> (AnnKey -> next) -> AnnotationF next
[GetSrcSpanForKw] :: SrcSpan -> AnnKeywordId -> (SrcSpan -> next) -> AnnotationF next
[AnnotationsToComments] :: [AnnKeywordId] -> next -> AnnotationF next
[SetContextLevel] :: Set AstContext -> Int -> Annotated () -> next -> AnnotationF next
[UnsetContext] :: AstContext -> Annotated () -> next -> AnnotationF next
[IfInContext] :: Set AstContext -> Annotated () -> Annotated () -> next -> AnnotationF next
[WithSortKeyContexts] :: ListContexts -> [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[TellContext] :: Set AstContext -> next -> AnnotationF next
type Annotated = FreeT AnnotationF Identity
markEOF :: forall m_aNAv. MonadFree AnnotationF m_aNAv => m_aNAv ()
markPrim :: forall m_aOkI. MonadFree AnnotationF m_aOkI => AnnKeywordId -> Maybe String -> m_aOkI ()
markPPOptional :: forall m_aOlP. MonadFree AnnotationF m_aOlP => AnnKeywordId -> Maybe String -> m_aOlP ()
markInstead :: forall m_aOmW. MonadFree AnnotationF m_aOmW => AnnKeywordId -> KeywordId -> m_aOmW ()
markOutside :: forall m_aOo3. MonadFree AnnotationF m_aOo3 => AnnKeywordId -> KeywordId -> m_aOo3 ()
markInside :: forall m_aOpa. MonadFree AnnotationF m_aOpa => AnnKeywordId -> m_aOpa ()
markExternal :: forall m_aOqe. MonadFree AnnotationF m_aOqe => SrcSpan -> AnnKeywordId -> String -> m_aOqe ()
markMany :: forall m_aOro. MonadFree AnnotationF m_aOro => AnnKeywordId -> m_aOro ()
markManyOptional :: forall m_aOss. MonadFree AnnotationF m_aOss => AnnKeywordId -> m_aOss ()
markOffsetPrim :: forall m_aOtw. MonadFree AnnotationF m_aOtw => AnnKeywordId -> Int -> Maybe String -> m_aOtw ()
markOffsetPrimOptional :: forall m_aOuG. MonadFree AnnotationF m_aOuG => AnnKeywordId -> Int -> Maybe String -> m_aOuG ()
countAnns :: forall m_aOvQ. MonadFree AnnotationF m_aOvQ => AnnKeywordId -> m_aOvQ Int
storeOriginalSrcSpan :: forall m_aOwV. MonadFree AnnotationF m_aOwV => SrcSpan -> AnnKey -> m_aOwV AnnKey
getSrcSpanForKw :: forall m_aOy3. MonadFree AnnotationF m_aOy3 => SrcSpan -> AnnKeywordId -> m_aOy3 SrcSpan
annotationsToComments :: forall m_aOzb. MonadFree AnnotationF m_aOzb => [AnnKeywordId] -> m_aOzb ()
withSortKey :: forall m_aOAf. MonadFree AnnotationF m_aOAf => [(SrcSpan, Annotated ())] -> m_aOAf ()
setContextLevel :: forall m_aOBj. MonadFree AnnotationF m_aOBj => Set AstContext -> Int -> Annotated () -> m_aOBj ()
unsetContext :: forall m_aOCt. MonadFree AnnotationF m_aOCt => AstContext -> Annotated () -> m_aOCt ()
ifInContext :: forall m_aODA. MonadFree AnnotationF m_aODA => Set AstContext -> Annotated () -> Annotated () -> m_aODA ()
withSortKeyContexts :: forall m_aOEK. MonadFree AnnotationF m_aOEK => ListContexts -> [(SrcSpan, Annotated ())] -> m_aOEK ()
tellContext :: forall m_aOFR. MonadFree AnnotationF m_aOFR => Set AstContext -> m_aOFR ()
markAnnBeforeAnn :: forall m_aOGV. MonadFree AnnotationF m_aOGV => AnnKeywordId -> AnnKeywordId -> m_aOGV ()
setContext :: Set AstContext -> Annotated () -> Annotated ()
setLayoutFlag :: Annotated () -> Annotated ()
setRigidFlag :: Annotated () -> Annotated ()
inContext :: Set AstContext -> Annotated () -> Annotated ()

-- | Main driver point for annotations.
withAST :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> Annotated () -> Annotated ()
mark :: AnnKeywordId -> Annotated ()
markOptional :: AnnKeywordId -> Annotated ()
markWithString :: AnnKeywordId -> String -> Annotated ()
markWithStringOptional :: AnnKeywordId -> String -> Annotated ()
markOffsetWithString :: AnnKeywordId -> Int -> String -> Annotated ()
markOffset :: AnnKeywordId -> Int -> Annotated ()
markOffsetOptional :: AnnKeywordId -> Int -> Annotated ()
markTrailingSemi :: Annotated ()
withLocated :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> (SrcSpan -> a -> Annotated ()) -> Annotated ()
markListIntercalateWithFun :: (t -> Annotated ()) -> [t] -> Annotated ()
markListIntercalateWithFunLevel :: (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevelCtx :: (t -> Annotated ()) -> Int -> AstContext -> [t] -> Annotated ()
markListWithContextsFunction :: ListContexts -> (t -> Annotated ()) -> [t] -> Annotated ()
withSortKeyContextsHelper :: Monad m => (Annotated () -> m ()) -> ListContexts -> [(SrcSpan, Annotated ())] -> m ()
applyListAnnotations :: [(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsContexts :: ListContexts -> [(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsLayout :: [(SrcSpan, Annotated ())] -> Annotated ()
listContexts :: ListContexts
listContexts' :: ListContexts
markAnnOpen :: SourceText -> String -> Annotated ()
markSourceText :: SourceText -> String -> Annotated ()
markExternalSourceText :: SrcSpan -> SourceText -> String -> Annotated ()
sourceTextToString :: SourceText -> String -> String
instance GHC.Base.Functor Language.Haskell.GHC.ExactPrint.AnnotateTypes.AnnotationF

module Language.Haskell.GHC.ExactPrint.Utils
ss2pos :: SrcSpan -> Pos
ss2posEnd :: SrcSpan -> Pos

-- | Apply the delta to the current position, taking into account the
--   current column offset if advancing to a new line
undelta :: Pos -> DeltaPos -> LayoutStartCol -> Pos

-- | Checks whether a SrcSpan has zero length.
isPointSrcSpan :: SrcSpan -> Bool

-- | Convert the start of the second Pos to be an offset from the
--   first. The assumption is the reference starts before the second
--   Pos
pos2delta :: Pos -> Pos -> DeltaPos

-- | Create a delta from the current position to the start of the given
--   SrcSpan.
ss2delta :: Pos -> SrcSpan -> DeltaPos

-- | 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)
--   
addDP :: DeltaPos -> DeltaPos -> DeltaPos
spanLength :: SrcSpan -> Int

-- | A good delta has no negative values.
isGoodDelta :: DeltaPos -> Bool
mkComment :: String -> SrcSpan -> Comment

-- | Makes a comment which originates from a specific keyword.
mkKWComment :: AnnKeywordId -> SrcSpan -> Comment

-- | Calculates the distance from the start of a string to the end of a
--   string.
dpFromString :: String -> DeltaPos
comment2dp :: (Comment, DeltaPos) -> (KeywordId, DeltaPos)
extractComments :: ApiAnns -> [Comment]
srcSpanStartLine :: SrcSpan -> Int
srcSpanEndLine :: SrcSpan -> Int
srcSpanStartColumn :: SrcSpan -> Int
srcSpanEndColumn :: SrcSpan -> Int
rdrName2String :: RdrName -> String
isSymbolRdrName :: RdrName -> Bool
tokComment :: Located AnnotationComment -> Comment
isListComp :: HsStmtContext name -> Bool
isGadt :: [LConDecl name] -> Bool
isExactName :: Data name => name -> Bool
getAnnotationEP :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> Anns -> Maybe Annotation

-- | The "true entry" is the distance from the last concrete element to the
--   start of the current element.
annTrueEntryDelta :: Annotation -> DeltaPos

-- | Take an annotation and a required "true entry" and calculate an
--   equivalent one relative to the last comment in the annPriorComments.
annCommentEntryDelta :: Annotation -> DeltaPos -> DeltaPos

-- | Return the DP of the first item that generates output, either a
--   comment or the entry DP
annLeadingCommentEntryDelta :: Annotation -> DeltaPos

-- | Given a list of items and a list of keys, returns a list of items
--   ordered by their position in the list of keys.
orderByKey :: [(SrcSpan, a)] -> [SrcSpan] -> [(SrcSpan, a)]

-- | Put the provided context elements into the existing set with fresh
--   level counts
setAcs :: Set AstContext -> AstContextSet -> AstContextSet

-- | Put the provided context elements into the existing set with given
--   level counts setAcsWithLevel :: Set.Set AstContext -> Int ->
--   AstContextSet -> AstContextSet setAcsWithLevel ctxt level (ACS a) =
--   ACS a' where upd s (k,v) = Map.insert k v s a' = foldl' upd a $ zip
--   (Set.toList ctxt) (repeat level)
setAcsWithLevel :: Ord a => Set a -> Int -> ACS' a -> ACS' a

-- | Remove the provided context element from the existing set unsetAcs ::
--   AstContext -> AstContextSet -> AstContextSet
unsetAcs :: Ord a => a -> ACS' a -> ACS' a

-- | Are any of the contexts currently active? inAcs :: Set.Set AstContext
--   -> AstContextSet -> Bool
inAcs :: Ord a => Set a -> ACS' a -> Bool

-- | propagate the ACS down a level, dropping all values which hit zero
--   pushAcs :: AstContextSet -> AstContextSet
pushAcs :: ACS' a -> ACS' a

-- | Sometimes we have to pass the context down unchanged. Bump each count
--   up by one so that it is unchanged after a pushAcs call.
--   bumpAcs :: AstContextSet -> AstContextSet
bumpAcs :: ACS' a -> ACS' a

-- | Provide a version of trace that comes at the end of the line, so it
--   can easily be commented out when debugging different things.
debug :: c -> String -> c

-- | Provide a version of trace for the Pretty module, which can be enabled
--   separately from debug and debugM
debugP :: String -> c -> c
debugM :: Monad m => String -> m ()
warn :: c -> String -> c

-- | Show a GHC.Outputable structure
showGhc :: Outputable a => a -> String

-- | Show a GHC AST with interleaved Annotation information.
showAnnData :: Data a => Anns -> Int -> a -> String
occAttributes :: OccName -> String
showSDoc_ :: SDoc -> String
showSDocDebug_ :: SDoc -> String
ghead :: String -> [a] -> a
glast :: String -> [a] -> a
gtail :: String -> [a] -> [a]
gfromJust :: String -> Maybe a -> a

-- | This module is currently under heavy development, and no promises are
--   made about API stability. Use with care.
--   
--   We welcome any feedback / contributions on this, as it is the main
--   point of the library.
module Language.Haskell.GHC.ExactPrint.Transform

-- | Monad type for updating the AST and managing the annotations at the
--   same time. The W state is used to generate logging information if
--   required.
type Transform = TransformT Identity

-- | Monad transformer version of Transform monad
newtype TransformT m a
TransformT :: RWST () [String] (Anns, Int) m a -> TransformT m a
[unTransformT] :: TransformT m a -> RWST () [String] (Anns, Int) m a

-- | Change inner monad of TransformT.
hoistTransform :: (forall x. m x -> n x) -> TransformT m a -> TransformT n a

-- | Run a transformation in the Transform monad, returning the
--   updated annotations and any logging generated via logTr
runTransform :: Anns -> Transform a -> (a, (Anns, Int), [String])
runTransformT :: Anns -> TransformT m a -> m (a, (Anns, Int), [String])

-- | Run a transformation in the Transform monad, returning the
--   updated annotations and any logging generated via logTr,
--   allocating any new SrcSpans from the provided initial value.
runTransformFrom :: Int -> Anns -> Transform a -> (a, (Anns, Int), [String])

-- | Run a monad transformer stack for the TransformT monad
--   transformer
runTransformFromT :: Int -> Anns -> TransformT m a -> m (a, (Anns, Int), [String])

-- | Log a string to the output of the Monad
logTr :: Monad m => String -> TransformT m ()

-- | Log a representation of the given AST with annotations to the output
--   of the Monad
logDataWithAnnsTr :: Monad m => Data a => String -> a -> TransformT m ()

-- | Access the Anns being modified in this transformation
getAnnsT :: Monad m => TransformT m Anns

-- | Replace the Anns after any changes
putAnnsT :: Monad m => Anns -> TransformT m ()

-- | Change the stored Anns
modifyAnnsT :: Monad m => (Anns -> Anns) -> TransformT m ()

-- | Once we have Anns, a SrcSpan is used purely as part of
--   an AnnKey to index into the Anns. If we need to add new
--   elements to the AST, they need their own SrcSpan for this.
uniqueSrcSpanT :: Monad m => TransformT m SrcSpan

-- | Make a copy of an AST element, replacing the existing SrcSpans with
--   new ones, and duplicating the matching annotations.
cloneT :: (Data a, Monad m) => a -> TransformT m (a, [(SrcSpan, SrcSpan)])

-- | Slightly more general form of cloneT
graftT :: (Data a, Monad m) => Anns -> a -> TransformT m a

-- | Transform monad version of getEntryDP
getEntryDPT :: (Constraints a, Monad m) => a -> TransformT m DeltaPos

-- | Transform monad version of getEntryDP
setEntryDPT :: (Constraints a, Monad m) => a -> DeltaPos -> TransformT m ()

-- | Transform monad version of transferEntryDP
transferEntryDPT :: (Data a, Data b, Monad m) => Located a -> Located b -> TransformT m ()

-- | Transform monad version of setPrecedingLinesDecl
setPrecedingLinesDeclT :: Monad m => LHsDecl GhcPs -> Int -> Int -> TransformT m ()

-- | Transform monad version of setPrecedingLines
setPrecedingLinesT :: (Data a, Monad m) => Located a -> Int -> Int -> TransformT m ()

-- | Create a simple Annotation without comments, and attach it to
--   the first parameter.
addSimpleAnnT :: (Constraints a, Monad m) => a -> DeltaPos -> [(KeywordId, DeltaPos)] -> TransformT m ()

-- | Add a trailing comma annotation, unless there is already one
addTrailingCommaT :: (Data a, Monad m) => Located a -> TransformT m ()

-- | Remove a trailing comma annotation, if there is one one
removeTrailingCommaT :: (Data a, Monad m) => Located a -> TransformT m ()

-- | Used to integrate a Transform into other Monad stacks
class (Monad m) => HasTransform m
liftT :: HasTransform m => Transform a -> m a

-- | Provide a means to get and process the immediate child declartions of
--   a given AST element.
class (Data t) => HasDecls t

-- | Return the HsDecls that are directly enclosed in the given
--   syntax phrase. They are always returned in the wrapped HsDecl
--   form, even if orginating in local decls. This is safe, as annotations
--   never attach to the wrapper, only to the wrapped item.
hsDecls :: (HasDecls t, Monad m) => t -> TransformT m [LHsDecl GhcPs]

-- | Replace the directly enclosed decl list by the given decl list. Runs
--   in the Transform monad to be able to update list order
--   annotations, and rebalance comments and other layout changes as
--   needed.
--   
--   For example, a call on replaceDecls for a wrapped FunBind
--   having no where clause will convert
--   
--   
--   -- |This is a function
--   foo = x -- comment1
--   
--   
--   in to
--   
--   
--   -- |This is a function
--   foo = x -- comment1
--     where
--       nn = 2
--   
replaceDecls :: (HasDecls t, Monad m) => t -> [LHsDecl GhcPs] -> TransformT m t

-- | Do a transformation on an AST fragment by providing a function to
--   process the general case and one specific for a LHsBind. This
--   is required because a FunBind may have multiple Match
--   items, so we cannot gurantee that replaceDecls after
--   hsDecls is idempotent.
hasDeclsSybTransform :: (Data t2, Monad m) => (forall t. HasDecls t => t -> m t) -> (LHsBind GhcPs -> m (LHsBind GhcPs)) -> t2 -> m t2

-- | A FunBind wraps up one or more Match items.
--   hsDecls cannot return anything for these as there is not
--   meaningful replaceDecls for it. This function provides a
--   version of hsDecls that returns the FunBind decls too,
--   where they are needed for analysis only.
hsDeclsGeneric :: (Data t, Monad m) => t -> TransformT m [LHsDecl GhcPs]

-- | Extract the immediate declarations for a PatBind. This cannot
--   be a member of HasDecls because a FunBind is not
--   idempotent for hsDecls / replaceDecls.
--   hsDeclsPatBind / replaceDeclsPatBind is idempotent.
hsDeclsPatBind :: Monad m => LHsBind GhcPs -> TransformT m [LHsDecl GhcPs]

-- | Extract the immediate declarations for a PatBind wrapped in a
--   ValD. This cannot be a member of HasDecls because a
--   FunBind is not idempotent for hsDecls /
--   replaceDecls. hsDeclsPatBindD /
--   replaceDeclsPatBindD is idempotent.
hsDeclsPatBindD :: Monad m => LHsDecl GhcPs -> TransformT m [LHsDecl GhcPs]

-- | Replace the immediate declarations for a PatBind. This cannot
--   be a member of HasDecls because a FunBind is not
--   idempotent for hsDecls / replaceDecls.
--   hsDeclsPatBind / replaceDeclsPatBind is idempotent.
replaceDeclsPatBind :: Monad m => LHsBind GhcPs -> [LHsDecl GhcPs] -> TransformT m (LHsBind GhcPs)

-- | Replace the immediate declarations for a PatBind wrapped in a
--   ValD. This cannot be a member of HasDecls because a
--   FunBind is not idempotent for hsDecls /
--   replaceDecls. hsDeclsPatBindD /
--   replaceDeclsPatBindD is idempotent.
replaceDeclsPatBindD :: Monad m => LHsDecl GhcPs -> [LHsDecl GhcPs] -> TransformT m (LHsDecl GhcPs)

-- | Apply a transformation to the decls contained in t
modifyDeclsT :: (HasDecls t, HasTransform m) => ([LHsDecl GhcPs] -> m [LHsDecl GhcPs]) -> t -> m t

-- | Modify a LHsBind wrapped in a ValD. For a PatBind
--   the declarations are extracted and returned after modification. For a
--   FunBind the supplied SrcSpan is used to identify the
--   specific Match to be transformed, for when there are multiple
--   of them.
modifyValD :: forall m t. HasTransform m => SrcSpan -> Decl -> (Match -> [Decl] -> m ([Decl], Maybe t)) -> m (Decl, Maybe t)

-- | Utility function for extracting decls from HsLocalBinds. Use
--   with care, as this does not necessarily return the declarations in
--   order, the ordering should be done by the calling function from the
--   HsLocalBinds context in the AST.
hsDeclsValBinds :: Monad m => HsLocalBinds GhcPs -> TransformT m [LHsDecl GhcPs]

-- | Utility function for returning decls to HsLocalBinds. Use with
--   care, as this does not manage the declaration order, the ordering
--   should be done by the calling function from the HsLocalBinds
--   context in the AST.
replaceDeclsValbinds :: Monad m => HsLocalBinds GhcPs -> [LHsDecl GhcPs] -> TransformT m (HsLocalBinds GhcPs)

-- | Insert a declaration at the beginning or end of the subdecls of the
--   given AST item
insertAtStart :: HasDecls (Located ast) => Located ast -> LHsDecl GhcPs -> Transform (Located ast)

-- | Insert a declaration at the beginning or end of the subdecls of the
--   given AST item
insertAtEnd :: HasDecls (Located ast) => Located ast -> LHsDecl GhcPs -> Transform (Located ast)

-- | Insert a declaration at a specific location in the subdecls of the
--   given AST item
insertAfter :: HasDecls (Located ast) => Located old -> Located ast -> LHsDecl GhcPs -> Transform (Located ast)

-- | Insert a declaration at a specific location in the subdecls of the
--   given AST item
insertBefore :: HasDecls (Located ast) => Located old -> Located ast -> LHsDecl GhcPs -> Transform (Located ast)

-- | The relatavise phase puts all comments appearing between the end of
--   one AST item and the beginning of the next as annPriorComments
--   for the second one. This function takes two adjacent AST items and
--   moves any annPriorComments from the second one to the
--   annFollowingComments of the first if they belong to it instead.
--   This is typically required before deleting or duplicating either of
--   the AST elements.
balanceComments :: (Data a, Data b, Monad m) => Located a -> Located b -> TransformT m ()

-- | After moving an AST element, make sure any comments that may belong
--   with the following element in fact do. Of necessity this is a
--   heuristic process, to be tuned later. Possibly a variant should be
--   provided with a passed-in decision function.
balanceTrailingComments :: Monad m => (Data a, Data b) => Located a -> Located b -> TransformT m [(Comment, DeltaPos)]

-- | Move any annFollowingComments values from the Annotation
--   associated to the first parameter to that of the second.
moveTrailingComments :: (Data a, Data b) => Located a -> Located b -> Transform ()

-- | If a list has been re-ordered or had items added, capture the new
--   order in the appropriate annSortKey attached to the
--   Annotation for the first parameter.
captureOrder :: Data a => Located a -> [Located b] -> Anns -> Anns

-- | If a list has been re-ordered or had items added, capture the new
--   order in the appropriate annSortKey item of the supplied
--   AnnKey
captureOrderAnnKey :: AnnKey -> [Located b] -> Anns -> Anns

-- | Test whether a given SrcSpan was generated by
--   uniqueSrcSpanT
isUniqueSrcSpan :: SrcSpan -> Bool

-- | Left bias pair union
mergeAnns :: Anns -> Anns -> Anns

-- | Combine a list of annotations
mergeAnnList :: [Anns] -> Anns

-- | Unwrap a HsDecl and call setPrecedingLines on it ++AZ++ TODO: get rid
--   of this, it is a synonym only
setPrecedingLinesDecl :: LHsDecl GhcPs -> Int -> Int -> Anns -> Anns

-- | Adjust the entry annotations to provide an n line preceding
--   gap
setPrecedingLines :: Data a => Located a -> Int -> Int -> Anns -> Anns

-- | Return the true entry DeltaPos from the annotation for a given
--   AST element. This is the DeltaPos ignoring any comments.
getEntryDP :: Constraints a => Anns -> a -> DeltaPos

-- | Set the true entry DeltaPos from the annotation for a given AST
--   element. This is the DeltaPos ignoring any comments.
setEntryDP :: Constraints a => a -> DeltaPos -> Anns -> Anns

-- | Take the annEntryDelta associated with the first item and associate it
--   with the second. Also transfer any comments occuring before it.
transferEntryDP :: (Data a, Data b) => Located a -> Located b -> Anns -> Anns
addTrailingComma :: Data a => Located a -> DeltaPos -> Anns -> Anns

-- | Convert a LSig into a LHsDecl
wrapSig :: LSig GhcPs -> LHsDecl GhcPs

-- | Convert a LHsBind into a LHsDecl
wrapDecl :: LHsBind GhcPs -> LHsDecl GhcPs

-- | 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
decl2Sig :: LHsDecl name -> [LSig name]

-- | 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
decl2Bind :: LHsDecl name -> [LHsBind name]
instance Control.Monad.Trans.Class.MonadTrans Language.Haskell.GHC.ExactPrint.Transform.TransformT
instance GHC.Base.Monad m => Control.Monad.State.Class.MonadState (Language.Haskell.GHC.ExactPrint.Types.Anns, GHC.Types.Int) (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Monad m => Control.Monad.Writer.Class.MonadWriter [GHC.Base.String] (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader () (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance GHC.Base.Monad m => Language.Haskell.GHC.ExactPrint.Transform.HasTransform (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)
instance Language.Haskell.GHC.ExactPrint.Transform.HasDecls GHC.ParsedSource
instance Language.Haskell.GHC.ExactPrint.Transform.HasDecls (HsExpr.LMatch Language.Haskell.GHC.ExactPrint.Types.GhcPs (HsExpr.LHsExpr Language.Haskell.GHC.ExactPrint.Types.GhcPs))
instance Language.Haskell.GHC.ExactPrint.Transform.HasDecls (HsExpr.LHsExpr Language.Haskell.GHC.ExactPrint.Types.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Transform.HasDecls (HsExpr.LStmt Language.Haskell.GHC.ExactPrint.Types.GhcPs (HsExpr.LHsExpr Language.Haskell.GHC.ExactPrint.Types.GhcPs))
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Language.Haskell.GHC.ExactPrint.Transform.TransformT m)

-- | This module provides support for CPP, interpreter directives and line
--   pragmas.
module Language.Haskell.GHC.ExactPrint.Preprocess

-- | Remove GHC style line pragams ({--}) and convert them into
--   comments.
stripLinePragmas :: String -> (String, [Comment])

-- | Replacement for original getRichTokenStream which will return
--   the tokens for a file processed by CPP. See bug
--   http://ghc.haskell.org/trac/ghc/ticket/8265
getCppTokensAsComments :: GhcMonad m => CppOptions -> FilePath -> m [Comment]
getPreprocessedSrcDirect :: GhcMonad m => CppOptions -> FilePath -> m (String, DynFlags)
readFileGhc :: FilePath -> IO String
data CppOptions
CppOptions :: [String] -> [FilePath] -> [FilePath] -> CppOptions

-- | CPP #define macros
[cppDefine] :: CppOptions -> [String]

-- | CPP Includes directory
[cppInclude] :: CppOptions -> [FilePath]

-- | CPP pre-include file
[cppFile] :: CppOptions -> [FilePath]
defaultCppOptions :: CppOptions

-- | annotate is a function which given a GHC AST fragment,
--   constructs a syntax tree which indicates which annotations belong to
--   each specific part of the fragment.
--   
--   Delta and Print provide two interpreters for this
--   structure. You should probably use those unless you know what you're
--   doing!
--   
--   The functor AnnotationF has a number of constructors which
--   correspond to different sitations which annotations can arise. It is
--   hoped that in future versions of GHC these can be simplified by making
--   suitable modifications to the AST.
module Language.Haskell.GHC.ExactPrint.Annotater

-- | Construct a syntax tree which represent which KeywordIds must appear
--   where.
annotate :: (Annotate ast, Data (SrcSpanLess ast), HasSrcSpan ast) => ast -> Annotated ()

-- | 
--   
- MarkPrim The main constructor. Marks that a specific
--   AnnKeywordId could appear with an optional String which is used when
--   printing.
--   
- MarkPPOptional Used to flag elements, such as
--   optional braces, that are not used in the pretty printer. This
--   functions identically to MarkPrim for the other
--   interpreters.
--   
- MarkEOF Special constructor which marks the end of
--   file marker.
--   
- MarkExternal TODO
--   
- MarkOutside A AnnKeywordId which is
--   precisely located but not inside the current context. This is usually
--   used to reassociated located RdrName which are more naturally
--   associated with their parent than in their own annotation.
--   
- MarkInside The dual of MarkOutside. If we wish to
--   mark a non-separating comma or semi-colon then we must use this
--   constructor.
--   
- MarkMany Some syntax elements allow an arbritary
--   number of puncuation marks without reflection in the AST. This
--   construction greedily takes all of the specified
--   AnnKeywordId.
--   
- MarkOffsetPrim Some syntax elements have repeated
--   AnnKeywordId which are seperated by different
--   AnnKeywordId. Thus using MarkMany is unsuitable and instead
--   we provide an index to specify which specific instance to choose each
--   time.
--   
- WithAST TODO
--   
- CountAnns Sometimes the AST does not reflect the
--   concrete source code and the only way to tell what the concrete source
--   was is to count a certain kind of AnnKeywordId.
--   
- WithSortKey There are many places where the
--   syntactic ordering of elements is thrown away by the AST. This
--   constructor captures the original ordering and reflects any changes in
--   ordered as specified by the annSortKey field in
--   Annotation.
--   
- SetLayoutFlag It is important to know precisely
--   where layout rules apply. This constructor wraps a computation to
--   indicate that LayoutRules apply to the corresponding construct.
--   
- StoreOriginalSrcSpan TODO
--   
- GetSrcSpanFromKw TODO
--   
- StoreString TODO
--   
- AnnotationsToComments Used when the AST is
--   sufficiently vague that there is no other option but to convert a
--   fragment of source code into a comment. This means it is impossible to
--   edit such a fragment but means that processing files with such
--   fragments is still possible.
--   
data AnnotationF next
[MarkPrim] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkPPOptional] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkEOF] :: next -> AnnotationF next
[MarkExternal] :: SrcSpan -> AnnKeywordId -> String -> next -> AnnotationF next
[MarkInstead] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkOutside] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkInside] :: AnnKeywordId -> next -> AnnotationF next
[MarkMany] :: AnnKeywordId -> next -> AnnotationF next
[MarkManyOptional] :: AnnKeywordId -> next -> AnnotationF next
[MarkOffsetPrim] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[MarkOffsetPrimOptional] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[WithAST] :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> Annotated b -> next -> AnnotationF next
[CountAnns] :: AnnKeywordId -> (Int -> next) -> AnnotationF next
[WithSortKey] :: [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[SetLayoutFlag] :: Rigidity -> Annotated () -> next -> AnnotationF next
[MarkAnnBeforeAnn] :: AnnKeywordId -> AnnKeywordId -> next -> AnnotationF next
[StoreOriginalSrcSpan] :: SrcSpan -> AnnKey -> (AnnKey -> next) -> AnnotationF next
[GetSrcSpanForKw] :: SrcSpan -> AnnKeywordId -> (SrcSpan -> next) -> AnnotationF next
[AnnotationsToComments] :: [AnnKeywordId] -> next -> AnnotationF next
[SetContextLevel] :: Set AstContext -> Int -> Annotated () -> next -> AnnotationF next
[UnsetContext] :: AstContext -> Annotated () -> next -> AnnotationF next
[IfInContext] :: Set AstContext -> Annotated () -> Annotated () -> next -> AnnotationF next
[WithSortKeyContexts] :: ListContexts -> [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[TellContext] :: Set AstContext -> next -> AnnotationF next
type Annotated = FreeT AnnotationF Identity
class Data ast => Annotate ast
markAST :: Annotate ast => SrcSpan -> ast -> Annotated ()
withSortKeyContextsHelper :: Monad m => (Annotated () -> m ()) -> ListContexts -> [(SrcSpan, Annotated ())] -> m ()
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Annotater.WildCardAnon
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Annotater.WildCardAnon
instance Data.Data.Data Language.Haskell.GHC.ExactPrint.Annotater.ResTyGADTHook
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate Language.Haskell.GHC.ExactPrint.Annotater.WildCardAnon
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.ConDecl HsExtension.GhcPs)
instance Outputable.Outputable Language.Haskell.GHC.ExactPrint.Annotater.ResTyGADTHook
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate Language.Haskell.GHC.ExactPrint.Annotater.ResTyGADTHook
instance (Data.Data.Data ast, Language.Haskell.GHC.ExactPrint.Annotater.Annotate ast) => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (SrcLoc.Located ast)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsSyn.HsModule HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate BasicTypes.WarningTxt
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate BasicTypes.StringLiteral
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (BasicTypes.SourceText, FastString.FastString)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsImpExp.LIE HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsImpExp.IE HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsImpExp.IEWrappedName RdrName.RdrName)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate RdrName.RdrName
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsImpExp.ImportDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate Module.ModuleName
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.HsDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.RoleAnnotDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (GHC.Maybe.Maybe CoAxiom.Role)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.SpliceDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.RuleDecls HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.RuleDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.RuleBndr HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.AnnDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.WarnDecls HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.WarnDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate FastString.FastString
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.ForeignDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate ForeignCall.CExportSpec
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate ForeignCall.CCallConv
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate ForeignCall.Safety
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.DerivDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.DerivStrategy HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.DefaultDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.InstDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate BasicTypes.OverlapMode
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.ClsInstDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.TyFamInstDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.DataFamInstDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsBinds.HsBind HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsBinds.IPBind HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate HsTypes.HsIPName
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate body => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.Match HsExtension.GhcPs (SrcLoc.Located body))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate body => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.GRHS HsExtension.GhcPs (SrcLoc.Located body))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsBinds.Sig HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsTypes.LHsSigType HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate name => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (BooleanFormula.BooleanFormula (SrcLoc.Located name))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.HsTyVarBndr HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.HsType HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.HsSplice HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.ConDeclField HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.FieldOcc HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate HsDoc.HsDocString
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsPat.Pat HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsTypes.LConDeclField HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsLit.HsOverLit HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate arg => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.HsImplicitBndrs HsExtension.GhcPs (SrcLoc.Located arg))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate body => Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.Stmt HsExtension.GhcPs (SrcLoc.Located body))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.ParStmtBlock HsExtension.GhcPs HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsBinds.HsLocalBinds HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate body => Language.Haskell.GHC.ExactPrint.Annotater.Annotate [SrcLoc.Located (HsExpr.Match HsExtension.GhcPs (SrcLoc.Located body))]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.HsExpr HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsLit.HsLit HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsPat.HsRecUpdField HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsTypes.AmbiguousFieldOcc HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsExpr.ExprLStmt HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.HsTupArg HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.HsCmdTop HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsExpr.HsCmd HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [SrcLoc.Located (HsExpr.StmtLR HsExtension.GhcPs HsExtension.GhcPs (HsExpr.LHsCmd HsExtension.GhcPs))]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.TyClDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsDecls.LHsDerivingClause HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.HsDerivingClause HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.FamilyDecl HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.FamilyResultSig HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.InjectivityAnn HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.TyFamInstEqn HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsDecls.TyFamDefltEqn HsExtension.GhcPs)
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate HsDecls.DocDecl
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate [HsTypes.LHsType HsExtension.GhcPs]
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsPat.HsRecField HsExtension.GhcPs (HsPat.LPat HsExtension.GhcPs))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (HsPat.HsRecField HsExtension.GhcPs (HsExpr.LHsExpr HsExtension.GhcPs))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate (Class.FunDep (SrcLoc.Located RdrName.RdrName))
instance Language.Haskell.GHC.ExactPrint.Annotater.Annotate ForeignCall.CType

-- | annotate is a function which given a GHC AST fragment,
--   constructs a syntax tree which indicates which annotations belong to
--   each specific part of the fragment.
--   
--   Delta and Print provide two interpreters for this
--   structure. You should probably use those unless you know what you're
--   doing!
--   
--   The functor AnnotationF has a number of constructors which
--   correspond to different sitations which annotations can arise. It is
--   hoped that in future versions of GHC these can be simplified by making
--   suitable modifications to the AST.
module Language.Haskell.GHC.ExactPrint.Annotate

-- | Construct a syntax tree which represent which KeywordIds must appear
--   where.
annotate :: (Annotate ast, Data (SrcSpanLess ast), HasSrcSpan ast) => ast -> Annotated ()

-- | 
--   
- MarkPrim The main constructor. Marks that a specific
--   AnnKeywordId could appear with an optional String which is used when
--   printing.
--   
- MarkPPOptional Used to flag elements, such as
--   optional braces, that are not used in the pretty printer. This
--   functions identically to MarkPrim for the other
--   interpreters.
--   
- MarkEOF Special constructor which marks the end of
--   file marker.
--   
- MarkExternal TODO
--   
- MarkOutside A AnnKeywordId which is
--   precisely located but not inside the current context. This is usually
--   used to reassociated located RdrName which are more naturally
--   associated with their parent than in their own annotation.
--   
- MarkInside The dual of MarkOutside. If we wish to
--   mark a non-separating comma or semi-colon then we must use this
--   constructor.
--   
- MarkMany Some syntax elements allow an arbritary
--   number of puncuation marks without reflection in the AST. This
--   construction greedily takes all of the specified
--   AnnKeywordId.
--   
- MarkOffsetPrim Some syntax elements have repeated
--   AnnKeywordId which are seperated by different
--   AnnKeywordId. Thus using MarkMany is unsuitable and instead
--   we provide an index to specify which specific instance to choose each
--   time.
--   
- WithAST TODO
--   
- CountAnns Sometimes the AST does not reflect the
--   concrete source code and the only way to tell what the concrete source
--   was is to count a certain kind of AnnKeywordId.
--   
- WithSortKey There are many places where the
--   syntactic ordering of elements is thrown away by the AST. This
--   constructor captures the original ordering and reflects any changes in
--   ordered as specified by the annSortKey field in
--   Annotation.
--   
- SetLayoutFlag It is important to know precisely
--   where layout rules apply. This constructor wraps a computation to
--   indicate that LayoutRules apply to the corresponding construct.
--   
- StoreOriginalSrcSpan TODO
--   
- GetSrcSpanFromKw TODO
--   
- StoreString TODO
--   
- AnnotationsToComments Used when the AST is
--   sufficiently vague that there is no other option but to convert a
--   fragment of source code into a comment. This means it is impossible to
--   edit such a fragment but means that processing files with such
--   fragments is still possible.
--   
data AnnotationF next
[MarkPrim] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkPPOptional] :: AnnKeywordId -> Maybe String -> next -> AnnotationF next
[MarkEOF] :: next -> AnnotationF next
[MarkExternal] :: SrcSpan -> AnnKeywordId -> String -> next -> AnnotationF next
[MarkInstead] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkOutside] :: AnnKeywordId -> KeywordId -> next -> AnnotationF next
[MarkInside] :: AnnKeywordId -> next -> AnnotationF next
[MarkMany] :: AnnKeywordId -> next -> AnnotationF next
[MarkManyOptional] :: AnnKeywordId -> next -> AnnotationF next
[MarkOffsetPrim] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[MarkOffsetPrimOptional] :: AnnKeywordId -> Int -> Maybe String -> next -> AnnotationF next
[WithAST] :: (Data a, Data (SrcSpanLess a), HasSrcSpan a) => a -> Annotated b -> next -> AnnotationF next
[CountAnns] :: AnnKeywordId -> (Int -> next) -> AnnotationF next
[WithSortKey] :: [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[SetLayoutFlag] :: Rigidity -> Annotated () -> next -> AnnotationF next
[MarkAnnBeforeAnn] :: AnnKeywordId -> AnnKeywordId -> next -> AnnotationF next
[StoreOriginalSrcSpan] :: SrcSpan -> AnnKey -> (AnnKey -> next) -> AnnotationF next
[GetSrcSpanForKw] :: SrcSpan -> AnnKeywordId -> (SrcSpan -> next) -> AnnotationF next
[AnnotationsToComments] :: [AnnKeywordId] -> next -> AnnotationF next
[SetContextLevel] :: Set AstContext -> Int -> Annotated () -> next -> AnnotationF next
[UnsetContext] :: AstContext -> Annotated () -> next -> AnnotationF next
[IfInContext] :: Set AstContext -> Annotated () -> Annotated () -> next -> AnnotationF next
[WithSortKeyContexts] :: ListContexts -> [(SrcSpan, Annotated ())] -> next -> AnnotationF next
[TellContext] :: Set AstContext -> next -> AnnotationF next
type Annotated = FreeT AnnotationF Identity
class Data ast => Annotate ast
markAST :: Annotate ast => SrcSpan -> ast -> Annotated ()
withSortKeyContextsHelper :: Monad m => (Annotated () -> m ()) -> ListContexts -> [(SrcSpan, Annotated ())] -> m ()

-- | This module inverts the process performed by Delta. Given
--   Anns and a corresponding AST we produce a source file based on
--   this information.
module Language.Haskell.GHC.ExactPrint.Print

-- | Print an AST with a map of potential modified Anns. The usual
--   way to generate such a map is by using one of the parsers in
--   Language.Haskell.GHC.ExactPrint.Parsers.
exactPrint :: Annotate ast => Located ast -> Anns -> String

-- | The additional option to specify the rigidity and printing
--   configuration.
exactPrintWithOptions :: (Annotate ast, Monoid b, Monad m) => PrintOptions m b -> Located ast -> Anns -> m b
data PrintOptions m a

-- | Options which can be used to print as a normal String.
stringOptions :: PrintOptions Identity String

-- | Helper to create a PrintOptions
printOptions :: (forall ast. (Data ast, HasSrcSpan ast) => ast -> a -> m a) -> (String -> m a) -> (String -> m a) -> Rigidity -> PrintOptions m a
instance GHC.Base.Monoid w => GHC.Base.Semigroup (Language.Haskell.GHC.ExactPrint.Print.EPWriter w)
instance GHC.Base.Monoid w => GHC.Base.Monoid (Language.Haskell.GHC.ExactPrint.Print.EPWriter w)

-- | This module adds default annotations to an AST fragment that does not
--   have them, to be able to exactprint it in a way that preserves the
--   orginal AST when re-parsed.
module Language.Haskell.GHC.ExactPrint.Pretty

-- | Add any missing annotations so that the full AST element will
--   exactprint properly when done.
addAnnotationsForPretty :: Annotate a => [Comment] -> Located a -> Anns -> Anns
instance GHC.Show.Show Language.Haskell.GHC.ExactPrint.Pretty.PrettyOptions
instance GHC.Base.Semigroup Language.Haskell.GHC.ExactPrint.Pretty.PrettyWriter
instance GHC.Base.Monoid Language.Haskell.GHC.ExactPrint.Pretty.PrettyWriter

-- | This module converts ApiAnns into Anns by traversing a
--   structure created by the Annotate module.
--   
--   
Structure of an Annotation
--   
--   As a rule of thumb, every located element in the GHC AST will have a
--   corresponding entry in Anns. An Annotation contains 6
--   fields which can be modifed to change how the AST is printed.
--   
--   
Layout Calculation
--   
--   In order to properly place syntax nodes and comments properly after
--   refactoring them (in such a way that the indentation level changes),
--   their position (encoded in the addEntryDelta field) is not
--   expressed as absolute but relative to their context. As further
--   motivation, consider the simple let-into-where-block refactoring,
--   from:
--   
--   
--   foo = do
--     let bar = do
--           x
--           -- comment
--           y
--     bar
--   
--   
--   to
--   
--   
--   foo = do
--     bar
--    where
--     bar = do
--       x
--       -- comment
--       y
--   
--   
--   Notice how the column of x, y and the comment change
--   due to this refactoring but certain relative positions (e.g. the
--   comment starting at the same column as x) remain unchanged.
--   
--   Now, what does "context" mean exactly? Here we reference the
--   "indentation level" as used in the haskell report (see chapter 2.7:
--   https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-210002.7):
--   addEntryDelta is mostly relative to the current (inner-most)
--   indentation level. But in order to get better results, for the purpose
--   of defining relative positions a the offside-rule is modified
--   slightly: Normally it fires (only) at the first elements after
--   whereletdo/of, introducing a new indentation level. In
--   addition, the rule here fires also at the "let" keyword (when
--   it is part of a "let-in" construct) and at the "if"
--   keyword.
--   
--   The effect of this additional applications of the offside-rule is that
--   any elements (more or less directly) following the "let"
--   ("if"") keyword have a position relative to the
--   "let" ("if") keyword position, even when the regular
--   offside-rule does apply not yet/not anymore. This affects two concrete
--   things: Comments directly following "let"/"if", and
--   the respective follow-up keywords: "in" or
--   "then"/"else".
--   
--   Due to this additional indentation level, it is possible to
--   observe/obtain negative delta-positions; consider:
--   
--   
--   foo = let x = 1
--     in x
--   
--   
--   Here, the in keyword has an annEntryDelta of DP
--   (1, -4) as it appears one line below the previous elements and 4
--   columns left relative to the start of the let keyword.
--   
--   In general, the element that defines such an indentation level (i.e.
--   the first element after a whereletdo/of) will have an
--   annEntryDelta relative to the previous inner-most indentation
--   level; in other words: a new indentation level becomes relevant only
--   after the construct introducing the element received its
--   annEntryDelta position. (Otherwise these elements always would
--   have a zero horizontal position - relative to itself.)
--   
--   (This affects comments, too: A comment preceding the first element of
--   a layout block will have a position relative to the outer block, not
--   of the newly introduced layout block.)
--   
--   For example, in the following expression the statement corresponding
--   to baz will be given a annEntryDelta of DP (1,
--   2) as it appears 1 line and 2 columns after the do
--   keyword. On the other hand, bar will be given a
--   annEntryDelta of DP (1,0) as it appears 1 line further
--   than baz but in the same column as the start of the layout
--   block.
--   
--   
--   foo = do
--     baz
--     bar
--   
--   
--   A useful way to think of these rules is that the DeltaPos is
--   relative to the further left an expression could have been placed. In
--   the previous example, we could have placed baz anywhere on
--   the line as its position determines where the other statements must
--   be. bar could have not been placed any further left without
--   resulting in a syntax error which is why the relative column is 0.
--   
--   
annTrueEntryDelta
--   
--   A very useful function is annTrueEntryDelta which calculates
--   the offset from the last syntactic element (ignoring comments). This
--   is different to annEntryDelta which does not ignore comments.
module Language.Haskell.GHC.ExactPrint.Delta

-- | Transform concrete annotations into relative annotations which are
--   more useful when transforming an AST.
relativiseApiAnns :: (Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) => ast -> ApiAnns -> Anns

-- | Exactly the same as relativiseApiAnns but with the possibilty
--   to inject comments. This is typically used if the source has been
--   preprocessed by e.g. CPP, and the parts stripped out of the original
--   source are re-added as comments so they are not lost for round
--   tripping.
relativiseApiAnnsWithComments :: (Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) => [Comment] -> ast -> ApiAnns -> Anns
relativiseApiAnnsWithOptions :: (Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) => DeltaOptions -> [Comment] -> ast -> ApiAnns -> Anns
data DeltaOptions
deltaOptions :: Rigidity -> DeltaOptions
normalLayout :: DeltaOptions
instance GHC.Base.Semigroup Language.Haskell.GHC.ExactPrint.Delta.DeltaWriter
instance GHC.Base.Monoid Language.Haskell.GHC.ExactPrint.Delta.DeltaWriter

-- | This module rexposes wrapped parsers from the GHC API. Along with
--   returning the parse result, the corresponding annotations are also
--   returned such that it is then easy to modify the annotations and print
--   the result.
module Language.Haskell.GHC.ExactPrint.Parsers
type Parser a = DynFlags -> FilePath -> String -> Either (SrcSpan, String) (Anns, a)

-- | Provides a safe way to consume a properly initialised set of
--   DynFlags.
--   
--   
--   myParser fname expr = withDynFlags (\d -> parseExpr d fname expr)
--   
withDynFlags :: (DynFlags -> a) -> IO a
data CppOptions
CppOptions :: [String] -> [FilePath] -> [FilePath] -> CppOptions

-- | CPP #define macros
[cppDefine] :: CppOptions -> [String]

-- | CPP Includes directory
[cppInclude] :: CppOptions -> [FilePath]

-- | CPP pre-include file
[cppFile] :: CppOptions -> [FilePath]
defaultCppOptions :: CppOptions

-- | This entry point will also work out which language extensions are
--   required and perform CPP processing if necessary.
--   
--   
--   parseModule = parseModuleWithCpp defaultCppOptions
--   
--   
--   Note: ParsedSource is a synonym for Located
--   (HsModule GhcPs)
parseModule :: FilePath -> IO (Either (SrcSpan, String) (Anns, ParsedSource))

-- | This entry point will work out which language extensions are required
--   but will _not_ perform CPP processing. In contrast to
--   parseModoule the input source is read from the provided
--   string; the FilePath parameter solely exists to provide a name
--   in source location annotations.
parseModuleFromString :: FilePath -> String -> IO (Either (SrcSpan, String) (Anns, ParsedSource))
parseModuleWithOptions :: DeltaOptions -> FilePath -> IO (Either (SrcSpan, String) (Anns, ParsedSource))

-- | Parse a module with specific instructions for the C pre-processor.
parseModuleWithCpp :: CppOptions -> DeltaOptions -> FilePath -> IO (Either (SrcSpan, String) (Anns, ParsedSource))
parseExpr :: Parser (LHsExpr GhcPs)
parseImport :: Parser (LImportDecl GhcPs)
parseType :: Parser (LHsType GhcPs)
parseDecl :: Parser (LHsDecl GhcPs)
parsePattern :: Parser (LPat GhcPs)
parseStmt :: Parser (ExprLStmt GhcPs)

-- | Wrapper function which returns Annotations along with the parsed
--   element.
parseWith :: (Data (SrcSpanLess w), Annotate w, HasSrcSpan w) => DynFlags -> FilePath -> P w -> String -> Either (SrcSpan, String) (Anns, w)

-- | Internal function. Default runner of GHC.Ghc action in IO.
ghcWrapper :: Ghc a -> IO a

-- | Internal function. Initializes DynFlags value for parsing.
--   
--   Passes "-hide-all-packages" to the GHC API to prevent parsing of
--   package environment files. However this only works if there is no
--   invocation of setSessionDynFlags before calling
--   initDynFlags. See ghc tickets 15541.
initDynFlags :: GhcMonad m => FilePath -> m DynFlags

-- | Requires GhcMonad constraint because there is no pure variant of
--   parseDynamicFilePragma. Yet, in constrast to
--   initDynFlags, it does not (try to) read the file at filepath,
--   but solely depends on the module source in the input string.
--   
--   Passes "-hide-all-packages" to the GHC API to prevent parsing of
--   package environment files. However this only works if there is no
--   invocation of setSessionDynFlags before calling
--   initDynFlagsPure. See ghc tickets 15541.
initDynFlagsPure :: GhcMonad m => FilePath -> String -> m DynFlags

-- | Internal part of parseModuleFromString.
parseModuleFromStringInternal :: DynFlags -> FilePath -> String -> Either (SrcSpan, String) (Anns, ParsedSource)

-- | Low level function which is used in the internal tests. It is advised
--   to use parseModule or parseModuleWithCpp instead of this
--   function.
parseModuleApiAnnsWithCpp :: CppOptions -> FilePath -> IO (Either (SrcSpan, String) (ApiAnns, [Comment], DynFlags, ParsedSource))

-- | Internal function. Exposed if you want to muck with DynFlags before
--   parsing.
parseModuleApiAnnsWithCppInternal :: GhcMonad m => CppOptions -> DynFlags -> FilePath -> m (Either (SrcSpan, String) (ApiAnns, [Comment], DynFlags, ParsedSource))

-- | Internal function. Exposed if you want to muck with DynFlags before
--   parsing. Or after parsing.
postParseTransform :: Either a (ApiAnns, [Comment], DynFlags, ParsedSource) -> DeltaOptions -> Either a (Anns, ParsedSource)

-- | ghc-exactprint is a library to manage manipulating Haskell
--   source files. There are four components.
module Language.Haskell.GHC.ExactPrint

-- | Transform concrete annotations into relative annotations which are
--   more useful when transforming an AST.
relativiseApiAnns :: (Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) => ast -> ApiAnns -> Anns

-- | Exactly the same as relativiseApiAnns but with the possibilty
--   to inject comments. This is typically used if the source has been
--   preprocessed by e.g. CPP, and the parts stripped out of the original
--   source are re-added as comments so they are not lost for round
--   tripping.
relativiseApiAnnsWithComments :: (Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) => [Comment] -> ast -> ApiAnns -> Anns

-- | This structure holds a complete set of annotations for an AST
type Anns = Map AnnKey Annotation

-- | A Haskell comment. The AnnKeywordId is present if it has been
--   converted from an AnnKeywordId because the annotation must be
--   interleaved into the stream and does not have a well-defined position
data Comment
data Annotation
Ann :: !DeltaPos -> ![(Comment, DeltaPos)] -> ![(Comment, DeltaPos)] -> ![(KeywordId, DeltaPos)] -> !Maybe [SrcSpan] -> !Maybe AnnKey -> Annotation

-- | Offset used to get to the start of the SrcSpan, from whatever the
--   prior output was, including all annPriorComments (field below).
[annEntryDelta] :: Annotation -> !DeltaPos

-- | Comments coming after the last non-comment output of the preceding
--   element but before the SrcSpan being annotated by this Annotation. If
--   these are changed then annEntryDelta (field above) must also change to
--   match.
[annPriorComments] :: Annotation -> ![(Comment, DeltaPos)]

-- | Comments coming after the last output for the element subject to this
--   Annotation. These will only be added by AST transformations, and care
--   must be taken not to disturb layout of following elements.
[annFollowingComments] :: Annotation -> ![(Comment, DeltaPos)]

-- | Annotations associated with this element.
[annsDP] :: Annotation -> ![(KeywordId, DeltaPos)]

-- | Captures the sort order of sub elements. This is needed when the
--   sub-elements have been split (as in a HsLocalBind which holds separate
--   binds and sigs) or for infix patterns where the order has been
--   re-arranged. It is captured explicitly so that after the Delta phase a
--   SrcSpan is used purely as an index into the annotations, allowing
--   transformations of the AST including the introduction of new Located
--   items or re-arranging existing ones.
[annSortKey] :: Annotation -> !Maybe [SrcSpan]

-- | Occasionally we must calculate a SrcSpan for an unlocated list of
--   elements which we must remember for the Print phase. e.g. the
--   statements in a HsLet or HsDo. These must be managed as a group
--   because they all need eo be vertically aligned for the Haskell layout
--   rules, and this guarantees this property in the presence of AST edits.
[annCapturedSpan] :: Annotation -> !Maybe AnnKey

-- | For every Located a, use the SrcSpan and constructor
--   name of a as the key, to store the standard annotation. These are used
--   to maintain context in the AP and EP monads
data AnnKey
AnnKey :: SrcSpan -> AnnConName -> AnnKey

-- | This entry point will also work out which language extensions are
--   required and perform CPP processing if necessary.
--   
--   
--   parseModule = parseModuleWithCpp defaultCppOptions
--   
--   
--   Note: ParsedSource is a synonym for Located
--   (HsModule GhcPs)
parseModule :: FilePath -> IO (Either (SrcSpan, String) (Anns, ParsedSource))

-- | Add any missing annotations so that the full AST element will
--   exactprint properly when done.
addAnnotationsForPretty :: Annotate a => [Comment] -> Located a -> Anns -> Anns

-- | Print an AST with a map of potential modified Anns. The usual
--   way to generate such a map is by using one of the parsers in
--   Language.Haskell.GHC.ExactPrint.Parsers.
exactPrint :: Annotate ast => Located ast -> Anns -> String
