ghc-exactprint-1.1.0: ExactPrint for GHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Haskell.GHC.ExactPrint.Types

Synopsis

Documentation

type Anns = Map AnnKey Annotation Source #

This structure holds a complete set of annotations for an AST

data AnnKey Source #

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

Instances

Instances details
Data AnnKey Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnKey -> c AnnKey #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnKey #

toConstr :: AnnKey -> Constr #

dataTypeOf :: AnnKey -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnKey) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnKey) #

gmapT :: (forall b. Data b => b -> b) -> AnnKey -> AnnKey #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnKey -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnKey -> r #

gmapQ :: (forall d. Data d => d -> u) -> AnnKey -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnKey -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnKey -> m AnnKey #

Show AnnKey Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Eq AnnKey Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

(==) :: AnnKey -> AnnKey -> Bool #

(/=) :: AnnKey -> AnnKey -> Bool #

Ord AnnKey Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Monad m => MonadState (Anns, Int) (TransformT m) Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Transform

Methods

get :: TransformT m (Anns, Int) #

put :: (Anns, Int) -> TransformT m () #

state :: ((Anns, Int) -> (a, (Anns, Int))) -> TransformT m a #

data AnnConName Source #

Constructors

CN 

Fields

Instances

Instances details
Data AnnConName Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AnnConName -> c AnnConName #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnnConName #

toConstr :: AnnConName -> Constr #

dataTypeOf :: AnnConName -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnnConName) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnConName) #

gmapT :: (forall b. Data b => b -> b) -> AnnConName -> AnnConName #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnConName -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnConName -> r #

gmapQ :: (forall d. Data d => d -> u) -> AnnConName -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AnnConName -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnnConName -> m AnnConName #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnConName -> m AnnConName #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnnConName -> m AnnConName #

Show AnnConName Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Eq AnnConName Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Ord AnnConName Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

mkAnnKey :: Data a => Located a -> AnnKey Source #

Make an unwrapped AnnKey for the LHsDecl case, a normal one otherwise.

type Pos = (Int, Int) Source #

data Annotation Source #

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

  • annsDP :: ![(KeywordId, DeltaPos)]

    Annotations associated with this element.

  • annSortKey :: !(Maybe [RealSrcSpan])

    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.

Instances

Instances details
Eq Annotation Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Monad m => MonadState (Anns, Int) (TransformT m) Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Transform

Methods

get :: TransformT m (Anns, Int) #

put :: (Anns, Int) -> TransformT m () #

state :: ((Anns, Int) -> (a, (Anns, Int))) -> TransformT m a #

declFun :: (forall a. Data a => LocatedA a -> b) -> LHsDecl GhcPs -> b Source #

data Comment Source #

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

Instances

Instances details
Show Comment Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Outputable Comment Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

ppr :: Comment -> SDoc #

Eq Comment Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Methods

(==) :: Comment -> Comment -> Bool #

(/=) :: Comment -> Comment -> Bool #

Ord Comment Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

data KeywordId Source #

The different syntactic elements which are not represented in the AST.

Constructors

G AnnKeywordId

A normal keyword

AnnSemiSep

A separating comma

AnnTypeApp

Visible type application annotation

AnnComment Comment 
AnnString String

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

Instances

Instances details
Show KeywordId Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types

Eq KeywordId Source # 
Instance details

Defined in Language.Haskell.GHC.ExactPrint.Types