ghc-exactprint-0.3: ExactPrint for GHC

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Internal.Types

Synopsis

Documentation

data PComment a

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

Constructors

Comment 

Fields

commentPos :: !a

Either Span for end or DeltaPos giving offset to end

commentContents :: !String

The contents of the comment including separators

commentIdentifier :: !SrcSpan

Needed to uniquely identify two comments with the same contents

commentOrigin :: !(Maybe AnnKeywordId)

We sometimes turn syntax into comments in order to process them properly.

Instances

Functor PComment 
Eq a => Eq (PComment a) 
Data a => Data (PComment a) 
Ord a => Ord (PComment a) 
Show a => Show (PComment a) 
Show a => Outputable (PComment a) 

type Pos = (Int, Int)

type Span = (Pos, Pos)

newtype DeltaPos

A relative positions, row then column

Constructors

DP (Int, Int) 

newtype LayoutStartCol

Marks the start column of a layout block.

Constructors

LayoutStartCol 

newtype ColDelta

Marks the distance from the start of the layout block to the element.

Constructors

ColDelta 

Fields

getColDelta :: Int
 

data Annotation

Constructors

Ann 

Fields

annEntryDelta :: !DeltaPos

Offset used to get to the start of the SrcSpan, from whatever the prior output was, including all annPriorComments (field below).

annPriorComments :: ![(DComment, 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.

annFollowingComments :: ![(DComment, 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.

annsDP :: ![(KeywordId, DeltaPos)]

Annotations associated with this element.

annSortKey :: !(Maybe [SrcSpan])

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.

annCapturedSpan :: !(Maybe AnnKey)

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.

data Anns

This structure holds a complete set of annotations for an AST

Constructors

Anns 

Instances

data 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

Constructors

AnnKey SrcSpan AnnConName 

data KeywordId

We need our own version of keywordid to manage various special cases

Constructors

G AnnKeywordId 
AnnSpanEntry

Marks the entry position of a SrcSpan, does not generate specific output but does adjust last output position, and cause comment processing.

AnnSemiSep 
AnnComment DComment 
AnnString String

Used to pass information from Delta to Print when we have to work out details from the original SrcSpan.

AnnUnicode AnnKeywordId

Used to indicate that we should print using unicode syntax if possible.

data ResTyGADTHook name

Constructors

ResTyGADTHook [LHsTyVarBndr name] 

Instances

DataId name => Data (ResTyGADTHook name) 
Show (LHsTyVarBndr name) => Show (ResTyGADTHook name) 
OutputableBndr name => Outputable (ResTyGADTHook name) 
(DataId name, OutputableBndr name, HasOccName name, Annotate name) => Annotate (ResTyGADTHook name) 

showGhc :: Outputable a => a -> String

Show a GHC.Outputable structure