{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}

module GHC.Parser.Annotation (
  -- * Core Exact Print Annotation types
  AnnKeywordId(..),
  EpaComment(..), EpaCommentTok(..),
  IsUnicodeSyntax(..),
  unicodeAnn,
  HasE(..),

  -- * In-tree Exact Print Annotations
  AddEpAnn(..),
  EpaLocation(..), epaLocationRealSrcSpan, epaLocationFromSrcAnn,
  DeltaPos(..), deltaPos, getDeltaLine,

  EpAnn(..), Anchor(..), AnchorOperation(..),
  spanAsAnchor, realSpanAsAnchor,
  noAnn,

  -- ** Comments in Annotations

  EpAnnComments(..), LEpaComment, emptyComments,
  getFollowingComments, setFollowingComments, setPriorComments,
  EpAnnCO,

  -- ** Annotations in 'GenLocated'
  LocatedA, LocatedL, LocatedC, LocatedN, LocatedAn, LocatedP,
  SrcSpanAnnA, SrcSpanAnnL, SrcSpanAnnP, SrcSpanAnnC, SrcSpanAnnN,
  SrcSpanAnn'(..), SrcAnn,

  -- ** Annotation data types used in 'GenLocated'

  AnnListItem(..), AnnList(..),
  AnnParen(..), ParenType(..), parenTypeKws,
  AnnPragma(..),
  AnnContext(..),
  NameAnn(..), NameAdornment(..),
  NoEpAnns(..),
  AnnSortKey(..),

  -- ** Trailing annotations in lists
  TrailingAnn(..), addTrailingAnnToA, addTrailingAnnToL, addTrailingCommaToN,

  -- ** Utilities for converting between different 'GenLocated' when
  -- ** we do not care about the annotations.
  la2na, na2la, n2l, l2n, l2l, la2la,
  reLoc, reLocA, reLocL, reLocC, reLocN,

  la2r, realSrcSpan,

  -- ** Building up annotations
  extraToAnnList, reAnn,
  reAnnL, reAnnC,
  addAnns, addAnnsA, widenSpan, widenAnchor, widenAnchorR, widenLocatedAn,

  -- ** Querying annotations
  getLocAnn,
  epAnnAnns, epAnnAnnsL,
  annParen2AddEpAnn,
  epAnnComments,

  -- ** Working with locations of annotations
  sortLocatedA,
  mapLocA,
  combineLocsA,
  combineSrcSpansA,
  addCLocA, addCLocAA,

  -- ** Constructing 'GenLocated' annotation types when we do not care
  -- about annotations.
  noLocA, getLocA,
  noSrcSpanA,
  noAnnSrcSpan,

  -- ** Working with comments in annotations
  noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn,
  addCommentsToEpAnn, setCommentsEpAnn,
  transferAnnsA, commentsOnlyA, removeCommentsA,

  placeholderRealSpan,
  ) where

import GHC.Prelude

import Data.Data
import Data.Function (on)
import Data.List (sortBy)
import Data.Semigroup
import GHC.Data.FastString
import GHC.Types.Name
import GHC.Types.SrcLoc
import GHC.Utils.Binary
import GHC.Utils.Outputable hiding ( (<>) )
import GHC.Utils.Panic

{-
Note [exact print annotations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given a parse tree of a Haskell module, how can we reconstruct
the original Haskell source code, retaining all whitespace and
source code comments?  We need to track the locations of all
elements from the original source: this includes keywords such as
'let' / 'in' / 'do' etc as well as punctuation such as commas and
braces, and also comments.  We collectively refer to this
metadata as the "exact print annotations".

NON-COMMENT ELEMENTS

Intuitively, every AST element directly contains a bag of keywords
(keywords can show up more than once in a node: a semicolon i.e. newline
can show up multiple times before the next AST element), each of which
needs to be associated with its location in the original source code.

These keywords are recorded directly in the AST element in which they
occur, for the GhcPs phase.

For any given element in the AST, there is only a set number of
keywords that are applicable for it (e.g., you'll never see an
'import' keyword associated with a let-binding.)  The set of allowed
keywords is documented in a comment associated with the constructor
of a given AST element, although the ground truth is in GHC.Parser
and GHC.Parser.PostProcess (which actually add the annotations).

COMMENT ELEMENTS

We associate comments with the lowest (most specific) AST element
enclosing them

PARSER STATE

There are three fields in PState (the parser state) which play a role
with annotation comments.

>  comment_q :: [LEpaComment],
>  header_comments :: Maybe [LEpaComment],
>  eof_pos :: Maybe (RealSrcSpan, RealSrcSpan), -- pos, gap to prior token

The 'comment_q' field captures comments as they are seen in the token stream,
so that when they are ready to be allocated via the parser they are
available.

The 'header_comments' capture the comments coming at the top of the
source file.  They are moved there from the `comment_q` when comments
are allocated for the first top-level declaration.

The 'eof_pos' captures the final location in the file, and the
location of the immediately preceding token to the last location, so
that the exact-printer can work out how far to advance to add the
trailing whitespace.

PARSER EMISSION OF ANNOTATIONS

The parser interacts with the lexer using the functions

> getCommentsFor      :: (MonadP m) => SrcSpan -> m EpAnnComments
> getPriorCommentsFor :: (MonadP m) => SrcSpan -> m EpAnnComments
> getFinalCommentsFor :: (MonadP m) => SrcSpan -> m EpAnnComments

The 'getCommentsFor' function is the one used most often.  It takes
the AST element SrcSpan and removes and returns any comments in the
'comment_q' that are inside the span. 'allocateComments' in 'Lexer' is
responsible for making sure we only return comments that actually fit
in the 'SrcSpan'.

The 'getPriorCommentsFor' function is used for top-level declarations,
and removes and returns any comments in the 'comment_q' that either
precede or are included in the given SrcSpan. This is to ensure that
preceding documentation comments are kept together with the
declaration they belong to.

The 'getFinalCommentsFor' function is called right at the end when EOF
is hit. This drains the 'comment_q' completely, and returns the
'header_comments', remaining 'comment_q' entries and the
'eof_pos'. These values are inserted into the 'HsModule' AST element.

The wiki page describing this feature is
https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations

-}

-- --------------------------------------------------------------------

-- | Exact print annotations exist so that tools can perform source to
-- source conversions of Haskell code. They are used to keep track of
-- the various syntactic keywords that are not otherwise captured in the
-- AST.
--
-- The wiki page describing this feature is
-- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations
-- https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations
--
-- Note: in general the names of these are taken from the
-- corresponding token, unless otherwise noted
-- See note [exact print annotations] above for details of the usage
data AnnKeywordId
    = AnnAnyclass
    | AnnAs
    | AnnAt
    | AnnBang  -- ^ '!'
    | AnnBackquote -- ^ '`'
    | AnnBy
    | AnnCase -- ^ case or lambda case
    | AnnClass
    | AnnClose -- ^  '\#)' or '\#-}'  etc
    | AnnCloseB -- ^ '|)'
    | AnnCloseBU -- ^ '|)', unicode variant
    | AnnCloseC -- ^ '}'
    | AnnCloseQ  -- ^ '|]'
    | AnnCloseQU -- ^ '|]', unicode variant
    | AnnCloseP -- ^ ')'
    | AnnClosePH -- ^ '\#)'
    | AnnCloseS -- ^ ']'
    | AnnColon
    | AnnComma -- ^ as a list separator
    | AnnCommaTuple -- ^ in a RdrName for a tuple
    | AnnDarrow -- ^ '=>'
    | AnnDarrowU -- ^ '=>', unicode variant
    | AnnData
    | AnnDcolon -- ^ '::'
    | AnnDcolonU -- ^ '::', unicode variant
    | AnnDefault
    | AnnDeriving
    | AnnDo
    | AnnDot    -- ^ '.'
    | AnnDotdot -- ^ '..'
    | AnnElse
    | AnnEqual
    | AnnExport
    | AnnFamily
    | AnnForall
    | AnnForallU -- ^ Unicode variant
    | AnnForeign
    | AnnFunId -- ^ for function name in matches where there are
               -- multiple equations for the function.
    | AnnGroup
    | AnnHeader -- ^ for CType
    | AnnHiding
    | AnnIf
    | AnnImport
    | AnnIn
    | AnnInfix -- ^ 'infix' or 'infixl' or 'infixr'
    | AnnInstance
    | AnnLam
    | AnnLarrow     -- ^ '<-'
    | AnnLarrowU    -- ^ '<-', unicode variant
    | AnnLet
    | AnnLollyU     -- ^ The '⊸' unicode arrow
    | AnnMdo
    | AnnMinus -- ^ '-'
    | AnnModule
    | AnnNewtype
    | AnnName -- ^ where a name loses its location in the AST, this carries it
    | AnnOf
    | AnnOpen    -- ^ '{-\# DEPRECATED' etc. Opening of pragmas where
                 -- the capitalisation of the string can be changed by
                 -- the user. The actual text used is stored in a
                 -- 'SourceText' on the relevant pragma item.
    | AnnOpenB   -- ^ '(|'
    | AnnOpenBU  -- ^ '(|', unicode variant
    | AnnOpenC   -- ^ '{'
    | AnnOpenE   -- ^ '[e|' or '[e||'
    | AnnOpenEQ  -- ^ '[|'
    | AnnOpenEQU -- ^ '[|', unicode variant
    | AnnOpenP   -- ^ '('
    | AnnOpenS   -- ^ '['
    | AnnOpenPH  -- ^ '(\#'
    | AnnDollar          -- ^ prefix '$'   -- TemplateHaskell
    | AnnDollarDollar    -- ^ prefix '$$'  -- TemplateHaskell
    | AnnPackageName
    | AnnPattern
    | AnnPercent    -- ^ '%'  -- for HsExplicitMult
    | AnnPercentOne -- ^ '%1' -- for HsLinearArrow
    | AnnProc
    | AnnQualified
    | AnnRarrow -- ^ '->'
    | AnnRarrowU -- ^ '->', unicode variant
    | AnnRec
    | AnnRole
    | AnnSafe
    | AnnSemi -- ^ ';'
    | AnnSimpleQuote -- ^ '''
    | AnnSignature
    | AnnStatic -- ^ 'static'
    | AnnStock
    | AnnThen
    | AnnThTyQuote -- ^ double '''
    | AnnTilde -- ^ '~'
    | AnnType
    | AnnUnit -- ^ '()' for types
    | AnnUsing
    | AnnVal  -- ^ e.g. INTEGER
    | AnnValStr  -- ^ String value, will need quotes when output
    | AnnVbar -- ^ '|'
    | AnnVia -- ^ 'via'
    | AnnWhere
    | Annlarrowtail -- ^ '-<'
    | AnnlarrowtailU -- ^ '-<', unicode variant
    | Annrarrowtail -- ^ '->'
    | AnnrarrowtailU -- ^ '->', unicode variant
    | AnnLarrowtail -- ^ '-<<'
    | AnnLarrowtailU -- ^ '-<<', unicode variant
    | AnnRarrowtail -- ^ '>>-'
    | AnnRarrowtailU -- ^ '>>-', unicode variant
    deriving (AnnKeywordId -> AnnKeywordId -> Bool
(AnnKeywordId -> AnnKeywordId -> Bool)
-> (AnnKeywordId -> AnnKeywordId -> Bool) -> Eq AnnKeywordId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnKeywordId -> AnnKeywordId -> Bool
$c/= :: AnnKeywordId -> AnnKeywordId -> Bool
== :: AnnKeywordId -> AnnKeywordId -> Bool
$c== :: AnnKeywordId -> AnnKeywordId -> Bool
Eq, Eq AnnKeywordId
Eq AnnKeywordId
-> (AnnKeywordId -> AnnKeywordId -> Ordering)
-> (AnnKeywordId -> AnnKeywordId -> Bool)
-> (AnnKeywordId -> AnnKeywordId -> Bool)
-> (AnnKeywordId -> AnnKeywordId -> Bool)
-> (AnnKeywordId -> AnnKeywordId -> Bool)
-> (AnnKeywordId -> AnnKeywordId -> AnnKeywordId)
-> (AnnKeywordId -> AnnKeywordId -> AnnKeywordId)
-> Ord AnnKeywordId
AnnKeywordId -> AnnKeywordId -> Bool
AnnKeywordId -> AnnKeywordId -> Ordering
AnnKeywordId -> AnnKeywordId -> AnnKeywordId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId
$cmin :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId
max :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId
$cmax :: AnnKeywordId -> AnnKeywordId -> AnnKeywordId
>= :: AnnKeywordId -> AnnKeywordId -> Bool
$c>= :: AnnKeywordId -> AnnKeywordId -> Bool
> :: AnnKeywordId -> AnnKeywordId -> Bool
$c> :: AnnKeywordId -> AnnKeywordId -> Bool
<= :: AnnKeywordId -> AnnKeywordId -> Bool
$c<= :: AnnKeywordId -> AnnKeywordId -> Bool
< :: AnnKeywordId -> AnnKeywordId -> Bool
$c< :: AnnKeywordId -> AnnKeywordId -> Bool
compare :: AnnKeywordId -> AnnKeywordId -> Ordering
$ccompare :: AnnKeywordId -> AnnKeywordId -> Ordering
Ord, Typeable AnnKeywordId
Typeable AnnKeywordId
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnKeywordId)
-> (AnnKeywordId -> Constr)
-> (AnnKeywordId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnKeywordId))
-> ((forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnKeywordId -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId)
-> Data AnnKeywordId
AnnKeywordId -> DataType
AnnKeywordId -> Constr
(forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u
forall u. (forall d. Data d => d -> u) -> AnnKeywordId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnKeywordId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnKeywordId)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnKeywordId -> m AnnKeywordId
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnKeywordId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnKeywordId -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnKeywordId -> r
gmapT :: (forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId
$cgmapT :: (forall b. Data b => b -> b) -> AnnKeywordId -> AnnKeywordId
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnKeywordId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnKeywordId)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnKeywordId)
dataTypeOf :: AnnKeywordId -> DataType
$cdataTypeOf :: AnnKeywordId -> DataType
toConstr :: AnnKeywordId -> Constr
$ctoConstr :: AnnKeywordId -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnKeywordId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnKeywordId
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId
Data, Int -> AnnKeywordId -> ShowS
[AnnKeywordId] -> ShowS
AnnKeywordId -> String
(Int -> AnnKeywordId -> ShowS)
-> (AnnKeywordId -> String)
-> ([AnnKeywordId] -> ShowS)
-> Show AnnKeywordId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnnKeywordId] -> ShowS
$cshowList :: [AnnKeywordId] -> ShowS
show :: AnnKeywordId -> String
$cshow :: AnnKeywordId -> String
showsPrec :: Int -> AnnKeywordId -> ShowS
$cshowsPrec :: Int -> AnnKeywordId -> ShowS
Show)

instance Outputable AnnKeywordId where
  ppr :: AnnKeywordId -> SDoc
ppr AnnKeywordId
x = String -> SDoc
text (AnnKeywordId -> String
forall a. Show a => a -> String
show AnnKeywordId
x)

-- | Certain tokens can have alternate representations when unicode syntax is
-- enabled. This flag is attached to those tokens in the lexer so that the
-- original source representation can be reproduced in the corresponding
-- 'EpAnnotation'
data IsUnicodeSyntax = UnicodeSyntax | NormalSyntax
    deriving (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
(IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> Eq IsUnicodeSyntax
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c/= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
== :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c== :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
Eq, Eq IsUnicodeSyntax
Eq IsUnicodeSyntax
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Ordering)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> Bool)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax)
-> (IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax)
-> Ord IsUnicodeSyntax
IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
IsUnicodeSyntax -> IsUnicodeSyntax -> Ordering
IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax
$cmin :: IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax
max :: IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax
$cmax :: IsUnicodeSyntax -> IsUnicodeSyntax -> IsUnicodeSyntax
>= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c>= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
> :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c> :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
<= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c<= :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
< :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
$c< :: IsUnicodeSyntax -> IsUnicodeSyntax -> Bool
compare :: IsUnicodeSyntax -> IsUnicodeSyntax -> Ordering
$ccompare :: IsUnicodeSyntax -> IsUnicodeSyntax -> Ordering
Ord, Typeable IsUnicodeSyntax
Typeable IsUnicodeSyntax
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> IsUnicodeSyntax -> c IsUnicodeSyntax)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c IsUnicodeSyntax)
-> (IsUnicodeSyntax -> Constr)
-> (IsUnicodeSyntax -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c IsUnicodeSyntax))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c IsUnicodeSyntax))
-> ((forall b. Data b => b -> b)
    -> IsUnicodeSyntax -> IsUnicodeSyntax)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> IsUnicodeSyntax -> m IsUnicodeSyntax)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> IsUnicodeSyntax -> m IsUnicodeSyntax)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> IsUnicodeSyntax -> m IsUnicodeSyntax)
-> Data IsUnicodeSyntax
IsUnicodeSyntax -> DataType
IsUnicodeSyntax -> Constr
(forall b. Data b => b -> b) -> IsUnicodeSyntax -> IsUnicodeSyntax
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u
forall u. (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsUnicodeSyntax
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsUnicodeSyntax -> c IsUnicodeSyntax
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsUnicodeSyntax)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IsUnicodeSyntax)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IsUnicodeSyntax -> m IsUnicodeSyntax
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsUnicodeSyntax -> r
gmapT :: (forall b. Data b => b -> b) -> IsUnicodeSyntax -> IsUnicodeSyntax
$cgmapT :: (forall b. Data b => b -> b) -> IsUnicodeSyntax -> IsUnicodeSyntax
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IsUnicodeSyntax)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IsUnicodeSyntax)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsUnicodeSyntax)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsUnicodeSyntax)
dataTypeOf :: IsUnicodeSyntax -> DataType
$cdataTypeOf :: IsUnicodeSyntax -> DataType
toConstr :: IsUnicodeSyntax -> Constr
$ctoConstr :: IsUnicodeSyntax -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsUnicodeSyntax
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsUnicodeSyntax
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsUnicodeSyntax -> c IsUnicodeSyntax
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsUnicodeSyntax -> c IsUnicodeSyntax
Data, Int -> IsUnicodeSyntax -> ShowS
[IsUnicodeSyntax] -> ShowS
IsUnicodeSyntax -> String
(Int -> IsUnicodeSyntax -> ShowS)
-> (IsUnicodeSyntax -> String)
-> ([IsUnicodeSyntax] -> ShowS)
-> Show IsUnicodeSyntax
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IsUnicodeSyntax] -> ShowS
$cshowList :: [IsUnicodeSyntax] -> ShowS
show :: IsUnicodeSyntax -> String
$cshow :: IsUnicodeSyntax -> String
showsPrec :: Int -> IsUnicodeSyntax -> ShowS
$cshowsPrec :: Int -> IsUnicodeSyntax -> ShowS
Show)

-- | Convert a normal annotation into its unicode equivalent one
unicodeAnn :: AnnKeywordId -> AnnKeywordId
unicodeAnn :: AnnKeywordId -> AnnKeywordId
unicodeAnn AnnKeywordId
AnnForall     = AnnKeywordId
AnnForallU
unicodeAnn AnnKeywordId
AnnDcolon     = AnnKeywordId
AnnDcolonU
unicodeAnn AnnKeywordId
AnnLarrow     = AnnKeywordId
AnnLarrowU
unicodeAnn AnnKeywordId
AnnRarrow     = AnnKeywordId
AnnRarrowU
unicodeAnn AnnKeywordId
AnnDarrow     = AnnKeywordId
AnnDarrowU
unicodeAnn AnnKeywordId
Annlarrowtail = AnnKeywordId
AnnlarrowtailU
unicodeAnn AnnKeywordId
Annrarrowtail = AnnKeywordId
AnnrarrowtailU
unicodeAnn AnnKeywordId
AnnLarrowtail = AnnKeywordId
AnnLarrowtailU
unicodeAnn AnnKeywordId
AnnRarrowtail = AnnKeywordId
AnnRarrowtailU
unicodeAnn AnnKeywordId
AnnOpenB      = AnnKeywordId
AnnOpenBU
unicodeAnn AnnKeywordId
AnnCloseB     = AnnKeywordId
AnnCloseBU
unicodeAnn AnnKeywordId
AnnOpenEQ     = AnnKeywordId
AnnOpenEQU
unicodeAnn AnnKeywordId
AnnCloseQ     = AnnKeywordId
AnnCloseQU
unicodeAnn AnnKeywordId
ann           = AnnKeywordId
ann


-- | Some template haskell tokens have two variants, one with an `e` the other
-- not:
--
-- >  [| or [e|
-- >  [|| or [e||
--
-- This type indicates whether the 'e' is present or not.
data HasE = HasE | NoE
     deriving (HasE -> HasE -> Bool
(HasE -> HasE -> Bool) -> (HasE -> HasE -> Bool) -> Eq HasE
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HasE -> HasE -> Bool
$c/= :: HasE -> HasE -> Bool
== :: HasE -> HasE -> Bool
$c== :: HasE -> HasE -> Bool
Eq, Eq HasE
Eq HasE
-> (HasE -> HasE -> Ordering)
-> (HasE -> HasE -> Bool)
-> (HasE -> HasE -> Bool)
-> (HasE -> HasE -> Bool)
-> (HasE -> HasE -> Bool)
-> (HasE -> HasE -> HasE)
-> (HasE -> HasE -> HasE)
-> Ord HasE
HasE -> HasE -> Bool
HasE -> HasE -> Ordering
HasE -> HasE -> HasE
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: HasE -> HasE -> HasE
$cmin :: HasE -> HasE -> HasE
max :: HasE -> HasE -> HasE
$cmax :: HasE -> HasE -> HasE
>= :: HasE -> HasE -> Bool
$c>= :: HasE -> HasE -> Bool
> :: HasE -> HasE -> Bool
$c> :: HasE -> HasE -> Bool
<= :: HasE -> HasE -> Bool
$c<= :: HasE -> HasE -> Bool
< :: HasE -> HasE -> Bool
$c< :: HasE -> HasE -> Bool
compare :: HasE -> HasE -> Ordering
$ccompare :: HasE -> HasE -> Ordering
Ord, Typeable HasE
Typeable HasE
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HasE -> c HasE)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HasE)
-> (HasE -> Constr)
-> (HasE -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HasE))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HasE))
-> ((forall b. Data b => b -> b) -> HasE -> HasE)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r)
-> (forall u. (forall d. Data d => d -> u) -> HasE -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> HasE -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HasE -> m HasE)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HasE -> m HasE)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HasE -> m HasE)
-> Data HasE
HasE -> DataType
HasE -> Constr
(forall b. Data b => b -> b) -> HasE -> HasE
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> HasE -> u
forall u. (forall d. Data d => d -> u) -> HasE -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HasE
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HasE -> c HasE
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HasE)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HasE)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HasE -> m HasE
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HasE -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HasE -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> HasE -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HasE -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HasE -> r
gmapT :: (forall b. Data b => b -> b) -> HasE -> HasE
$cgmapT :: (forall b. Data b => b -> b) -> HasE -> HasE
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HasE)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HasE)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HasE)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HasE)
dataTypeOf :: HasE -> DataType
$cdataTypeOf :: HasE -> DataType
toConstr :: HasE -> Constr
$ctoConstr :: HasE -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HasE
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HasE
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HasE -> c HasE
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HasE -> c HasE
Data, Int -> HasE -> ShowS
[HasE] -> ShowS
HasE -> String
(Int -> HasE -> ShowS)
-> (HasE -> String) -> ([HasE] -> ShowS) -> Show HasE
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HasE] -> ShowS
$cshowList :: [HasE] -> ShowS
show :: HasE -> String
$cshow :: HasE -> String
showsPrec :: Int -> HasE -> ShowS
$cshowsPrec :: Int -> HasE -> ShowS
Show)

-- ---------------------------------------------------------------------

data EpaComment =
  EpaComment
    { EpaComment -> EpaCommentTok
ac_tok :: EpaCommentTok
    , EpaComment -> RealSrcSpan
ac_prior_tok :: RealSrcSpan
    -- ^ The location of the prior token, used in exact printing.  The
    -- 'EpaComment' appears as an 'LEpaComment' containing its
    -- location.  The difference between the end of the prior token
    -- and the start of this location is used for the spacing when
    -- exact printing the comment.
    }
    deriving (EpaComment -> EpaComment -> Bool
(EpaComment -> EpaComment -> Bool)
-> (EpaComment -> EpaComment -> Bool) -> Eq EpaComment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpaComment -> EpaComment -> Bool
$c/= :: EpaComment -> EpaComment -> Bool
== :: EpaComment -> EpaComment -> Bool
$c== :: EpaComment -> EpaComment -> Bool
Eq, Eq EpaComment
Eq EpaComment
-> (EpaComment -> EpaComment -> Ordering)
-> (EpaComment -> EpaComment -> Bool)
-> (EpaComment -> EpaComment -> Bool)
-> (EpaComment -> EpaComment -> Bool)
-> (EpaComment -> EpaComment -> Bool)
-> (EpaComment -> EpaComment -> EpaComment)
-> (EpaComment -> EpaComment -> EpaComment)
-> Ord EpaComment
EpaComment -> EpaComment -> Bool
EpaComment -> EpaComment -> Ordering
EpaComment -> EpaComment -> EpaComment
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EpaComment -> EpaComment -> EpaComment
$cmin :: EpaComment -> EpaComment -> EpaComment
max :: EpaComment -> EpaComment -> EpaComment
$cmax :: EpaComment -> EpaComment -> EpaComment
>= :: EpaComment -> EpaComment -> Bool
$c>= :: EpaComment -> EpaComment -> Bool
> :: EpaComment -> EpaComment -> Bool
$c> :: EpaComment -> EpaComment -> Bool
<= :: EpaComment -> EpaComment -> Bool
$c<= :: EpaComment -> EpaComment -> Bool
< :: EpaComment -> EpaComment -> Bool
$c< :: EpaComment -> EpaComment -> Bool
compare :: EpaComment -> EpaComment -> Ordering
$ccompare :: EpaComment -> EpaComment -> Ordering
Ord, Typeable EpaComment
Typeable EpaComment
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EpaComment -> c EpaComment)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EpaComment)
-> (EpaComment -> Constr)
-> (EpaComment -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EpaComment))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EpaComment))
-> ((forall b. Data b => b -> b) -> EpaComment -> EpaComment)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaComment -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaComment -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpaComment -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EpaComment -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpaComment -> m EpaComment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaComment -> m EpaComment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaComment -> m EpaComment)
-> Data EpaComment
EpaComment -> DataType
EpaComment -> Constr
(forall b. Data b => b -> b) -> EpaComment -> EpaComment
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EpaComment -> u
forall u. (forall d. Data d => d -> u) -> EpaComment -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaComment
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaComment -> c EpaComment
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaComment)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpaComment)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaComment -> m EpaComment
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaComment -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaComment -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpaComment -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpaComment -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaComment -> r
gmapT :: (forall b. Data b => b -> b) -> EpaComment -> EpaComment
$cgmapT :: (forall b. Data b => b -> b) -> EpaComment -> EpaComment
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpaComment)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpaComment)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaComment)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaComment)
dataTypeOf :: EpaComment -> DataType
$cdataTypeOf :: EpaComment -> DataType
toConstr :: EpaComment -> Constr
$ctoConstr :: EpaComment -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaComment
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaComment
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaComment -> c EpaComment
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaComment -> c EpaComment
Data, Int -> EpaComment -> ShowS
[EpaComment] -> ShowS
EpaComment -> String
(Int -> EpaComment -> ShowS)
-> (EpaComment -> String)
-> ([EpaComment] -> ShowS)
-> Show EpaComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EpaComment] -> ShowS
$cshowList :: [EpaComment] -> ShowS
show :: EpaComment -> String
$cshow :: EpaComment -> String
showsPrec :: Int -> EpaComment -> ShowS
$cshowsPrec :: Int -> EpaComment -> ShowS
Show)

data EpaCommentTok =
  -- Documentation annotations
    EpaDocCommentNext  String     -- ^ something beginning '-- |'
  | EpaDocCommentPrev  String     -- ^ something beginning '-- ^'
  | EpaDocCommentNamed String     -- ^ something beginning '-- $'
  | EpaDocSection      Int String -- ^ a section heading
  | EpaDocOptions      String     -- ^ doc options (prune, ignore-exports, etc)
  | EpaLineComment     String     -- ^ comment starting by "--"
  | EpaBlockComment    String     -- ^ comment in {- -}
  | EpaEofComment                 -- ^ empty comment, capturing
                                  -- location of EOF

  -- See #19697 for a discussion of EpaEofComment's use and how it
  -- should be removed in favour of capturing it in the location for
  -- 'Located HsModule' in the parser.

    deriving (EpaCommentTok -> EpaCommentTok -> Bool
(EpaCommentTok -> EpaCommentTok -> Bool)
-> (EpaCommentTok -> EpaCommentTok -> Bool) -> Eq EpaCommentTok
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpaCommentTok -> EpaCommentTok -> Bool
$c/= :: EpaCommentTok -> EpaCommentTok -> Bool
== :: EpaCommentTok -> EpaCommentTok -> Bool
$c== :: EpaCommentTok -> EpaCommentTok -> Bool
Eq, Eq EpaCommentTok
Eq EpaCommentTok
-> (EpaCommentTok -> EpaCommentTok -> Ordering)
-> (EpaCommentTok -> EpaCommentTok -> Bool)
-> (EpaCommentTok -> EpaCommentTok -> Bool)
-> (EpaCommentTok -> EpaCommentTok -> Bool)
-> (EpaCommentTok -> EpaCommentTok -> Bool)
-> (EpaCommentTok -> EpaCommentTok -> EpaCommentTok)
-> (EpaCommentTok -> EpaCommentTok -> EpaCommentTok)
-> Ord EpaCommentTok
EpaCommentTok -> EpaCommentTok -> Bool
EpaCommentTok -> EpaCommentTok -> Ordering
EpaCommentTok -> EpaCommentTok -> EpaCommentTok
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EpaCommentTok -> EpaCommentTok -> EpaCommentTok
$cmin :: EpaCommentTok -> EpaCommentTok -> EpaCommentTok
max :: EpaCommentTok -> EpaCommentTok -> EpaCommentTok
$cmax :: EpaCommentTok -> EpaCommentTok -> EpaCommentTok
>= :: EpaCommentTok -> EpaCommentTok -> Bool
$c>= :: EpaCommentTok -> EpaCommentTok -> Bool
> :: EpaCommentTok -> EpaCommentTok -> Bool
$c> :: EpaCommentTok -> EpaCommentTok -> Bool
<= :: EpaCommentTok -> EpaCommentTok -> Bool
$c<= :: EpaCommentTok -> EpaCommentTok -> Bool
< :: EpaCommentTok -> EpaCommentTok -> Bool
$c< :: EpaCommentTok -> EpaCommentTok -> Bool
compare :: EpaCommentTok -> EpaCommentTok -> Ordering
$ccompare :: EpaCommentTok -> EpaCommentTok -> Ordering
Ord, Typeable EpaCommentTok
Typeable EpaCommentTok
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EpaCommentTok -> c EpaCommentTok)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EpaCommentTok)
-> (EpaCommentTok -> Constr)
-> (EpaCommentTok -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EpaCommentTok))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EpaCommentTok))
-> ((forall b. Data b => b -> b) -> EpaCommentTok -> EpaCommentTok)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpaCommentTok -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EpaCommentTok -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok)
-> Data EpaCommentTok
EpaCommentTok -> DataType
EpaCommentTok -> Constr
(forall b. Data b => b -> b) -> EpaCommentTok -> EpaCommentTok
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EpaCommentTok -> u
forall u. (forall d. Data d => d -> u) -> EpaCommentTok -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaCommentTok
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaCommentTok -> c EpaCommentTok
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaCommentTok)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaCommentTok)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaCommentTok -> m EpaCommentTok
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaCommentTok -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaCommentTok -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpaCommentTok -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpaCommentTok -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaCommentTok -> r
gmapT :: (forall b. Data b => b -> b) -> EpaCommentTok -> EpaCommentTok
$cgmapT :: (forall b. Data b => b -> b) -> EpaCommentTok -> EpaCommentTok
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaCommentTok)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaCommentTok)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaCommentTok)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaCommentTok)
dataTypeOf :: EpaCommentTok -> DataType
$cdataTypeOf :: EpaCommentTok -> DataType
toConstr :: EpaCommentTok -> Constr
$ctoConstr :: EpaCommentTok -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaCommentTok
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaCommentTok
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaCommentTok -> c EpaCommentTok
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaCommentTok -> c EpaCommentTok
Data, Int -> EpaCommentTok -> ShowS
[EpaCommentTok] -> ShowS
EpaCommentTok -> String
(Int -> EpaCommentTok -> ShowS)
-> (EpaCommentTok -> String)
-> ([EpaCommentTok] -> ShowS)
-> Show EpaCommentTok
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EpaCommentTok] -> ShowS
$cshowList :: [EpaCommentTok] -> ShowS
show :: EpaCommentTok -> String
$cshow :: EpaCommentTok -> String
showsPrec :: Int -> EpaCommentTok -> ShowS
$cshowsPrec :: Int -> EpaCommentTok -> ShowS
Show)
-- Note: these are based on the Token versions, but the Token type is
-- defined in GHC.Parser.Lexer and bringing it in here would create a loop

instance Outputable EpaComment where
  ppr :: EpaComment -> SDoc
ppr EpaComment
x = String -> SDoc
text (EpaComment -> String
forall a. Show a => a -> String
show EpaComment
x)

-- ---------------------------------------------------------------------

-- | Captures an annotation, storing the @'AnnKeywordId'@ and its
-- location.  The parser only ever inserts @'EpaLocation'@ fields with a
-- RealSrcSpan being the original location of the annotation in the
-- source file.
-- The @'EpaLocation'@ can also store a delta position if the AST has been
-- modified and needs to be pretty printed again.
-- The usual way an 'AddEpAnn' is created is using the 'mj' ("make
-- jump") function, and then it can be inserted into the appropriate
-- annotation.
data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Typeable AddEpAnn
Typeable AddEpAnn
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AddEpAnn -> c AddEpAnn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AddEpAnn)
-> (AddEpAnn -> Constr)
-> (AddEpAnn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AddEpAnn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AddEpAnn))
-> ((forall b. Data b => b -> b) -> AddEpAnn -> AddEpAnn)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r)
-> (forall u. (forall d. Data d => d -> u) -> AddEpAnn -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> AddEpAnn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn)
-> Data AddEpAnn
AddEpAnn -> DataType
AddEpAnn -> Constr
(forall b. Data b => b -> b) -> AddEpAnn -> AddEpAnn
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AddEpAnn -> u
forall u. (forall d. Data d => d -> u) -> AddEpAnn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AddEpAnn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AddEpAnn -> c AddEpAnn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AddEpAnn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AddEpAnn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AddEpAnn -> m AddEpAnn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AddEpAnn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AddEpAnn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AddEpAnn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AddEpAnn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AddEpAnn -> r
gmapT :: (forall b. Data b => b -> b) -> AddEpAnn -> AddEpAnn
$cgmapT :: (forall b. Data b => b -> b) -> AddEpAnn -> AddEpAnn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AddEpAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AddEpAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AddEpAnn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AddEpAnn)
dataTypeOf :: AddEpAnn -> DataType
$cdataTypeOf :: AddEpAnn -> DataType
toConstr :: AddEpAnn -> Constr
$ctoConstr :: AddEpAnn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AddEpAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AddEpAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AddEpAnn -> c AddEpAnn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AddEpAnn -> c AddEpAnn
Data,AddEpAnn -> AddEpAnn -> Bool
(AddEpAnn -> AddEpAnn -> Bool)
-> (AddEpAnn -> AddEpAnn -> Bool) -> Eq AddEpAnn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddEpAnn -> AddEpAnn -> Bool
$c/= :: AddEpAnn -> AddEpAnn -> Bool
== :: AddEpAnn -> AddEpAnn -> Bool
$c== :: AddEpAnn -> AddEpAnn -> Bool
Eq)

-- | The anchor for an @'AnnKeywordId'@. The Parser inserts the
-- @'EpaSpan'@ variant, giving the exact location of the original item
-- in the parsed source.  This can be replaced by the @'EpaDelta'@
-- version, to provide a position for the item relative to the end of
-- the previous item in the source.  This is useful when editing an
-- AST prior to exact printing the changed one. The list of comments
-- in the @'EpaDelta'@ variant captures any comments between the prior
-- output and the thing being marked here, since we cannot otherwise
-- sort the relative order.
data EpaLocation = EpaSpan !RealSrcSpan
                 | EpaDelta !DeltaPos ![LEpaComment]
               deriving (Typeable EpaLocation
Typeable EpaLocation
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EpaLocation -> c EpaLocation)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EpaLocation)
-> (EpaLocation -> Constr)
-> (EpaLocation -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EpaLocation))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EpaLocation))
-> ((forall b. Data b => b -> b) -> EpaLocation -> EpaLocation)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaLocation -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpaLocation -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpaLocation -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EpaLocation -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation)
-> Data EpaLocation
EpaLocation -> DataType
EpaLocation -> Constr
(forall b. Data b => b -> b) -> EpaLocation -> EpaLocation
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EpaLocation -> u
forall u. (forall d. Data d => d -> u) -> EpaLocation -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaLocation
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaLocation -> c EpaLocation
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaLocation)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaLocation)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpaLocation -> m EpaLocation
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaLocation -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpaLocation -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpaLocation -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpaLocation -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpaLocation -> r
gmapT :: (forall b. Data b => b -> b) -> EpaLocation -> EpaLocation
$cgmapT :: (forall b. Data b => b -> b) -> EpaLocation -> EpaLocation
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaLocation)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpaLocation)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaLocation)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpaLocation)
dataTypeOf :: EpaLocation -> DataType
$cdataTypeOf :: EpaLocation -> DataType
toConstr :: EpaLocation -> Constr
$ctoConstr :: EpaLocation -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaLocation
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpaLocation
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaLocation -> c EpaLocation
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpaLocation -> c EpaLocation
Data,EpaLocation -> EpaLocation -> Bool
(EpaLocation -> EpaLocation -> Bool)
-> (EpaLocation -> EpaLocation -> Bool) -> Eq EpaLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpaLocation -> EpaLocation -> Bool
$c/= :: EpaLocation -> EpaLocation -> Bool
== :: EpaLocation -> EpaLocation -> Bool
$c== :: EpaLocation -> EpaLocation -> Bool
Eq,Eq EpaLocation
Eq EpaLocation
-> (EpaLocation -> EpaLocation -> Ordering)
-> (EpaLocation -> EpaLocation -> Bool)
-> (EpaLocation -> EpaLocation -> Bool)
-> (EpaLocation -> EpaLocation -> Bool)
-> (EpaLocation -> EpaLocation -> Bool)
-> (EpaLocation -> EpaLocation -> EpaLocation)
-> (EpaLocation -> EpaLocation -> EpaLocation)
-> Ord EpaLocation
EpaLocation -> EpaLocation -> Bool
EpaLocation -> EpaLocation -> Ordering
EpaLocation -> EpaLocation -> EpaLocation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EpaLocation -> EpaLocation -> EpaLocation
$cmin :: EpaLocation -> EpaLocation -> EpaLocation
max :: EpaLocation -> EpaLocation -> EpaLocation
$cmax :: EpaLocation -> EpaLocation -> EpaLocation
>= :: EpaLocation -> EpaLocation -> Bool
$c>= :: EpaLocation -> EpaLocation -> Bool
> :: EpaLocation -> EpaLocation -> Bool
$c> :: EpaLocation -> EpaLocation -> Bool
<= :: EpaLocation -> EpaLocation -> Bool
$c<= :: EpaLocation -> EpaLocation -> Bool
< :: EpaLocation -> EpaLocation -> Bool
$c< :: EpaLocation -> EpaLocation -> Bool
compare :: EpaLocation -> EpaLocation -> Ordering
$ccompare :: EpaLocation -> EpaLocation -> Ordering
Ord)

-- | Spacing between output items when exact printing.  It captures
-- the spacing from the current print position on the page to the
-- position required for the thing about to be printed.  This is
-- either on the same line in which case is is simply the number of
-- spaces to emit, or it is some number of lines down, with a given
-- column offset.  The exact printing algorithm keeps track of the
-- column offset pertaining to the current anchor position, so the
-- `deltaColumn` is the additional spaces to add in this case.  See
-- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations for
-- details.
data DeltaPos
  = SameLine { DeltaPos -> Int
deltaColumn :: !Int }
  | DifferentLine
      { DeltaPos -> Int
deltaLine   :: !Int, -- ^ deltaLine should always be > 0
        deltaColumn :: !Int
      } deriving (Int -> DeltaPos -> ShowS
[DeltaPos] -> ShowS
DeltaPos -> String
(Int -> DeltaPos -> ShowS)
-> (DeltaPos -> String) -> ([DeltaPos] -> ShowS) -> Show DeltaPos
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeltaPos] -> ShowS
$cshowList :: [DeltaPos] -> ShowS
show :: DeltaPos -> String
$cshow :: DeltaPos -> String
showsPrec :: Int -> DeltaPos -> ShowS
$cshowsPrec :: Int -> DeltaPos -> ShowS
Show,DeltaPos -> DeltaPos -> Bool
(DeltaPos -> DeltaPos -> Bool)
-> (DeltaPos -> DeltaPos -> Bool) -> Eq DeltaPos
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeltaPos -> DeltaPos -> Bool
$c/= :: DeltaPos -> DeltaPos -> Bool
== :: DeltaPos -> DeltaPos -> Bool
$c== :: DeltaPos -> DeltaPos -> Bool
Eq,Eq DeltaPos
Eq DeltaPos
-> (DeltaPos -> DeltaPos -> Ordering)
-> (DeltaPos -> DeltaPos -> Bool)
-> (DeltaPos -> DeltaPos -> Bool)
-> (DeltaPos -> DeltaPos -> Bool)
-> (DeltaPos -> DeltaPos -> Bool)
-> (DeltaPos -> DeltaPos -> DeltaPos)
-> (DeltaPos -> DeltaPos -> DeltaPos)
-> Ord DeltaPos
DeltaPos -> DeltaPos -> Bool
DeltaPos -> DeltaPos -> Ordering
DeltaPos -> DeltaPos -> DeltaPos
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DeltaPos -> DeltaPos -> DeltaPos
$cmin :: DeltaPos -> DeltaPos -> DeltaPos
max :: DeltaPos -> DeltaPos -> DeltaPos
$cmax :: DeltaPos -> DeltaPos -> DeltaPos
>= :: DeltaPos -> DeltaPos -> Bool
$c>= :: DeltaPos -> DeltaPos -> Bool
> :: DeltaPos -> DeltaPos -> Bool
$c> :: DeltaPos -> DeltaPos -> Bool
<= :: DeltaPos -> DeltaPos -> Bool
$c<= :: DeltaPos -> DeltaPos -> Bool
< :: DeltaPos -> DeltaPos -> Bool
$c< :: DeltaPos -> DeltaPos -> Bool
compare :: DeltaPos -> DeltaPos -> Ordering
$ccompare :: DeltaPos -> DeltaPos -> Ordering
Ord,Typeable DeltaPos
Typeable DeltaPos
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DeltaPos -> c DeltaPos)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DeltaPos)
-> (DeltaPos -> Constr)
-> (DeltaPos -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DeltaPos))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DeltaPos))
-> ((forall b. Data b => b -> b) -> DeltaPos -> DeltaPos)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DeltaPos -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DeltaPos -> r)
-> (forall u. (forall d. Data d => d -> u) -> DeltaPos -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> DeltaPos -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos)
-> Data DeltaPos
DeltaPos -> DataType
DeltaPos -> Constr
(forall b. Data b => b -> b) -> DeltaPos -> DeltaPos
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DeltaPos -> u
forall u. (forall d. Data d => d -> u) -> DeltaPos -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DeltaPos
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DeltaPos -> c DeltaPos
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DeltaPos)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DeltaPos)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DeltaPos -> m DeltaPos
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DeltaPos -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DeltaPos -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DeltaPos -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DeltaPos -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DeltaPos -> r
gmapT :: (forall b. Data b => b -> b) -> DeltaPos -> DeltaPos
$cgmapT :: (forall b. Data b => b -> b) -> DeltaPos -> DeltaPos
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DeltaPos)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DeltaPos)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DeltaPos)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DeltaPos)
dataTypeOf :: DeltaPos -> DataType
$cdataTypeOf :: DeltaPos -> DataType
toConstr :: DeltaPos -> Constr
$ctoConstr :: DeltaPos -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DeltaPos
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DeltaPos
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DeltaPos -> c DeltaPos
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DeltaPos -> c DeltaPos
Data)

-- | Smart constructor for a 'DeltaPos'. It preserves the invariant
-- that for the 'DifferentLine' constructor 'deltaLine' is always > 0.
deltaPos :: Int -> Int -> DeltaPos
deltaPos :: Int -> Int -> DeltaPos
deltaPos Int
l Int
c = case Int
l of
  Int
0 -> Int -> DeltaPos
SameLine Int
c
  Int
_ -> Int -> Int -> DeltaPos
DifferentLine Int
l Int
c

getDeltaLine :: DeltaPos -> Int
getDeltaLine :: DeltaPos -> Int
getDeltaLine (SameLine Int
_) = Int
0
getDeltaLine (DifferentLine Int
r Int
_) = Int
r

-- | Used in the parser only, extract the 'RealSrcSpan' from an
-- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the
-- partial function is safe.
epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan
epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan
epaLocationRealSrcSpan (EpaSpan RealSrcSpan
r) = RealSrcSpan
r
epaLocationRealSrcSpan (EpaDelta DeltaPos
_ [LEpaComment]
_) = String -> RealSrcSpan
forall a. String -> a
panic String
"epaLocationRealSrcSpan"

epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation
epaLocationFromSrcAnn :: forall ann. SrcAnn ann -> EpaLocation
epaLocationFromSrcAnn (SrcSpanAnn EpAnn ann
EpAnnNotUsed SrcSpan
l) = RealSrcSpan -> EpaLocation
EpaSpan (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
l)
epaLocationFromSrcAnn (SrcSpanAnn (EpAnn Anchor
anc ann
_ EpAnnComments
_) SrcSpan
_) = RealSrcSpan -> EpaLocation
EpaSpan (Anchor -> RealSrcSpan
anchor Anchor
anc)

instance Outputable EpaLocation where
  ppr :: EpaLocation -> SDoc
ppr (EpaSpan RealSrcSpan
r) = String -> SDoc
text String
"EpaSpan" SDoc -> SDoc -> SDoc
<+> RealSrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr RealSrcSpan
r
  ppr (EpaDelta DeltaPos
d [LEpaComment]
cs) = String -> SDoc
text String
"EpaDelta" SDoc -> SDoc -> SDoc
<+> DeltaPos -> SDoc
forall a. Outputable a => a -> SDoc
ppr DeltaPos
d SDoc -> SDoc -> SDoc
<+> [LEpaComment] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LEpaComment]
cs

instance Outputable AddEpAnn where
  ppr :: AddEpAnn -> SDoc
ppr (AddEpAnn AnnKeywordId
kw EpaLocation
ss) = String -> SDoc
text String
"AddEpAnn" SDoc -> SDoc -> SDoc
<+> AnnKeywordId -> SDoc
forall a. Outputable a => a -> SDoc
ppr AnnKeywordId
kw SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss

instance Ord AddEpAnn where
  compare :: AddEpAnn -> AddEpAnn -> Ordering
compare (AddEpAnn AnnKeywordId
kw1 EpaLocation
loc1) (AddEpAnn AnnKeywordId
kw2 EpaLocation
loc2) = (EpaLocation, AnnKeywordId)
-> (EpaLocation, AnnKeywordId) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (EpaLocation
loc1, AnnKeywordId
kw1) (EpaLocation
loc2,AnnKeywordId
kw2)

-- ---------------------------------------------------------------------

-- | The exact print annotations (EPAs) are kept in the HsSyn AST for
--   the GhcPs phase. We do not always have EPAs though, only for code
--   that has been parsed as they do not exist for generated
--   code. This type captures that they may be missing.
--
-- A goal of the annotations is that an AST can be edited, including
-- moving subtrees from one place to another, duplicating them, and so
-- on.  This means that each fragment must be self-contained.  To this
-- end, each annotated fragment keeps track of the anchor position it
-- was originally captured at, being simply the start span of the
-- topmost element of the ast fragment.  This gives us a way to later
-- re-calculate all Located items in this layer of the AST, as well as
-- any annotations captured. The comments associated with the AST
-- fragment are also captured here.
--
-- The 'ann' type parameter allows this general structure to be
-- specialised to the specific set of locations of original exact
-- print annotation elements.  So for 'HsLet' we have
--
--    type instance XLet GhcPs = EpAnn AnnsLet
--    data AnnsLet
--      = AnnsLet {
--          alLet :: EpaLocation,
--          alIn :: EpaLocation
--          } deriving Data
--
-- The spacing between the items under the scope of a given EpAnn is
-- normally derived from the original 'Anchor'.  But if a sub-element
-- is not in its original position, the required spacing can be
-- directly captured in the 'anchor_op' field of the 'entry' Anchor.
-- This allows us to freely move elements around, and stitch together
-- new AST fragments out of old ones, and have them still printed out
-- in a precise way.
data EpAnn ann
  = EpAnn { forall ann. EpAnn ann -> Anchor
entry   :: Anchor
           -- ^ Base location for the start of the syntactic element
           -- holding the annotations.
           , forall ann. EpAnn ann -> ann
anns     :: ann -- ^ Annotations added by the Parser
           , forall ann. EpAnn ann -> EpAnnComments
comments :: EpAnnComments
              -- ^ Comments enclosed in the SrcSpan of the element
              -- this `EpAnn` is attached to
           }
  | EpAnnNotUsed -- ^ No Annotation for generated code,
                  -- e.g. from TH, deriving, etc.
        deriving (Typeable (EpAnn ann)
Typeable (EpAnn ann)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EpAnn ann -> c (EpAnn ann))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (EpAnn ann))
-> (EpAnn ann -> Constr)
-> (EpAnn ann -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (EpAnn ann)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (EpAnn ann)))
-> ((forall b. Data b => b -> b) -> EpAnn ann -> EpAnn ann)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpAnn ann -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EpAnn ann -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann))
-> Data (EpAnn ann)
EpAnn ann -> DataType
EpAnn ann -> Constr
(forall b. Data b => b -> b) -> EpAnn ann -> EpAnn ann
forall {ann}. Data ann => Typeable (EpAnn ann)
forall ann. Data ann => EpAnn ann -> DataType
forall ann. Data ann => EpAnn ann -> Constr
forall ann.
Data ann =>
(forall b. Data b => b -> b) -> EpAnn ann -> EpAnn ann
forall ann u.
Data ann =>
Int -> (forall d. Data d => d -> u) -> EpAnn ann -> u
forall ann u.
Data ann =>
(forall d. Data d => d -> u) -> EpAnn ann -> [u]
forall ann r r'.
Data ann =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
forall ann r r'.
Data ann =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
forall ann (m :: * -> *).
(Data ann, Monad m) =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
forall ann (m :: * -> *).
(Data ann, MonadPlus m) =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
forall ann (c :: * -> *).
Data ann =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (EpAnn ann)
forall ann (c :: * -> *).
Data ann =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnn ann -> c (EpAnn ann)
forall ann (t :: * -> *) (c :: * -> *).
(Data ann, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (EpAnn ann))
forall ann (t :: * -> * -> *) (c :: * -> *).
(Data ann, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (EpAnn ann))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EpAnn ann -> u
forall u. (forall d. Data d => d -> u) -> EpAnn ann -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (EpAnn ann)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnn ann -> c (EpAnn ann)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (EpAnn ann))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (EpAnn ann))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
$cgmapMo :: forall ann (m :: * -> *).
(Data ann, MonadPlus m) =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
$cgmapMp :: forall ann (m :: * -> *).
(Data ann, MonadPlus m) =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
$cgmapM :: forall ann (m :: * -> *).
(Data ann, Monad m) =>
(forall d. Data d => d -> m d) -> EpAnn ann -> m (EpAnn ann)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpAnn ann -> u
$cgmapQi :: forall ann u.
Data ann =>
Int -> (forall d. Data d => d -> u) -> EpAnn ann -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnn ann -> [u]
$cgmapQ :: forall ann u.
Data ann =>
(forall d. Data d => d -> u) -> EpAnn ann -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
$cgmapQr :: forall ann r r'.
Data ann =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
$cgmapQl :: forall ann r r'.
Data ann =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnn ann -> r
gmapT :: (forall b. Data b => b -> b) -> EpAnn ann -> EpAnn ann
$cgmapT :: forall ann.
Data ann =>
(forall b. Data b => b -> b) -> EpAnn ann -> EpAnn ann
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (EpAnn ann))
$cdataCast2 :: forall ann (t :: * -> * -> *) (c :: * -> *).
(Data ann, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (EpAnn ann))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (EpAnn ann))
$cdataCast1 :: forall ann (t :: * -> *) (c :: * -> *).
(Data ann, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (EpAnn ann))
dataTypeOf :: EpAnn ann -> DataType
$cdataTypeOf :: forall ann. Data ann => EpAnn ann -> DataType
toConstr :: EpAnn ann -> Constr
$ctoConstr :: forall ann. Data ann => EpAnn ann -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (EpAnn ann)
$cgunfold :: forall ann (c :: * -> *).
Data ann =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (EpAnn ann)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnn ann -> c (EpAnn ann)
$cgfoldl :: forall ann (c :: * -> *).
Data ann =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnn ann -> c (EpAnn ann)
Data, EpAnn ann -> EpAnn ann -> Bool
(EpAnn ann -> EpAnn ann -> Bool)
-> (EpAnn ann -> EpAnn ann -> Bool) -> Eq (EpAnn ann)
forall ann. Eq ann => EpAnn ann -> EpAnn ann -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpAnn ann -> EpAnn ann -> Bool
$c/= :: forall ann. Eq ann => EpAnn ann -> EpAnn ann -> Bool
== :: EpAnn ann -> EpAnn ann -> Bool
$c== :: forall ann. Eq ann => EpAnn ann -> EpAnn ann -> Bool
Eq, (forall a b. (a -> b) -> EpAnn a -> EpAnn b)
-> (forall a b. a -> EpAnn b -> EpAnn a) -> Functor EpAnn
forall a b. a -> EpAnn b -> EpAnn a
forall a b. (a -> b) -> EpAnn a -> EpAnn b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> EpAnn b -> EpAnn a
$c<$ :: forall a b. a -> EpAnn b -> EpAnn a
fmap :: forall a b. (a -> b) -> EpAnn a -> EpAnn b
$cfmap :: forall a b. (a -> b) -> EpAnn a -> EpAnn b
Functor)

-- | An 'Anchor' records the base location for the start of the
-- syntactic element holding the annotations, and is used as the point
-- of reference for calculating delta positions for contained
-- annotations.
-- It is also normally used as the reference point for the spacing of
-- the element relative to its container. If it is moved, that
-- relationship is tracked in the 'anchor_op' instead.

data Anchor = Anchor        { Anchor -> RealSrcSpan
anchor :: RealSrcSpan
                                 -- ^ Base location for the start of
                                 -- the syntactic element holding
                                 -- the annotations.
                            , Anchor -> AnchorOperation
anchor_op :: AnchorOperation }
        deriving (Typeable Anchor
Typeable Anchor
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Anchor -> c Anchor)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Anchor)
-> (Anchor -> Constr)
-> (Anchor -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Anchor))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Anchor))
-> ((forall b. Data b => b -> b) -> Anchor -> Anchor)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Anchor -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Anchor -> r)
-> (forall u. (forall d. Data d => d -> u) -> Anchor -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Anchor -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Anchor -> m Anchor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Anchor -> m Anchor)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Anchor -> m Anchor)
-> Data Anchor
Anchor -> DataType
Anchor -> Constr
(forall b. Data b => b -> b) -> Anchor -> Anchor
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Anchor -> u
forall u. (forall d. Data d => d -> u) -> Anchor -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Anchor
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Anchor -> c Anchor
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Anchor)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Anchor)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Anchor -> m Anchor
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Anchor -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Anchor -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Anchor -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Anchor -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Anchor -> r
gmapT :: (forall b. Data b => b -> b) -> Anchor -> Anchor
$cgmapT :: (forall b. Data b => b -> b) -> Anchor -> Anchor
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Anchor)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Anchor)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Anchor)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Anchor)
dataTypeOf :: Anchor -> DataType
$cdataTypeOf :: Anchor -> DataType
toConstr :: Anchor -> Constr
$ctoConstr :: Anchor -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Anchor
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Anchor
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Anchor -> c Anchor
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Anchor -> c Anchor
Data, Anchor -> Anchor -> Bool
(Anchor -> Anchor -> Bool)
-> (Anchor -> Anchor -> Bool) -> Eq Anchor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Anchor -> Anchor -> Bool
$c/= :: Anchor -> Anchor -> Bool
== :: Anchor -> Anchor -> Bool
$c== :: Anchor -> Anchor -> Bool
Eq, Int -> Anchor -> ShowS
[Anchor] -> ShowS
Anchor -> String
(Int -> Anchor -> ShowS)
-> (Anchor -> String) -> ([Anchor] -> ShowS) -> Show Anchor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Anchor] -> ShowS
$cshowList :: [Anchor] -> ShowS
show :: Anchor -> String
$cshow :: Anchor -> String
showsPrec :: Int -> Anchor -> ShowS
$cshowsPrec :: Int -> Anchor -> ShowS
Show)

-- | If tools modify the parsed source, the 'MovedAnchor' variant can
-- directly provide the spacing for this item relative to the previous
-- one when printing. This allows AST fragments with a particular
-- anchor to be freely moved, without worrying about recalculating the
-- appropriate anchor span.
data AnchorOperation = UnchangedAnchor
                     | MovedAnchor DeltaPos
        deriving (Typeable AnchorOperation
Typeable AnchorOperation
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnchorOperation -> c AnchorOperation)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnchorOperation)
-> (AnchorOperation -> Constr)
-> (AnchorOperation -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnchorOperation))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnchorOperation))
-> ((forall b. Data b => b -> b)
    -> AnchorOperation -> AnchorOperation)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> AnchorOperation -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnchorOperation -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> AnchorOperation -> m AnchorOperation)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnchorOperation -> m AnchorOperation)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnchorOperation -> m AnchorOperation)
-> Data AnchorOperation
AnchorOperation -> DataType
AnchorOperation -> Constr
(forall b. Data b => b -> b) -> AnchorOperation -> AnchorOperation
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> AnchorOperation -> u
forall u. (forall d. Data d => d -> u) -> AnchorOperation -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnchorOperation
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnchorOperation -> c AnchorOperation
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnchorOperation)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnchorOperation)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnchorOperation -> m AnchorOperation
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnchorOperation -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnchorOperation -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnchorOperation -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnchorOperation -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnchorOperation -> r
gmapT :: (forall b. Data b => b -> b) -> AnchorOperation -> AnchorOperation
$cgmapT :: (forall b. Data b => b -> b) -> AnchorOperation -> AnchorOperation
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnchorOperation)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnchorOperation)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnchorOperation)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnchorOperation)
dataTypeOf :: AnchorOperation -> DataType
$cdataTypeOf :: AnchorOperation -> DataType
toConstr :: AnchorOperation -> Constr
$ctoConstr :: AnchorOperation -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnchorOperation
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnchorOperation
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnchorOperation -> c AnchorOperation
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnchorOperation -> c AnchorOperation
Data, AnchorOperation -> AnchorOperation -> Bool
(AnchorOperation -> AnchorOperation -> Bool)
-> (AnchorOperation -> AnchorOperation -> Bool)
-> Eq AnchorOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnchorOperation -> AnchorOperation -> Bool
$c/= :: AnchorOperation -> AnchorOperation -> Bool
== :: AnchorOperation -> AnchorOperation -> Bool
$c== :: AnchorOperation -> AnchorOperation -> Bool
Eq, Int -> AnchorOperation -> ShowS
[AnchorOperation] -> ShowS
AnchorOperation -> String
(Int -> AnchorOperation -> ShowS)
-> (AnchorOperation -> String)
-> ([AnchorOperation] -> ShowS)
-> Show AnchorOperation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnchorOperation] -> ShowS
$cshowList :: [AnchorOperation] -> ShowS
show :: AnchorOperation -> String
$cshow :: AnchorOperation -> String
showsPrec :: Int -> AnchorOperation -> ShowS
$cshowsPrec :: Int -> AnchorOperation -> ShowS
Show)


spanAsAnchor :: SrcSpan -> Anchor
spanAsAnchor :: SrcSpan -> Anchor
spanAsAnchor SrcSpan
s  = RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
s) AnchorOperation
UnchangedAnchor

realSpanAsAnchor :: RealSrcSpan -> Anchor
realSpanAsAnchor :: RealSrcSpan -> Anchor
realSpanAsAnchor RealSrcSpan
s  = RealSrcSpan -> AnchorOperation -> Anchor
Anchor RealSrcSpan
s AnchorOperation
UnchangedAnchor

-- ---------------------------------------------------------------------

-- | When we are parsing we add comments that belong a particular AST
-- element, and print them together with the element, interleaving
-- them into the output stream.  But when editing the AST to move
-- fragments around it is useful to be able to first separate the
-- comments into those occuring before the AST element and those
-- following it.  The 'EpaCommentsBalanced' constructor is used to do
-- this. The GHC parser will only insert the 'EpaComments' form.
data EpAnnComments = EpaComments
                        { EpAnnComments -> [LEpaComment]
priorComments :: ![LEpaComment] }
                    | EpaCommentsBalanced
                        { priorComments :: ![LEpaComment]
                        , EpAnnComments -> [LEpaComment]
followingComments :: ![LEpaComment] }
        deriving (Typeable EpAnnComments
Typeable EpAnnComments
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EpAnnComments -> c EpAnnComments)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EpAnnComments)
-> (EpAnnComments -> Constr)
-> (EpAnnComments -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EpAnnComments))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EpAnnComments))
-> ((forall b. Data b => b -> b) -> EpAnnComments -> EpAnnComments)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpAnnComments -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EpAnnComments -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments)
-> Data EpAnnComments
EpAnnComments -> DataType
EpAnnComments -> Constr
(forall b. Data b => b -> b) -> EpAnnComments -> EpAnnComments
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EpAnnComments -> u
forall u. (forall d. Data d => d -> u) -> EpAnnComments -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnComments
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnComments -> c EpAnnComments
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnComments)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnComments)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnComments -> m EpAnnComments
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpAnnComments -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpAnnComments -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnComments -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnComments -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnComments -> r
gmapT :: (forall b. Data b => b -> b) -> EpAnnComments -> EpAnnComments
$cgmapT :: (forall b. Data b => b -> b) -> EpAnnComments -> EpAnnComments
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnComments)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnComments)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnComments)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnComments)
dataTypeOf :: EpAnnComments -> DataType
$cdataTypeOf :: EpAnnComments -> DataType
toConstr :: EpAnnComments -> Constr
$ctoConstr :: EpAnnComments -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnComments
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnComments
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnComments -> c EpAnnComments
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnComments -> c EpAnnComments
Data, EpAnnComments -> EpAnnComments -> Bool
(EpAnnComments -> EpAnnComments -> Bool)
-> (EpAnnComments -> EpAnnComments -> Bool) -> Eq EpAnnComments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpAnnComments -> EpAnnComments -> Bool
$c/= :: EpAnnComments -> EpAnnComments -> Bool
== :: EpAnnComments -> EpAnnComments -> Bool
$c== :: EpAnnComments -> EpAnnComments -> Bool
Eq)

type LEpaComment = GenLocated Anchor EpaComment

emptyComments :: EpAnnComments
emptyComments :: EpAnnComments
emptyComments = [LEpaComment] -> EpAnnComments
EpaComments []

-- ---------------------------------------------------------------------
-- Annotations attached to a 'SrcSpan'.
-- ---------------------------------------------------------------------

-- | The 'SrcSpanAnn\'' type wraps a normal 'SrcSpan', together with
-- an extra annotation type. This is mapped to a specific `GenLocated`
-- usage in the AST through the `XRec` and `Anno` type families.
data SrcSpanAnn' a = SrcSpanAnn { forall a. SrcSpanAnn' a -> a
ann :: a, forall a. SrcSpanAnn' a -> SrcSpan
locA :: SrcSpan }
        deriving (Typeable (SrcSpanAnn' a)
Typeable (SrcSpanAnn' a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SrcSpanAnn' a -> c (SrcSpanAnn' a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (SrcSpanAnn' a))
-> (SrcSpanAnn' a -> Constr)
-> (SrcSpanAnn' a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (SrcSpanAnn' a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (SrcSpanAnn' a)))
-> ((forall b. Data b => b -> b) -> SrcSpanAnn' a -> SrcSpanAnn' a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r)
-> (forall u. (forall d. Data d => d -> u) -> SrcSpanAnn' a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SrcSpanAnn' a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> SrcSpanAnn' a -> m (SrcSpanAnn' a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SrcSpanAnn' a -> m (SrcSpanAnn' a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SrcSpanAnn' a -> m (SrcSpanAnn' a))
-> Data (SrcSpanAnn' a)
SrcSpanAnn' a -> DataType
SrcSpanAnn' a -> Constr
(forall b. Data b => b -> b) -> SrcSpanAnn' a -> SrcSpanAnn' a
forall {a}. Data a => Typeable (SrcSpanAnn' a)
forall a. Data a => SrcSpanAnn' a -> DataType
forall a. Data a => SrcSpanAnn' a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> SrcSpanAnn' a -> SrcSpanAnn' a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SrcSpanAnn' a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> SrcSpanAnn' a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SrcSpanAnn' a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SrcSpanAnn' a -> c (SrcSpanAnn' a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SrcSpanAnn' a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SrcSpanAnn' a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SrcSpanAnn' a -> u
forall u. (forall d. Data d => d -> u) -> SrcSpanAnn' a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SrcSpanAnn' a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SrcSpanAnn' a -> c (SrcSpanAnn' a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (SrcSpanAnn' a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SrcSpanAnn' a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> SrcSpanAnn' a -> m (SrcSpanAnn' a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SrcSpanAnn' a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SrcSpanAnn' a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> SrcSpanAnn' a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> SrcSpanAnn' a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SrcSpanAnn' a -> r
gmapT :: (forall b. Data b => b -> b) -> SrcSpanAnn' a -> SrcSpanAnn' a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> SrcSpanAnn' a -> SrcSpanAnn' a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SrcSpanAnn' a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SrcSpanAnn' a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (SrcSpanAnn' a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SrcSpanAnn' a))
dataTypeOf :: SrcSpanAnn' a -> DataType
$cdataTypeOf :: forall a. Data a => SrcSpanAnn' a -> DataType
toConstr :: SrcSpanAnn' a -> Constr
$ctoConstr :: forall a. Data a => SrcSpanAnn' a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SrcSpanAnn' a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SrcSpanAnn' a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SrcSpanAnn' a -> c (SrcSpanAnn' a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SrcSpanAnn' a -> c (SrcSpanAnn' a)
Data, SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
(SrcSpanAnn' a -> SrcSpanAnn' a -> Bool)
-> (SrcSpanAnn' a -> SrcSpanAnn' a -> Bool) -> Eq (SrcSpanAnn' a)
forall a. Eq a => SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
$c/= :: forall a. Eq a => SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
== :: SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
$c== :: forall a. Eq a => SrcSpanAnn' a -> SrcSpanAnn' a -> Bool
Eq)
-- See Note [XRec and Anno in the AST]

-- | We mostly use 'SrcSpanAnn\'' with an 'EpAnn\''
type SrcAnn ann = SrcSpanAnn' (EpAnn ann)

type LocatedA = GenLocated SrcSpanAnnA
type LocatedN = GenLocated SrcSpanAnnN

type LocatedL = GenLocated SrcSpanAnnL
type LocatedP = GenLocated SrcSpanAnnP
type LocatedC = GenLocated SrcSpanAnnC

type SrcSpanAnnA = SrcAnn AnnListItem
type SrcSpanAnnN = SrcAnn NameAnn

type SrcSpanAnnL = SrcAnn AnnList
type SrcSpanAnnP = SrcAnn AnnPragma
type SrcSpanAnnC = SrcAnn AnnContext

-- | General representation of a 'GenLocated' type carrying a
-- parameterised annotation type.
type LocatedAn an = GenLocated (SrcAnn an)

{-
Note [XRec and Anno in the AST]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The exact print annotations are captured directly inside the AST, using
TTG extension points. However certain annotations need to be captured
on the Located versions too.  While there is a general form for these,
captured in the type SrcSpanAnn', there are also specific usages in
different contexts.

Some of the particular use cases are

1) RdrNames, which can have additional items such as backticks or parens

2) Items which occur in lists, and the annotation relates purely
to its usage inside a list.

See the section above this note for the rest.

The Anno type family maps the specific SrcSpanAnn' variant for a given
item.

So

  type instance XRec (GhcPass p) a = GenLocated (Anno a) a
  type instance Anno RdrName = SrcSpanAnnN
  type LocatedN = GenLocated SrcSpanAnnN

meaning we can have type LocatedN RdrName

-}

-- ---------------------------------------------------------------------
-- Annotations for items in a list
-- ---------------------------------------------------------------------

-- | Captures the location of punctuation occuring between items,
-- normally in a list.  It is captured as a trailing annotation.
data TrailingAnn
  = AddSemiAnn EpaLocation    -- ^ Trailing ';'
  | AddCommaAnn EpaLocation   -- ^ Trailing ','
  | AddVbarAnn EpaLocation    -- ^ Trailing '|'
  | AddRarrowAnn EpaLocation  -- ^ Trailing '->'
  | AddRarrowAnnU EpaLocation -- ^ Trailing '->', unicode variant
  | AddLollyAnnU EpaLocation  -- ^ Trailing '⊸'
  deriving (Typeable TrailingAnn
Typeable TrailingAnn
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TrailingAnn -> c TrailingAnn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TrailingAnn)
-> (TrailingAnn -> Constr)
-> (TrailingAnn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TrailingAnn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c TrailingAnn))
-> ((forall b. Data b => b -> b) -> TrailingAnn -> TrailingAnn)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r)
-> (forall u. (forall d. Data d => d -> u) -> TrailingAnn -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TrailingAnn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn)
-> Data TrailingAnn
TrailingAnn -> DataType
TrailingAnn -> Constr
(forall b. Data b => b -> b) -> TrailingAnn -> TrailingAnn
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TrailingAnn -> u
forall u. (forall d. Data d => d -> u) -> TrailingAnn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TrailingAnn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TrailingAnn -> c TrailingAnn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TrailingAnn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TrailingAnn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TrailingAnn -> m TrailingAnn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TrailingAnn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TrailingAnn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TrailingAnn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TrailingAnn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TrailingAnn -> r
gmapT :: (forall b. Data b => b -> b) -> TrailingAnn -> TrailingAnn
$cgmapT :: (forall b. Data b => b -> b) -> TrailingAnn -> TrailingAnn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TrailingAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TrailingAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TrailingAnn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TrailingAnn)
dataTypeOf :: TrailingAnn -> DataType
$cdataTypeOf :: TrailingAnn -> DataType
toConstr :: TrailingAnn -> Constr
$ctoConstr :: TrailingAnn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TrailingAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TrailingAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TrailingAnn -> c TrailingAnn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TrailingAnn -> c TrailingAnn
Data,TrailingAnn -> TrailingAnn -> Bool
(TrailingAnn -> TrailingAnn -> Bool)
-> (TrailingAnn -> TrailingAnn -> Bool) -> Eq TrailingAnn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrailingAnn -> TrailingAnn -> Bool
$c/= :: TrailingAnn -> TrailingAnn -> Bool
== :: TrailingAnn -> TrailingAnn -> Bool
$c== :: TrailingAnn -> TrailingAnn -> Bool
Eq, Eq TrailingAnn
Eq TrailingAnn
-> (TrailingAnn -> TrailingAnn -> Ordering)
-> (TrailingAnn -> TrailingAnn -> Bool)
-> (TrailingAnn -> TrailingAnn -> Bool)
-> (TrailingAnn -> TrailingAnn -> Bool)
-> (TrailingAnn -> TrailingAnn -> Bool)
-> (TrailingAnn -> TrailingAnn -> TrailingAnn)
-> (TrailingAnn -> TrailingAnn -> TrailingAnn)
-> Ord TrailingAnn
TrailingAnn -> TrailingAnn -> Bool
TrailingAnn -> TrailingAnn -> Ordering
TrailingAnn -> TrailingAnn -> TrailingAnn
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TrailingAnn -> TrailingAnn -> TrailingAnn
$cmin :: TrailingAnn -> TrailingAnn -> TrailingAnn
max :: TrailingAnn -> TrailingAnn -> TrailingAnn
$cmax :: TrailingAnn -> TrailingAnn -> TrailingAnn
>= :: TrailingAnn -> TrailingAnn -> Bool
$c>= :: TrailingAnn -> TrailingAnn -> Bool
> :: TrailingAnn -> TrailingAnn -> Bool
$c> :: TrailingAnn -> TrailingAnn -> Bool
<= :: TrailingAnn -> TrailingAnn -> Bool
$c<= :: TrailingAnn -> TrailingAnn -> Bool
< :: TrailingAnn -> TrailingAnn -> Bool
$c< :: TrailingAnn -> TrailingAnn -> Bool
compare :: TrailingAnn -> TrailingAnn -> Ordering
$ccompare :: TrailingAnn -> TrailingAnn -> Ordering
Ord)

instance Outputable TrailingAnn where
  ppr :: TrailingAnn -> SDoc
ppr (AddSemiAnn EpaLocation
ss)    = String -> SDoc
text String
"AddSemiAnn"    SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss
  ppr (AddCommaAnn EpaLocation
ss)   = String -> SDoc
text String
"AddCommaAnn"   SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss
  ppr (AddVbarAnn EpaLocation
ss)    = String -> SDoc
text String
"AddVbarAnn"    SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss
  ppr (AddRarrowAnn EpaLocation
ss)  = String -> SDoc
text String
"AddRarrowAnn"  SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss
  ppr (AddRarrowAnnU EpaLocation
ss) = String -> SDoc
text String
"AddRarrowAnnU" SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss
  ppr (AddLollyAnnU EpaLocation
ss)  = String -> SDoc
text String
"AddLollyAnnU"  SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
ss

-- | Annotation for items appearing in a list. They can have one or
-- more trailing punctuations items, such as commas or semicolons.
data AnnListItem
  = AnnListItem {
      AnnListItem -> [TrailingAnn]
lann_trailing  :: [TrailingAnn]
      }
  deriving (Typeable AnnListItem
Typeable AnnListItem
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnListItem -> c AnnListItem)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnListItem)
-> (AnnListItem -> Constr)
-> (AnnListItem -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnListItem))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnListItem))
-> ((forall b. Data b => b -> b) -> AnnListItem -> AnnListItem)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnListItem -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnListItem -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnListItem -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnListItem -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem)
-> Data AnnListItem
AnnListItem -> DataType
AnnListItem -> Constr
(forall b. Data b => b -> b) -> AnnListItem -> AnnListItem
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnListItem -> u
forall u. (forall d. Data d => d -> u) -> AnnListItem -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnListItem
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnListItem -> c AnnListItem
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnListItem)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnListItem)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnListItem -> m AnnListItem
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnListItem -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnListItem -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnListItem -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnListItem -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnListItem -> r
gmapT :: (forall b. Data b => b -> b) -> AnnListItem -> AnnListItem
$cgmapT :: (forall b. Data b => b -> b) -> AnnListItem -> AnnListItem
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnListItem)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnListItem)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnListItem)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnListItem)
dataTypeOf :: AnnListItem -> DataType
$cdataTypeOf :: AnnListItem -> DataType
toConstr :: AnnListItem -> Constr
$ctoConstr :: AnnListItem -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnListItem
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnListItem
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnListItem -> c AnnListItem
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnListItem -> c AnnListItem
Data, AnnListItem -> AnnListItem -> Bool
(AnnListItem -> AnnListItem -> Bool)
-> (AnnListItem -> AnnListItem -> Bool) -> Eq AnnListItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnListItem -> AnnListItem -> Bool
$c/= :: AnnListItem -> AnnListItem -> Bool
== :: AnnListItem -> AnnListItem -> Bool
$c== :: AnnListItem -> AnnListItem -> Bool
Eq)

-- ---------------------------------------------------------------------
-- Annotations for the context of a list of items
-- ---------------------------------------------------------------------

-- | Annotation for the "container" of a list. This captures
-- surrounding items such as braces if present, and introductory
-- keywords such as 'where'.
data AnnList
  = AnnList {
      AnnList -> Maybe Anchor
al_anchor    :: Maybe Anchor, -- ^ start point of a list having layout
      AnnList -> Maybe AddEpAnn
al_open      :: Maybe AddEpAnn,
      AnnList -> Maybe AddEpAnn
al_close     :: Maybe AddEpAnn,
      AnnList -> [AddEpAnn]
al_rest      :: [AddEpAnn], -- ^ context, such as 'where' keyword
      AnnList -> [TrailingAnn]
al_trailing  :: [TrailingAnn] -- ^ items appearing after the
                                    -- list, such as '=>' for a
                                    -- context
      } deriving (Typeable AnnList
Typeable AnnList
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnList -> c AnnList)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnList)
-> (AnnList -> Constr)
-> (AnnList -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnList))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnList))
-> ((forall b. Data b => b -> b) -> AnnList -> AnnList)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnList -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnList -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnList -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> AnnList -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnList -> m AnnList)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnList -> m AnnList)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnList -> m AnnList)
-> Data AnnList
AnnList -> DataType
AnnList -> Constr
(forall b. Data b => b -> b) -> AnnList -> AnnList
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnList -> u
forall u. (forall d. Data d => d -> u) -> AnnList -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnList
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnList -> c AnnList
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnList)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnList)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnList -> m AnnList
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnList -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnList -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnList -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnList -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnList -> r
gmapT :: (forall b. Data b => b -> b) -> AnnList -> AnnList
$cgmapT :: (forall b. Data b => b -> b) -> AnnList -> AnnList
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnList)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnList)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnList)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnList)
dataTypeOf :: AnnList -> DataType
$cdataTypeOf :: AnnList -> DataType
toConstr :: AnnList -> Constr
$ctoConstr :: AnnList -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnList
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnList
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnList -> c AnnList
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnList -> c AnnList
Data,AnnList -> AnnList -> Bool
(AnnList -> AnnList -> Bool)
-> (AnnList -> AnnList -> Bool) -> Eq AnnList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnList -> AnnList -> Bool
$c/= :: AnnList -> AnnList -> Bool
== :: AnnList -> AnnList -> Bool
$c== :: AnnList -> AnnList -> Bool
Eq)

-- ---------------------------------------------------------------------
-- Annotations for parenthesised elements, such as tuples, lists
-- ---------------------------------------------------------------------

-- | exact print annotation for an item having surrounding "brackets", such as
-- tuples or lists
data AnnParen
  = AnnParen {
      AnnParen -> ParenType
ap_adornment :: ParenType,
      AnnParen -> EpaLocation
ap_open      :: EpaLocation,
      AnnParen -> EpaLocation
ap_close     :: EpaLocation
      } deriving (Typeable AnnParen
Typeable AnnParen
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnParen -> c AnnParen)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnParen)
-> (AnnParen -> Constr)
-> (AnnParen -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnParen))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnParen))
-> ((forall b. Data b => b -> b) -> AnnParen -> AnnParen)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnParen -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnParen -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnParen -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> AnnParen -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnParen -> m AnnParen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnParen -> m AnnParen)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnParen -> m AnnParen)
-> Data AnnParen
AnnParen -> DataType
AnnParen -> Constr
(forall b. Data b => b -> b) -> AnnParen -> AnnParen
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnParen -> u
forall u. (forall d. Data d => d -> u) -> AnnParen -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnParen
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnParen -> c AnnParen
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnParen)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnParen)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnParen -> m AnnParen
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnParen -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnParen -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnParen -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnParen -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnParen -> r
gmapT :: (forall b. Data b => b -> b) -> AnnParen -> AnnParen
$cgmapT :: (forall b. Data b => b -> b) -> AnnParen -> AnnParen
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnParen)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnParen)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnParen)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnParen)
dataTypeOf :: AnnParen -> DataType
$cdataTypeOf :: AnnParen -> DataType
toConstr :: AnnParen -> Constr
$ctoConstr :: AnnParen -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnParen
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnParen
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnParen -> c AnnParen
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnParen -> c AnnParen
Data)

-- | Detail of the "brackets" used in an 'AnnParen' exact print annotation.
data ParenType
  = AnnParens       -- ^ '(', ')'
  | AnnParensHash   -- ^ '(#', '#)'
  | AnnParensSquare -- ^ '[', ']'
  deriving (ParenType -> ParenType -> Bool
(ParenType -> ParenType -> Bool)
-> (ParenType -> ParenType -> Bool) -> Eq ParenType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParenType -> ParenType -> Bool
$c/= :: ParenType -> ParenType -> Bool
== :: ParenType -> ParenType -> Bool
$c== :: ParenType -> ParenType -> Bool
Eq, Eq ParenType
Eq ParenType
-> (ParenType -> ParenType -> Ordering)
-> (ParenType -> ParenType -> Bool)
-> (ParenType -> ParenType -> Bool)
-> (ParenType -> ParenType -> Bool)
-> (ParenType -> ParenType -> Bool)
-> (ParenType -> ParenType -> ParenType)
-> (ParenType -> ParenType -> ParenType)
-> Ord ParenType
ParenType -> ParenType -> Bool
ParenType -> ParenType -> Ordering
ParenType -> ParenType -> ParenType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ParenType -> ParenType -> ParenType
$cmin :: ParenType -> ParenType -> ParenType
max :: ParenType -> ParenType -> ParenType
$cmax :: ParenType -> ParenType -> ParenType
>= :: ParenType -> ParenType -> Bool
$c>= :: ParenType -> ParenType -> Bool
> :: ParenType -> ParenType -> Bool
$c> :: ParenType -> ParenType -> Bool
<= :: ParenType -> ParenType -> Bool
$c<= :: ParenType -> ParenType -> Bool
< :: ParenType -> ParenType -> Bool
$c< :: ParenType -> ParenType -> Bool
compare :: ParenType -> ParenType -> Ordering
$ccompare :: ParenType -> ParenType -> Ordering
Ord, Typeable ParenType
Typeable ParenType
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ParenType -> c ParenType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ParenType)
-> (ParenType -> Constr)
-> (ParenType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ParenType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ParenType))
-> ((forall b. Data b => b -> b) -> ParenType -> ParenType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ParenType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ParenType -> r)
-> (forall u. (forall d. Data d => d -> u) -> ParenType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ParenType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ParenType -> m ParenType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ParenType -> m ParenType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ParenType -> m ParenType)
-> Data ParenType
ParenType -> DataType
ParenType -> Constr
(forall b. Data b => b -> b) -> ParenType -> ParenType
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ParenType -> u
forall u. (forall d. Data d => d -> u) -> ParenType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ParenType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ParenType -> c ParenType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ParenType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ParenType)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ParenType -> m ParenType
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ParenType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ParenType -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ParenType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ParenType -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ParenType -> r
gmapT :: (forall b. Data b => b -> b) -> ParenType -> ParenType
$cgmapT :: (forall b. Data b => b -> b) -> ParenType -> ParenType
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ParenType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ParenType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ParenType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ParenType)
dataTypeOf :: ParenType -> DataType
$cdataTypeOf :: ParenType -> DataType
toConstr :: ParenType -> Constr
$ctoConstr :: ParenType -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ParenType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ParenType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ParenType -> c ParenType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ParenType -> c ParenType
Data)

-- | Maps the 'ParenType' to the related opening and closing
-- AnnKeywordId. Used when actually printing the item.
parenTypeKws :: ParenType -> (AnnKeywordId, AnnKeywordId)
parenTypeKws :: ParenType -> (AnnKeywordId, AnnKeywordId)
parenTypeKws ParenType
AnnParens       = (AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP)
parenTypeKws ParenType
AnnParensHash   = (AnnKeywordId
AnnOpenPH, AnnKeywordId
AnnClosePH)
parenTypeKws ParenType
AnnParensSquare = (AnnKeywordId
AnnOpenS, AnnKeywordId
AnnCloseS)

-- ---------------------------------------------------------------------

-- | Exact print annotation for the 'Context' data type.
data AnnContext
  = AnnContext {
      AnnContext -> Maybe (IsUnicodeSyntax, EpaLocation)
ac_darrow    :: Maybe (IsUnicodeSyntax, EpaLocation),
                      -- ^ location and encoding of the '=>', if present.
      AnnContext -> [EpaLocation]
ac_open      :: [EpaLocation], -- ^ zero or more opening parentheses.
      AnnContext -> [EpaLocation]
ac_close     :: [EpaLocation]  -- ^ zero or more closing parentheses.
      } deriving (Typeable AnnContext
Typeable AnnContext
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnContext -> c AnnContext)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnContext)
-> (AnnContext -> Constr)
-> (AnnContext -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnContext))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnContext))
-> ((forall b. Data b => b -> b) -> AnnContext -> AnnContext)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnContext -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnContext -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnContext -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnContext -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnContext -> m AnnContext)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnContext -> m AnnContext)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnContext -> m AnnContext)
-> Data AnnContext
AnnContext -> DataType
AnnContext -> Constr
(forall b. Data b => b -> b) -> AnnContext -> AnnContext
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnContext -> u
forall u. (forall d. Data d => d -> u) -> AnnContext -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnContext
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnContext -> c AnnContext
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnContext)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnContext)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnContext -> m AnnContext
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnContext -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnContext -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnContext -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnContext -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnContext -> r
gmapT :: (forall b. Data b => b -> b) -> AnnContext -> AnnContext
$cgmapT :: (forall b. Data b => b -> b) -> AnnContext -> AnnContext
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnContext)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnContext)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnContext)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnContext)
dataTypeOf :: AnnContext -> DataType
$cdataTypeOf :: AnnContext -> DataType
toConstr :: AnnContext -> Constr
$ctoConstr :: AnnContext -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnContext
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnContext
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnContext -> c AnnContext
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnContext -> c AnnContext
Data)


-- ---------------------------------------------------------------------
-- Annotations for names
-- ---------------------------------------------------------------------

-- | exact print annotations for a 'RdrName'.  There are many kinds of
-- adornment that can be attached to a given 'RdrName'. This type
-- captures them, as detailed on the individual constructors.
data NameAnn
  -- | Used for a name with an adornment, so '`foo`', '(bar)'
  = NameAnn {
      NameAnn -> NameAdornment
nann_adornment :: NameAdornment,
      NameAnn -> EpaLocation
nann_open      :: EpaLocation,
      NameAnn -> EpaLocation
nann_name      :: EpaLocation,
      NameAnn -> EpaLocation
nann_close     :: EpaLocation,
      NameAnn -> [TrailingAnn]
nann_trailing  :: [TrailingAnn]
      }
  -- | Used for @(,,,)@, or @(#,,,#)#
  | NameAnnCommas {
      nann_adornment :: NameAdornment,
      nann_open      :: EpaLocation,
      NameAnn -> [EpaLocation]
nann_commas    :: [EpaLocation],
      nann_close     :: EpaLocation,
      nann_trailing  :: [TrailingAnn]
      }
  -- | Used for @()@, @(##)@, @[]@
  | NameAnnOnly {
      nann_adornment :: NameAdornment,
      nann_open      :: EpaLocation,
      nann_close     :: EpaLocation,
      nann_trailing  :: [TrailingAnn]
      }
  -- | Used for @->@, as an identifier
  | NameAnnRArrow {
      nann_name      :: EpaLocation,
      nann_trailing  :: [TrailingAnn]
      }
  -- | Used for an item with a leading @'@. The annotation for
  -- unquoted item is stored in 'nann_quoted'.
  | NameAnnQuote {
      NameAnn -> EpaLocation
nann_quote     :: EpaLocation,
      NameAnn -> SrcSpanAnnN
nann_quoted    :: SrcSpanAnnN,
      nann_trailing  :: [TrailingAnn]
      }
  -- | Used when adding a 'TrailingAnn' to an existing 'LocatedN'
  -- which has no Api Annotation (via the 'EpAnnNotUsed' constructor.
  | NameAnnTrailing {
      nann_trailing  :: [TrailingAnn]
      }
  deriving (Typeable NameAnn
Typeable NameAnn
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NameAnn -> c NameAnn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NameAnn)
-> (NameAnn -> Constr)
-> (NameAnn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NameAnn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameAnn))
-> ((forall b. Data b => b -> b) -> NameAnn -> NameAnn)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NameAnn -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NameAnn -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameAnn -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NameAnn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NameAnn -> m NameAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NameAnn -> m NameAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NameAnn -> m NameAnn)
-> Data NameAnn
NameAnn -> DataType
NameAnn -> Constr
(forall b. Data b => b -> b) -> NameAnn -> NameAnn
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameAnn -> u
forall u. (forall d. Data d => d -> u) -> NameAnn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAnn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAnn -> c NameAnn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAnn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameAnn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAnn -> m NameAnn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameAnn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameAnn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NameAnn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameAnn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAnn -> r
gmapT :: (forall b. Data b => b -> b) -> NameAnn -> NameAnn
$cgmapT :: (forall b. Data b => b -> b) -> NameAnn -> NameAnn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAnn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAnn)
dataTypeOf :: NameAnn -> DataType
$cdataTypeOf :: NameAnn -> DataType
toConstr :: NameAnn -> Constr
$ctoConstr :: NameAnn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAnn -> c NameAnn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAnn -> c NameAnn
Data, NameAnn -> NameAnn -> Bool
(NameAnn -> NameAnn -> Bool)
-> (NameAnn -> NameAnn -> Bool) -> Eq NameAnn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NameAnn -> NameAnn -> Bool
$c/= :: NameAnn -> NameAnn -> Bool
== :: NameAnn -> NameAnn -> Bool
$c== :: NameAnn -> NameAnn -> Bool
Eq)

-- | A 'NameAnn' can capture the locations of surrounding adornments,
-- such as parens or backquotes. This data type identifies what
-- particular pair are being used.
data NameAdornment
  = NameParens -- ^ '(' ')'
  | NameParensHash -- ^ '(#' '#)'
  | NameBackquotes -- ^ '`'
  | NameSquare -- ^ '[' ']'
  deriving (NameAdornment -> NameAdornment -> Bool
(NameAdornment -> NameAdornment -> Bool)
-> (NameAdornment -> NameAdornment -> Bool) -> Eq NameAdornment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NameAdornment -> NameAdornment -> Bool
$c/= :: NameAdornment -> NameAdornment -> Bool
== :: NameAdornment -> NameAdornment -> Bool
$c== :: NameAdornment -> NameAdornment -> Bool
Eq, Eq NameAdornment
Eq NameAdornment
-> (NameAdornment -> NameAdornment -> Ordering)
-> (NameAdornment -> NameAdornment -> Bool)
-> (NameAdornment -> NameAdornment -> Bool)
-> (NameAdornment -> NameAdornment -> Bool)
-> (NameAdornment -> NameAdornment -> Bool)
-> (NameAdornment -> NameAdornment -> NameAdornment)
-> (NameAdornment -> NameAdornment -> NameAdornment)
-> Ord NameAdornment
NameAdornment -> NameAdornment -> Bool
NameAdornment -> NameAdornment -> Ordering
NameAdornment -> NameAdornment -> NameAdornment
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NameAdornment -> NameAdornment -> NameAdornment
$cmin :: NameAdornment -> NameAdornment -> NameAdornment
max :: NameAdornment -> NameAdornment -> NameAdornment
$cmax :: NameAdornment -> NameAdornment -> NameAdornment
>= :: NameAdornment -> NameAdornment -> Bool
$c>= :: NameAdornment -> NameAdornment -> Bool
> :: NameAdornment -> NameAdornment -> Bool
$c> :: NameAdornment -> NameAdornment -> Bool
<= :: NameAdornment -> NameAdornment -> Bool
$c<= :: NameAdornment -> NameAdornment -> Bool
< :: NameAdornment -> NameAdornment -> Bool
$c< :: NameAdornment -> NameAdornment -> Bool
compare :: NameAdornment -> NameAdornment -> Ordering
$ccompare :: NameAdornment -> NameAdornment -> Ordering
Ord, Typeable NameAdornment
Typeable NameAdornment
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NameAdornment -> c NameAdornment)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NameAdornment)
-> (NameAdornment -> Constr)
-> (NameAdornment -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NameAdornment))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c NameAdornment))
-> ((forall b. Data b => b -> b) -> NameAdornment -> NameAdornment)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NameAdornment -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NameAdornment -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameAdornment -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> NameAdornment -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment)
-> Data NameAdornment
NameAdornment -> DataType
NameAdornment -> Constr
(forall b. Data b => b -> b) -> NameAdornment -> NameAdornment
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameAdornment -> u
forall u. (forall d. Data d => d -> u) -> NameAdornment -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAdornment
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAdornment -> c NameAdornment
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAdornment)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameAdornment)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameAdornment -> m NameAdornment
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameAdornment -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameAdornment -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NameAdornment -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameAdornment -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameAdornment -> r
gmapT :: (forall b. Data b => b -> b) -> NameAdornment -> NameAdornment
$cgmapT :: (forall b. Data b => b -> b) -> NameAdornment -> NameAdornment
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameAdornment)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameAdornment)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAdornment)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameAdornment)
dataTypeOf :: NameAdornment -> DataType
$cdataTypeOf :: NameAdornment -> DataType
toConstr :: NameAdornment -> Constr
$ctoConstr :: NameAdornment -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAdornment
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameAdornment
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAdornment -> c NameAdornment
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameAdornment -> c NameAdornment
Data)

-- ---------------------------------------------------------------------

-- | exact print annotation used for capturing the locations of
-- annotations in pragmas.
data AnnPragma
  = AnnPragma {
      AnnPragma -> AddEpAnn
apr_open      :: AddEpAnn,
      AnnPragma -> AddEpAnn
apr_close     :: AddEpAnn,
      AnnPragma -> [AddEpAnn]
apr_rest      :: [AddEpAnn]
      } deriving (Typeable AnnPragma
Typeable AnnPragma
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnPragma -> c AnnPragma)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnPragma)
-> (AnnPragma -> Constr)
-> (AnnPragma -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnPragma))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnPragma))
-> ((forall b. Data b => b -> b) -> AnnPragma -> AnnPragma)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnPragma -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnPragma -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnPragma -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnPragma -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma)
-> Data AnnPragma
AnnPragma -> DataType
AnnPragma -> Constr
(forall b. Data b => b -> b) -> AnnPragma -> AnnPragma
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnPragma -> u
forall u. (forall d. Data d => d -> u) -> AnnPragma -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnPragma
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnPragma -> c AnnPragma
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnPragma)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnPragma)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnPragma -> m AnnPragma
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnPragma -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnPragma -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnPragma -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnPragma -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnPragma -> r
gmapT :: (forall b. Data b => b -> b) -> AnnPragma -> AnnPragma
$cgmapT :: (forall b. Data b => b -> b) -> AnnPragma -> AnnPragma
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnPragma)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnPragma)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnPragma)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnPragma)
dataTypeOf :: AnnPragma -> DataType
$cdataTypeOf :: AnnPragma -> DataType
toConstr :: AnnPragma -> Constr
$ctoConstr :: AnnPragma -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnPragma
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnPragma
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnPragma -> c AnnPragma
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnPragma -> c AnnPragma
Data,AnnPragma -> AnnPragma -> Bool
(AnnPragma -> AnnPragma -> Bool)
-> (AnnPragma -> AnnPragma -> Bool) -> Eq AnnPragma
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnPragma -> AnnPragma -> Bool
$c/= :: AnnPragma -> AnnPragma -> Bool
== :: AnnPragma -> AnnPragma -> Bool
$c== :: AnnPragma -> AnnPragma -> Bool
Eq)

-- ---------------------------------------------------------------------
-- | 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.
data AnnSortKey
  = NoAnnSortKey
  | AnnSortKey [RealSrcSpan]
  deriving (Typeable AnnSortKey
Typeable AnnSortKey
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AnnSortKey -> c AnnSortKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnSortKey)
-> (AnnSortKey -> Constr)
-> (AnnSortKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnSortKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnSortKey))
-> ((forall b. Data b => b -> b) -> AnnSortKey -> AnnSortKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnSortKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnSortKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey)
-> Data AnnSortKey
AnnSortKey -> DataType
AnnSortKey -> Constr
(forall b. Data b => b -> b) -> AnnSortKey -> AnnSortKey
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnSortKey -> u
forall u. (forall d. Data d => d -> u) -> AnnSortKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSortKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSortKey -> c AnnSortKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSortKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSortKey)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSortKey -> m AnnSortKey
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSortKey -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSortKey -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSortKey -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSortKey -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSortKey -> r
gmapT :: (forall b. Data b => b -> b) -> AnnSortKey -> AnnSortKey
$cgmapT :: (forall b. Data b => b -> b) -> AnnSortKey -> AnnSortKey
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSortKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSortKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSortKey)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSortKey)
dataTypeOf :: AnnSortKey -> DataType
$cdataTypeOf :: AnnSortKey -> DataType
toConstr :: AnnSortKey -> Constr
$ctoConstr :: AnnSortKey -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSortKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSortKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSortKey -> c AnnSortKey
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSortKey -> c AnnSortKey
Data, AnnSortKey -> AnnSortKey -> Bool
(AnnSortKey -> AnnSortKey -> Bool)
-> (AnnSortKey -> AnnSortKey -> Bool) -> Eq AnnSortKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnSortKey -> AnnSortKey -> Bool
$c/= :: AnnSortKey -> AnnSortKey -> Bool
== :: AnnSortKey -> AnnSortKey -> Bool
$c== :: AnnSortKey -> AnnSortKey -> Bool
Eq)

-- ---------------------------------------------------------------------


-- | Helper function used in the parser to add a 'TrailingAnn' items
-- to an existing annotation.
addTrailingAnnToL :: SrcSpan -> TrailingAnn -> EpAnnComments
                  -> EpAnn AnnList -> EpAnn AnnList
addTrailingAnnToL :: SrcSpan
-> TrailingAnn -> EpAnnComments -> EpAnn AnnList -> EpAnn AnnList
addTrailingAnnToL SrcSpan
s TrailingAnn
t EpAnnComments
cs EpAnn AnnList
EpAnnNotUsed
  = Anchor -> AnnList -> EpAnnComments -> EpAnn AnnList
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
s) (Maybe Anchor
-> Maybe AddEpAnn
-> Maybe AddEpAnn
-> [AddEpAnn]
-> [TrailingAnn]
-> AnnList
AnnList (Anchor -> Maybe Anchor
forall a. a -> Maybe a
Just (Anchor -> Maybe Anchor) -> Anchor -> Maybe Anchor
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Anchor
spanAsAnchor SrcSpan
s) Maybe AddEpAnn
forall a. Maybe a
Nothing Maybe AddEpAnn
forall a. Maybe a
Nothing [] [TrailingAnn
t]) EpAnnComments
cs
addTrailingAnnToL SrcSpan
_ TrailingAnn
t EpAnnComments
cs EpAnn AnnList
n = EpAnn AnnList
n { anns :: AnnList
anns = AnnList -> AnnList
addTrailing (EpAnn AnnList -> AnnList
forall ann. EpAnn ann -> ann
anns EpAnn AnnList
n)
                               , comments :: EpAnnComments
comments = EpAnn AnnList -> EpAnnComments
forall ann. EpAnn ann -> EpAnnComments
comments EpAnn AnnList
n EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs }
  where
    -- See Note [list append in addTrailing*]
    addTrailing :: AnnList -> AnnList
addTrailing AnnList
n = AnnList
n { al_trailing :: [TrailingAnn]
al_trailing = AnnList -> [TrailingAnn]
al_trailing AnnList
n [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. [a] -> [a] -> [a]
++ [TrailingAnn
t]}

-- | Helper function used in the parser to add a 'TrailingAnn' items
-- to an existing annotation.
addTrailingAnnToA :: SrcSpan -> TrailingAnn -> EpAnnComments
                  -> EpAnn AnnListItem -> EpAnn AnnListItem
addTrailingAnnToA :: SrcSpan
-> TrailingAnn
-> EpAnnComments
-> EpAnn AnnListItem
-> EpAnn AnnListItem
addTrailingAnnToA SrcSpan
s TrailingAnn
t EpAnnComments
cs EpAnn AnnListItem
EpAnnNotUsed
  = Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
s) ([TrailingAnn] -> AnnListItem
AnnListItem [TrailingAnn
t]) EpAnnComments
cs
addTrailingAnnToA SrcSpan
_ TrailingAnn
t EpAnnComments
cs EpAnn AnnListItem
n = EpAnn AnnListItem
n { anns :: AnnListItem
anns = AnnListItem -> AnnListItem
addTrailing (EpAnn AnnListItem -> AnnListItem
forall ann. EpAnn ann -> ann
anns EpAnn AnnListItem
n)
                               , comments :: EpAnnComments
comments = EpAnn AnnListItem -> EpAnnComments
forall ann. EpAnn ann -> EpAnnComments
comments EpAnn AnnListItem
n EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs }
  where
    -- See Note [list append in addTrailing*]
    addTrailing :: AnnListItem -> AnnListItem
addTrailing AnnListItem
n = AnnListItem
n { lann_trailing :: [TrailingAnn]
lann_trailing = AnnListItem -> [TrailingAnn]
lann_trailing AnnListItem
n [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. [a] -> [a] -> [a]
++ [TrailingAnn
t] }

-- | Helper function used in the parser to add a comma location to an
-- existing annotation.
addTrailingCommaToN :: SrcSpan -> EpAnn NameAnn -> EpaLocation -> EpAnn NameAnn
addTrailingCommaToN :: SrcSpan -> EpAnn NameAnn -> EpaLocation -> EpAnn NameAnn
addTrailingCommaToN SrcSpan
s EpAnn NameAnn
EpAnnNotUsed EpaLocation
l
  = Anchor -> NameAnn -> EpAnnComments -> EpAnn NameAnn
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
s) ([TrailingAnn] -> NameAnn
NameAnnTrailing [EpaLocation -> TrailingAnn
AddCommaAnn EpaLocation
l]) EpAnnComments
emptyComments
addTrailingCommaToN SrcSpan
_ EpAnn NameAnn
n EpaLocation
l = EpAnn NameAnn
n { anns :: NameAnn
anns = NameAnn -> EpaLocation -> NameAnn
addTrailing (EpAnn NameAnn -> NameAnn
forall ann. EpAnn ann -> ann
anns EpAnn NameAnn
n) EpaLocation
l }
  where
    -- See Note [list append in addTrailing*]
    addTrailing :: NameAnn -> EpaLocation -> NameAnn
    addTrailing :: NameAnn -> EpaLocation -> NameAnn
addTrailing NameAnn
n EpaLocation
l = NameAnn
n { nann_trailing :: [TrailingAnn]
nann_trailing = NameAnn -> [TrailingAnn]
nann_trailing NameAnn
n [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. [a] -> [a] -> [a]
++ [EpaLocation -> TrailingAnn
AddCommaAnn EpaLocation
l]}

{-
Note [list append in addTrailing*]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The addTrailingAnnToL, addTrailingAnnToA and addTrailingCommaToN
functions are used to add a separator for an item when it occurs in a
list.  So they are used to capture a comma, vbar, semicolon and similar.

In general, a given element will have zero or one of these.  In
extreme (test) cases, there may be multiple semicolons.

In exact printing we sometimes convert the EpaLocation variant for an
trailing annotation to the EpaDelta variant, which cannot be sorted.

Hence it is critical that these annotations are captured in the order
they appear in the original source file.

And so we use the less efficient list append to preserve the order,
knowing that in most cases the original list is empty.
-}

-- ---------------------------------------------------------------------

-- |Helper function (temporary) during transition of names
--  Discards any annotations
l2n :: LocatedAn a1 a2 -> LocatedN a2
l2n :: forall a1 a2. LocatedAn a1 a2 -> LocatedN a2
l2n (L SrcAnn a1
la a2
a) = SrcSpanAnnN -> a2 -> GenLocated SrcSpanAnnN a2
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnN
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcAnn a1 -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn a1
la)) a2
a

n2l :: LocatedN a -> LocatedA a
n2l :: forall a. LocatedN a -> LocatedA a
n2l (L SrcSpanAnnN
la a
a) = SrcSpanAnnA -> a -> GenLocated SrcSpanAnnA a
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnN -> SrcSpanAnnA
forall a ann. SrcSpanAnn' a -> SrcAnn ann
na2la SrcSpanAnnN
la) a
a

-- |Helper function (temporary) during transition of names
--  Discards any annotations
la2na :: SrcSpanAnn' a -> SrcSpanAnnN
la2na :: forall a. SrcSpanAnn' a -> SrcSpanAnnN
la2na SrcSpanAnn' a
l = SrcSpan -> SrcSpanAnnN
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
l)

-- |Helper function (temporary) during transition of names
--  Discards any annotations
la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2
la2la :: forall ann1 a2 ann2. LocatedAn ann1 a2 -> LocatedAn ann2 a2
la2la (L SrcAnn ann1
la a2
a) = SrcAnn ann2 -> a2 -> GenLocated (SrcAnn ann2) a2
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcAnn ann2
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcAnn ann1 -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn ann1
la)) a2
a

l2l :: SrcSpanAnn' a -> SrcAnn ann
l2l :: forall a ann. SrcSpanAnn' a -> SrcAnn ann
l2l SrcSpanAnn' a
l = SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
l)

-- |Helper function (temporary) during transition of names
--  Discards any annotations
na2la :: SrcSpanAnn' a -> SrcAnn ann
na2la :: forall a ann. SrcSpanAnn' a -> SrcAnn ann
na2la SrcSpanAnn' a
l = SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
l)

reLoc :: LocatedAn a e -> Located e
reLoc :: forall a e. LocatedAn a e -> Located e
reLoc (L (SrcSpanAnn EpAnn a
_ SrcSpan
l) e
a) = SrcSpan -> e -> GenLocated SrcSpan e
forall l e. l -> e -> GenLocated l e
L SrcSpan
l e
a

reLocA :: Located e -> LocatedAn ann e
reLocA :: forall e ann. Located e -> LocatedAn ann e
reLocA (L SrcSpan
l e
a) = (SrcAnn ann -> e -> GenLocated (SrcAnn ann) e
forall l e. l -> e -> GenLocated l e
L (EpAnn ann -> SrcSpan -> SrcAnn ann
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
l) e
a)

reLocL :: LocatedN e -> LocatedA e
reLocL :: forall a. LocatedN a -> LocatedA a
reLocL (L SrcSpanAnnN
l e
a) = (SrcSpanAnnA -> e -> GenLocated SrcSpanAnnA e
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnN -> SrcSpanAnnA
forall a ann. SrcSpanAnn' a -> SrcAnn ann
na2la SrcSpanAnnN
l) e
a)

reLocC :: LocatedN e -> LocatedC e
reLocC :: forall e. LocatedN e -> LocatedC e
reLocC (L SrcSpanAnnN
l e
a) = (SrcSpanAnnC -> e -> GenLocated SrcSpanAnnC e
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnN -> SrcSpanAnnC
forall a ann. SrcSpanAnn' a -> SrcAnn ann
na2la SrcSpanAnnN
l) e
a)

reLocN :: LocatedN a -> Located a
reLocN :: forall a. LocatedN a -> Located a
reLocN (L (SrcSpanAnn EpAnn NameAnn
_ SrcSpan
l) a
a) = SrcSpan -> a -> GenLocated SrcSpan a
forall l e. l -> e -> GenLocated l e
L SrcSpan
l a
a

-- ---------------------------------------------------------------------

realSrcSpan :: SrcSpan -> RealSrcSpan
realSrcSpan :: SrcSpan -> RealSrcSpan
realSrcSpan (RealSrcSpan RealSrcSpan
s Maybe BufSpan
_) = RealSrcSpan
s
realSrcSpan SrcSpan
_ = RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan RealSrcLoc
l RealSrcLoc
l -- AZ temporary
  where
    l :: RealSrcLoc
l = FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (String -> FastString
fsLit String
"foo") (-Int
1) (-Int
1)

la2r :: SrcSpanAnn' a -> RealSrcSpan
la2r :: forall a. SrcSpanAnn' a -> RealSrcSpan
la2r SrcSpanAnn' a
l = SrcSpan -> RealSrcSpan
realSrcSpan (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
l)

extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList
extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList
extraToAnnList (AnnList Maybe Anchor
a Maybe AddEpAnn
o Maybe AddEpAnn
c [AddEpAnn]
e [TrailingAnn]
t) [AddEpAnn]
as = Maybe Anchor
-> Maybe AddEpAnn
-> Maybe AddEpAnn
-> [AddEpAnn]
-> [TrailingAnn]
-> AnnList
AnnList Maybe Anchor
a Maybe AddEpAnn
o Maybe AddEpAnn
c ([AddEpAnn]
e[AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++[AddEpAnn]
as) [TrailingAnn]
t

reAnn :: [TrailingAnn] -> EpAnnComments -> Located a -> LocatedA a
reAnn :: forall a. [TrailingAnn] -> EpAnnComments -> Located a -> LocatedA a
reAnn [TrailingAnn]
anns EpAnnComments
cs (L SrcSpan
l a
a) = SrcSpanAnnA -> a -> GenLocated SrcSpanAnnA a
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
l) ([TrailingAnn] -> AnnListItem
AnnListItem [TrailingAnn]
anns) EpAnnComments
cs) SrcSpan
l) a
a

reAnnC :: AnnContext -> EpAnnComments -> Located a -> LocatedC a
reAnnC :: forall a. AnnContext -> EpAnnComments -> Located a -> LocatedC a
reAnnC AnnContext
anns EpAnnComments
cs (L SrcSpan
l a
a) = SrcSpanAnnC -> a -> GenLocated SrcSpanAnnC a
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnContext -> SrcSpan -> SrcSpanAnnC
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnContext -> EpAnnComments -> EpAnn AnnContext
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
l) AnnContext
anns EpAnnComments
cs) SrcSpan
l) a
a

reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e
reAnnL :: forall ann e.
ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e
reAnnL ann
anns EpAnnComments
cs (L SrcSpan
l e
a) = SrcAnn ann -> e -> GenLocated (SrcAnn ann) e
forall l e. l -> e -> GenLocated l e
L (EpAnn ann -> SrcSpan -> SrcAnn ann
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
l) ann
anns EpAnnComments
cs) SrcSpan
l) e
a

getLocAnn :: Located a  -> SrcSpanAnnA
getLocAnn :: forall a. Located a -> SrcSpanAnnA
getLocAnn (L SrcSpan
l a
_) = EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnListItem
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
l


getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA :: forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA (L (SrcSpanAnn a
_ SrcSpan
l) e
_) = SrcSpan
l

noLocA :: a -> LocatedAn an a
noLocA :: forall a an. a -> LocatedAn an a
noLocA = SrcAnn an -> a -> GenLocated (SrcAnn an) a
forall l e. l -> e -> GenLocated l e
L (EpAnn an -> SrcSpan -> SrcAnn an
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn an
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
noSrcSpan)

noAnnSrcSpan :: SrcSpan -> SrcAnn ann
noAnnSrcSpan :: forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
l = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
l

noSrcSpanA :: SrcAnn ann
noSrcSpanA :: forall ann. SrcAnn ann
noSrcSpanA = SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
noSrcSpan

-- | Short form for 'EpAnnNotUsed'
noAnn :: EpAnn a
noAnn :: forall ann. EpAnn ann
noAnn = EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed


addAnns :: EpAnn [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> EpAnn [AddEpAnn]
addAnns :: EpAnn [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> EpAnn [AddEpAnn]
addAnns (EpAnn Anchor
l [AddEpAnn]
as1 EpAnnComments
cs) [AddEpAnn]
as2 EpAnnComments
cs2
  = Anchor -> [AddEpAnn] -> EpAnnComments -> EpAnn [AddEpAnn]
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (Anchor -> [AddEpAnn] -> Anchor
widenAnchor Anchor
l ([AddEpAnn]
as1 [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn]
as2)) ([AddEpAnn]
as1 [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn]
as2) (EpAnnComments
cs EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs2)
addAnns EpAnn [AddEpAnn]
EpAnnNotUsed [] (EpaComments []) = EpAnn [AddEpAnn]
forall ann. EpAnn ann
EpAnnNotUsed
addAnns EpAnn [AddEpAnn]
EpAnnNotUsed [] (EpaCommentsBalanced [] []) = EpAnn [AddEpAnn]
forall ann. EpAnn ann
EpAnnNotUsed
addAnns EpAnn [AddEpAnn]
EpAnnNotUsed [AddEpAnn]
as EpAnnComments
cs = Anchor -> [AddEpAnn] -> EpAnnComments -> EpAnn [AddEpAnn]
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor RealSrcSpan
placeholderRealSpan AnchorOperation
UnchangedAnchor) [AddEpAnn]
as EpAnnComments
cs

-- AZ:TODO use widenSpan here too
addAnnsA :: SrcSpanAnnA -> [TrailingAnn] -> EpAnnComments -> SrcSpanAnnA
addAnnsA :: SrcSpanAnnA -> [TrailingAnn] -> EpAnnComments -> SrcSpanAnnA
addAnnsA (SrcSpanAnn (EpAnn Anchor
l AnnListItem
as1 EpAnnComments
cs) SrcSpan
loc) [TrailingAnn]
as2 EpAnnComments
cs2
  = EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
l ([TrailingAnn] -> AnnListItem
AnnListItem (AnnListItem -> [TrailingAnn]
lann_trailing AnnListItem
as1 [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. [a] -> [a] -> [a]
++ [TrailingAnn]
as2)) (EpAnnComments
cs EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs2)) SrcSpan
loc
addAnnsA (SrcSpanAnn EpAnn AnnListItem
EpAnnNotUsed SrcSpan
loc) [] (EpaComments [])
  = EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnListItem
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
loc
addAnnsA (SrcSpanAnn EpAnn AnnListItem
EpAnnNotUsed SrcSpan
loc) [] (EpaCommentsBalanced [] [])
  = EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnListItem
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
loc
addAnnsA (SrcSpanAnn EpAnn AnnListItem
EpAnnNotUsed SrcSpan
loc) [TrailingAnn]
as EpAnnComments
cs
  = EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (SrcSpan -> Anchor
spanAsAnchor SrcSpan
loc) ([TrailingAnn] -> AnnListItem
AnnListItem [TrailingAnn]
as) EpAnnComments
cs) SrcSpan
loc

-- | The annotations need to all come after the anchor.  Make sure
-- this is the case.
widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan
widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan
widenSpan SrcSpan
s [AddEpAnn]
as = (SrcSpan -> SrcSpan -> SrcSpan) -> SrcSpan -> [SrcSpan] -> SrcSpan
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
s ([AddEpAnn] -> [SrcSpan]
go [AddEpAnn]
as)
  where
    go :: [AddEpAnn] -> [SrcSpan]
go [] = []
    go (AddEpAnn AnnKeywordId
_ (EpaSpan RealSrcSpan
s):[AddEpAnn]
rest) = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan RealSrcSpan
s Maybe BufSpan
forall a. Maybe a
Nothing SrcSpan -> [SrcSpan] -> [SrcSpan]
forall a. a -> [a] -> [a]
: [AddEpAnn] -> [SrcSpan]
go [AddEpAnn]
rest
    go (AddEpAnn AnnKeywordId
_ (EpaDelta DeltaPos
_ [LEpaComment]
_):[AddEpAnn]
rest) = [AddEpAnn] -> [SrcSpan]
go [AddEpAnn]
rest

-- | The annotations need to all come after the anchor.  Make sure
-- this is the case.
widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan
widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan
widenRealSpan RealSrcSpan
s [AddEpAnn]
as = (RealSrcSpan -> RealSrcSpan -> RealSrcSpan)
-> RealSrcSpan -> [RealSrcSpan] -> RealSrcSpan
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans RealSrcSpan
s ([AddEpAnn] -> [RealSrcSpan]
go [AddEpAnn]
as)
  where
    go :: [AddEpAnn] -> [RealSrcSpan]
go [] = []
    go (AddEpAnn AnnKeywordId
_ (EpaSpan RealSrcSpan
s):[AddEpAnn]
rest) = RealSrcSpan
s RealSrcSpan -> [RealSrcSpan] -> [RealSrcSpan]
forall a. a -> [a] -> [a]
: [AddEpAnn] -> [RealSrcSpan]
go [AddEpAnn]
rest
    go (AddEpAnn AnnKeywordId
_ (EpaDelta DeltaPos
_ [LEpaComment]
_):[AddEpAnn]
rest) =     [AddEpAnn] -> [RealSrcSpan]
go [AddEpAnn]
rest

widenAnchor :: Anchor -> [AddEpAnn] -> Anchor
widenAnchor :: Anchor -> [AddEpAnn] -> Anchor
widenAnchor (Anchor RealSrcSpan
s AnchorOperation
op) [AddEpAnn]
as = RealSrcSpan -> AnchorOperation -> Anchor
Anchor (RealSrcSpan -> [AddEpAnn] -> RealSrcSpan
widenRealSpan RealSrcSpan
s [AddEpAnn]
as) AnchorOperation
op

widenAnchorR :: Anchor -> RealSrcSpan -> Anchor
widenAnchorR :: Anchor -> RealSrcSpan -> Anchor
widenAnchorR (Anchor RealSrcSpan
s AnchorOperation
op) RealSrcSpan
r = RealSrcSpan -> AnchorOperation -> Anchor
Anchor (RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans RealSrcSpan
s RealSrcSpan
r) AnchorOperation
op

widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an
widenLocatedAn :: forall an. SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an
widenLocatedAn (SrcSpanAnn an
a SrcSpan
l) [AddEpAnn]
as = an -> SrcSpan -> SrcSpanAnn' an
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn an
a (SrcSpan -> [AddEpAnn] -> SrcSpan
widenSpan SrcSpan
l [AddEpAnn]
as)

epAnnAnnsL :: EpAnn a -> [a]
epAnnAnnsL :: forall a. EpAnn a -> [a]
epAnnAnnsL EpAnn a
EpAnnNotUsed = []
epAnnAnnsL (EpAnn Anchor
_ a
anns EpAnnComments
_) = [a
anns]

epAnnAnns :: EpAnn [AddEpAnn] -> [AddEpAnn]
epAnnAnns :: EpAnn [AddEpAnn] -> [AddEpAnn]
epAnnAnns EpAnn [AddEpAnn]
EpAnnNotUsed = []
epAnnAnns (EpAnn Anchor
_ [AddEpAnn]
anns EpAnnComments
_) = [AddEpAnn]
anns

annParen2AddEpAnn :: EpAnn AnnParen -> [AddEpAnn]
annParen2AddEpAnn :: EpAnn AnnParen -> [AddEpAnn]
annParen2AddEpAnn EpAnn AnnParen
EpAnnNotUsed = []
annParen2AddEpAnn (EpAnn Anchor
_ (AnnParen ParenType
pt EpaLocation
o EpaLocation
c) EpAnnComments
_)
  = [AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
ai EpaLocation
o, AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
ac EpaLocation
c]
  where
    (AnnKeywordId
ai,AnnKeywordId
ac) = ParenType -> (AnnKeywordId, AnnKeywordId)
parenTypeKws ParenType
pt

epAnnComments :: EpAnn an -> EpAnnComments
epAnnComments :: forall ann. EpAnn ann -> EpAnnComments
epAnnComments EpAnn an
EpAnnNotUsed = [LEpaComment] -> EpAnnComments
EpaComments []
epAnnComments (EpAnn Anchor
_ an
_ EpAnnComments
cs) = EpAnnComments
cs

-- ---------------------------------------------------------------------
-- sortLocatedA :: [LocatedA a] -> [LocatedA a]
sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e]
sortLocatedA :: forall a e.
[GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e]
sortLocatedA = (GenLocated (SrcSpanAnn' a) e
 -> GenLocated (SrcSpanAnn' a) e -> Ordering)
-> [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (SrcSpan -> SrcSpan -> Ordering
leftmost_smallest (SrcSpan -> SrcSpan -> Ordering)
-> (GenLocated (SrcSpanAnn' a) e -> SrcSpan)
-> GenLocated (SrcSpanAnn' a) e
-> GenLocated (SrcSpanAnn' a) e
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` GenLocated (SrcSpanAnn' a) e -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA)

mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b
mapLocA :: forall a b ann.
(a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b
mapLocA a -> b
f (L SrcSpan
l a
a) = SrcAnn ann -> b -> GenLocated (SrcAnn ann) b
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
l) (a -> b
f a
a)

-- AZ:TODO: move this somewhere sane

combineLocsA :: Semigroup a => GenLocated (SrcAnn a) e1 -> GenLocated (SrcAnn a) e2 -> SrcAnn a
combineLocsA :: forall a e1 e2.
Semigroup a =>
GenLocated (SrcAnn a) e1 -> GenLocated (SrcAnn a) e2 -> SrcAnn a
combineLocsA (L SrcAnn a
a e1
_) (L SrcAnn a
b e2
_) = SrcAnn a -> SrcAnn a -> SrcAnn a
forall a. Semigroup a => SrcAnn a -> SrcAnn a -> SrcAnn a
combineSrcSpansA SrcAnn a
a SrcAnn a
b

combineSrcSpansA :: Semigroup a => SrcAnn a -> SrcAnn a -> SrcAnn a
combineSrcSpansA :: forall a. Semigroup a => SrcAnn a -> SrcAnn a -> SrcAnn a
combineSrcSpansA (SrcSpanAnn EpAnn a
aa SrcSpan
la) (SrcSpanAnn EpAnn a
ab SrcSpan
lb)
  = case EpAnn a -> SrcSpan -> SrcSpanAnn' (EpAnn a)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (EpAnn a
aa EpAnn a -> EpAnn a -> EpAnn a
forall a. Semigroup a => a -> a -> a
<> EpAnn a
ab) (SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
la SrcSpan
lb) of
      SrcSpanAnn EpAnn a
EpAnnNotUsed SrcSpan
l -> EpAnn a -> SrcSpan -> SrcSpanAnn' (EpAnn a)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
l
      SrcSpanAnn (EpAnn Anchor
anc a
an EpAnnComments
cs) SrcSpan
l ->
        EpAnn a -> SrcSpan -> SrcSpanAnn' (EpAnn a)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (Anchor -> RealSrcSpan -> Anchor
widenAnchorR Anchor
anc (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
l)) a
an EpAnnComments
cs) SrcSpan
l

-- | Combine locations from two 'Located' things and add them to a third thing
addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3
addCLocA :: forall a e1 e2 e3 ann.
GenLocated (SrcSpanAnn' a) e1
-> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3
addCLocA GenLocated (SrcSpanAnn' a) e1
a GenLocated SrcSpan e2
b e3
c = SrcAnn ann -> e3 -> GenLocated (SrcAnn ann) e3
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpan -> SrcAnn ann) -> SrcSpan -> SrcAnn ann
forall a b. (a -> b) -> a -> b
$ SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA (SrcSpanAnn' a -> SrcSpan) -> SrcSpanAnn' a -> SrcSpan
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcSpanAnn' a) e1 -> SrcSpanAnn' a
forall l e. GenLocated l e -> l
getLoc GenLocated (SrcSpanAnn' a) e1
a) (GenLocated SrcSpan e2 -> SrcSpan
forall l e. GenLocated l e -> l
getLoc GenLocated SrcSpan e2
b)) e3
c

addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3
addCLocAA :: forall a1 e1 a2 e2 e3 ann.
GenLocated (SrcSpanAnn' a1) e1
-> GenLocated (SrcSpanAnn' a2) e2
-> e3
-> GenLocated (SrcAnn ann) e3
addCLocAA GenLocated (SrcSpanAnn' a1) e1
a GenLocated (SrcSpanAnn' a2) e2
b e3
c = SrcAnn ann -> e3 -> GenLocated (SrcAnn ann) e3
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcAnn ann
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (SrcSpan -> SrcAnn ann) -> SrcSpan -> SrcAnn ann
forall a b. (a -> b) -> a -> b
$ SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans (SrcSpanAnn' a1 -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA (SrcSpanAnn' a1 -> SrcSpan) -> SrcSpanAnn' a1 -> SrcSpan
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcSpanAnn' a1) e1 -> SrcSpanAnn' a1
forall l e. GenLocated l e -> l
getLoc GenLocated (SrcSpanAnn' a1) e1
a) (SrcSpanAnn' a2 -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA (SrcSpanAnn' a2 -> SrcSpan) -> SrcSpanAnn' a2 -> SrcSpan
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcSpanAnn' a2) e2 -> SrcSpanAnn' a2
forall l e. GenLocated l e -> l
getLoc GenLocated (SrcSpanAnn' a2) e2
b)) e3
c

-- ---------------------------------------------------------------------
-- Utilities for manipulating EpAnnComments
-- ---------------------------------------------------------------------

getFollowingComments :: EpAnnComments -> [LEpaComment]
getFollowingComments :: EpAnnComments -> [LEpaComment]
getFollowingComments (EpaComments [LEpaComment]
_) = []
getFollowingComments (EpaCommentsBalanced [LEpaComment]
_ [LEpaComment]
cs) = [LEpaComment]
cs

setFollowingComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments
setFollowingComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments
setFollowingComments (EpaComments [LEpaComment]
ls) [LEpaComment]
cs           = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced [LEpaComment]
ls [LEpaComment]
cs
setFollowingComments (EpaCommentsBalanced [LEpaComment]
ls [LEpaComment]
_) [LEpaComment]
cs = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced [LEpaComment]
ls [LEpaComment]
cs

setPriorComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments
setPriorComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments
setPriorComments (EpaComments [LEpaComment]
_) [LEpaComment]
cs            = [LEpaComment] -> EpAnnComments
EpaComments [LEpaComment]
cs
setPriorComments (EpaCommentsBalanced [LEpaComment]
_ [LEpaComment]
ts) [LEpaComment]
cs = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced [LEpaComment]
cs [LEpaComment]
ts

-- ---------------------------------------------------------------------
-- Comment-only annotations
-- ---------------------------------------------------------------------

-- TODO:AZ I think EpAnnCO is not needed
type EpAnnCO = EpAnn NoEpAnns -- ^ Api Annotations for comments only

data NoEpAnns = NoEpAnns
  deriving (Typeable NoEpAnns
Typeable NoEpAnns
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NoEpAnns -> c NoEpAnns)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NoEpAnns)
-> (NoEpAnns -> Constr)
-> (NoEpAnns -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NoEpAnns))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NoEpAnns))
-> ((forall b. Data b => b -> b) -> NoEpAnns -> NoEpAnns)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r)
-> (forall u. (forall d. Data d => d -> u) -> NoEpAnns -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NoEpAnns -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns)
-> Data NoEpAnns
NoEpAnns -> DataType
NoEpAnns -> Constr
(forall b. Data b => b -> b) -> NoEpAnns -> NoEpAnns
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NoEpAnns -> u
forall u. (forall d. Data d => d -> u) -> NoEpAnns -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NoEpAnns
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NoEpAnns -> c NoEpAnns
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NoEpAnns)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NoEpAnns)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NoEpAnns -> m NoEpAnns
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NoEpAnns -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NoEpAnns -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NoEpAnns -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NoEpAnns -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NoEpAnns -> r
gmapT :: (forall b. Data b => b -> b) -> NoEpAnns -> NoEpAnns
$cgmapT :: (forall b. Data b => b -> b) -> NoEpAnns -> NoEpAnns
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NoEpAnns)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NoEpAnns)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NoEpAnns)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NoEpAnns)
dataTypeOf :: NoEpAnns -> DataType
$cdataTypeOf :: NoEpAnns -> DataType
toConstr :: NoEpAnns -> Constr
$ctoConstr :: NoEpAnns -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NoEpAnns
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NoEpAnns
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NoEpAnns -> c NoEpAnns
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NoEpAnns -> c NoEpAnns
Data,NoEpAnns -> NoEpAnns -> Bool
(NoEpAnns -> NoEpAnns -> Bool)
-> (NoEpAnns -> NoEpAnns -> Bool) -> Eq NoEpAnns
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NoEpAnns -> NoEpAnns -> Bool
$c/= :: NoEpAnns -> NoEpAnns -> Bool
== :: NoEpAnns -> NoEpAnns -> Bool
$c== :: NoEpAnns -> NoEpAnns -> Bool
Eq,Eq NoEpAnns
Eq NoEpAnns
-> (NoEpAnns -> NoEpAnns -> Ordering)
-> (NoEpAnns -> NoEpAnns -> Bool)
-> (NoEpAnns -> NoEpAnns -> Bool)
-> (NoEpAnns -> NoEpAnns -> Bool)
-> (NoEpAnns -> NoEpAnns -> Bool)
-> (NoEpAnns -> NoEpAnns -> NoEpAnns)
-> (NoEpAnns -> NoEpAnns -> NoEpAnns)
-> Ord NoEpAnns
NoEpAnns -> NoEpAnns -> Bool
NoEpAnns -> NoEpAnns -> Ordering
NoEpAnns -> NoEpAnns -> NoEpAnns
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NoEpAnns -> NoEpAnns -> NoEpAnns
$cmin :: NoEpAnns -> NoEpAnns -> NoEpAnns
max :: NoEpAnns -> NoEpAnns -> NoEpAnns
$cmax :: NoEpAnns -> NoEpAnns -> NoEpAnns
>= :: NoEpAnns -> NoEpAnns -> Bool
$c>= :: NoEpAnns -> NoEpAnns -> Bool
> :: NoEpAnns -> NoEpAnns -> Bool
$c> :: NoEpAnns -> NoEpAnns -> Bool
<= :: NoEpAnns -> NoEpAnns -> Bool
$c<= :: NoEpAnns -> NoEpAnns -> Bool
< :: NoEpAnns -> NoEpAnns -> Bool
$c< :: NoEpAnns -> NoEpAnns -> Bool
compare :: NoEpAnns -> NoEpAnns -> Ordering
$ccompare :: NoEpAnns -> NoEpAnns -> Ordering
Ord)

noComments ::EpAnnCO
noComments :: EpAnnCO
noComments = Anchor -> NoEpAnns -> EpAnnComments -> EpAnnCO
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor RealSrcSpan
placeholderRealSpan AnchorOperation
UnchangedAnchor) NoEpAnns
NoEpAnns EpAnnComments
emptyComments

-- TODO:AZ get rid of this
placeholderRealSpan :: RealSrcSpan
placeholderRealSpan :: RealSrcSpan
placeholderRealSpan = RealSrcLoc -> RealSrcSpan
realSrcLocSpan (FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (String -> FastString
mkFastString String
"placeholder") (-Int
1) (-Int
1))

comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO
comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO
comment RealSrcSpan
loc EpAnnComments
cs = Anchor -> NoEpAnns -> EpAnnComments -> EpAnnCO
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor RealSrcSpan
loc AnchorOperation
UnchangedAnchor) NoEpAnns
NoEpAnns EpAnnComments
cs

-- ---------------------------------------------------------------------
-- Utilities for managing comments in an `EpAnn a` structure.
-- ---------------------------------------------------------------------

-- | Add additional comments to a 'SrcAnn', used for manipulating the
-- AST prior to exact printing the changed one.
addCommentsToSrcAnn :: (Monoid ann) => SrcAnn ann -> EpAnnComments -> SrcAnn ann
addCommentsToSrcAnn :: forall ann. Monoid ann => SrcAnn ann -> EpAnnComments -> SrcAnn ann
addCommentsToSrcAnn (SrcSpanAnn EpAnn ann
EpAnnNotUsed SrcSpan
loc) EpAnnComments
cs
  = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
loc) AnchorOperation
UnchangedAnchor) ann
forall a. Monoid a => a
mempty EpAnnComments
cs) SrcSpan
loc
addCommentsToSrcAnn (SrcSpanAnn (EpAnn Anchor
a ann
an EpAnnComments
cs) SrcSpan
loc) EpAnnComments
cs'
  = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a ann
an (EpAnnComments
cs EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs')) SrcSpan
loc

-- | Replace any existing comments on a 'SrcAnn', used for manipulating the
-- AST prior to exact printing the changed one.
setCommentsSrcAnn :: (Monoid ann) => SrcAnn ann -> EpAnnComments -> SrcAnn ann
setCommentsSrcAnn :: forall ann. Monoid ann => SrcAnn ann -> EpAnnComments -> SrcAnn ann
setCommentsSrcAnn (SrcSpanAnn EpAnn ann
EpAnnNotUsed SrcSpan
loc) EpAnnComments
cs
  = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
loc) AnchorOperation
UnchangedAnchor) ann
forall a. Monoid a => a
mempty EpAnnComments
cs) SrcSpan
loc
setCommentsSrcAnn (SrcSpanAnn (EpAnn Anchor
a ann
an EpAnnComments
_) SrcSpan
loc) EpAnnComments
cs
  = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a ann
an EpAnnComments
cs) SrcSpan
loc

-- | Add additional comments, used for manipulating the
-- AST prior to exact printing the changed one.
addCommentsToEpAnn :: (Monoid a)
  => SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a
addCommentsToEpAnn :: forall a.
Monoid a =>
SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a
addCommentsToEpAnn SrcSpan
loc EpAnn a
EpAnnNotUsed EpAnnComments
cs
  = Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
loc) AnchorOperation
UnchangedAnchor) a
forall a. Monoid a => a
mempty EpAnnComments
cs
addCommentsToEpAnn SrcSpan
_ (EpAnn Anchor
a a
an EpAnnComments
ocs) EpAnnComments
ncs = Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a a
an (EpAnnComments
ocs EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
ncs)

-- | Replace any existing comments, used for manipulating the
-- AST prior to exact printing the changed one.
setCommentsEpAnn :: (Monoid a)
  => SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a
setCommentsEpAnn :: forall a.
Monoid a =>
SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a
setCommentsEpAnn SrcSpan
loc EpAnn a
EpAnnNotUsed EpAnnComments
cs
  = Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
loc) AnchorOperation
UnchangedAnchor) a
forall a. Monoid a => a
mempty EpAnnComments
cs
setCommentsEpAnn SrcSpan
_ (EpAnn Anchor
a a
an EpAnnComments
_) EpAnnComments
cs = Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a a
an EpAnnComments
cs

-- | Transfer comments and trailing items from the annotations in the
-- first 'SrcSpanAnnA' argument to those in the second.
transferAnnsA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA,  SrcSpanAnnA)
transferAnnsA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA, SrcSpanAnnA)
transferAnnsA from :: SrcSpanAnnA
from@(SrcSpanAnn EpAnn AnnListItem
EpAnnNotUsed SrcSpan
_) SrcSpanAnnA
to = (SrcSpanAnnA
from, SrcSpanAnnA
to)
transferAnnsA (SrcSpanAnn (EpAnn Anchor
a AnnListItem
an EpAnnComments
cs) SrcSpan
l) SrcSpanAnnA
to
  = ((EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a AnnListItem
forall a. Monoid a => a
mempty EpAnnComments
emptyComments) SrcSpan
l), SrcSpanAnnA
to')
  where
    to' :: SrcSpanAnnA
to' = case SrcSpanAnnA
to of
      (SrcSpanAnn EpAnn AnnListItem
EpAnnNotUsed SrcSpan
loc)
        ->  EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (RealSrcSpan -> AnchorOperation -> Anchor
Anchor (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
loc) AnchorOperation
UnchangedAnchor) AnnListItem
an EpAnnComments
cs) SrcSpan
loc
      (SrcSpanAnn (EpAnn Anchor
a AnnListItem
an' EpAnnComments
cs') SrcSpan
loc)
        -> EpAnn AnnListItem -> SrcSpan -> SrcSpanAnnA
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a (AnnListItem
an' AnnListItem -> AnnListItem -> AnnListItem
forall a. Semigroup a => a -> a -> a
<> AnnListItem
an) (EpAnnComments
cs' EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
cs)) SrcSpan
loc

-- | Remove the exact print annotations payload, leaving only the
-- anchor and comments.
commentsOnlyA :: Monoid ann => SrcAnn ann -> SrcAnn ann
commentsOnlyA :: forall ann. Monoid ann => SrcAnn ann -> SrcAnn ann
commentsOnlyA (SrcSpanAnn EpAnn ann
EpAnnNotUsed SrcSpan
loc) = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
loc
commentsOnlyA (SrcSpanAnn (EpAnn Anchor
a ann
_ EpAnnComments
cs) SrcSpan
loc) = (EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a ann
forall a. Monoid a => a
mempty EpAnnComments
cs) SrcSpan
loc)

-- | Remove the comments, leaving the exact print annotations payload
removeCommentsA :: SrcAnn ann -> SrcAnn ann
removeCommentsA :: forall ann. SrcAnn ann -> SrcAnn ann
removeCommentsA (SrcSpanAnn EpAnn ann
EpAnnNotUsed SrcSpan
loc) = EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
loc
removeCommentsA (SrcSpanAnn (EpAnn Anchor
a ann
an EpAnnComments
_) SrcSpan
loc)
  = (EpAnn ann -> SrcSpan -> SrcSpanAnn' (EpAnn ann)
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
a ann
an EpAnnComments
emptyComments) SrcSpan
loc)

-- ---------------------------------------------------------------------
-- Semigroup instances, to allow easy combination of annotaion elements
-- ---------------------------------------------------------------------

instance (Semigroup an) => Semigroup (SrcSpanAnn' an) where
  (SrcSpanAnn an
a1 SrcSpan
l1) <> :: SrcSpanAnn' an -> SrcSpanAnn' an -> SrcSpanAnn' an
<> (SrcSpanAnn an
a2 SrcSpan
l2) = an -> SrcSpan -> SrcSpanAnn' an
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (an
a1 an -> an -> an
forall a. Semigroup a => a -> a -> a
<> an
a2) (SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
l1 SrcSpan
l2)
   -- The critical part about the location is its left edge, and all
   -- annotations must follow it. So we combine them which yields the
   -- largest span

instance (Semigroup a) => Semigroup (EpAnn a) where
  EpAnn a
EpAnnNotUsed <> :: EpAnn a -> EpAnn a -> EpAnn a
<> EpAnn a
x = EpAnn a
x
  EpAnn a
x <> EpAnn a
EpAnnNotUsed = EpAnn a
x
  (EpAnn Anchor
l1 a
a1 EpAnnComments
b1) <> (EpAnn Anchor
l2 a
a2 EpAnnComments
b2) = Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (Anchor
l1 Anchor -> Anchor -> Anchor
forall a. Semigroup a => a -> a -> a
<> Anchor
l2) (a
a1 a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
a2) (EpAnnComments
b1 EpAnnComments -> EpAnnComments -> EpAnnComments
forall a. Semigroup a => a -> a -> a
<> EpAnnComments
b2)
   -- The critical part about the anchor is its left edge, and all
   -- annotations must follow it. So we combine them which yields the
   -- largest span

instance Ord Anchor where
  compare :: Anchor -> Anchor -> Ordering
compare (Anchor RealSrcSpan
s1 AnchorOperation
_) (Anchor RealSrcSpan
s2 AnchorOperation
_) = RealSrcSpan -> RealSrcSpan -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RealSrcSpan
s1 RealSrcSpan
s2

instance Semigroup Anchor where
  Anchor RealSrcSpan
r1 AnchorOperation
o1 <> :: Anchor -> Anchor -> Anchor
<> Anchor RealSrcSpan
r2 AnchorOperation
_ = RealSrcSpan -> AnchorOperation -> Anchor
Anchor (RealSrcSpan -> RealSrcSpan -> RealSrcSpan
combineRealSrcSpans RealSrcSpan
r1 RealSrcSpan
r2) AnchorOperation
o1

instance Semigroup EpAnnComments where
  EpaComments [LEpaComment]
cs1 <> :: EpAnnComments -> EpAnnComments -> EpAnnComments
<> EpaComments [LEpaComment]
cs2 = [LEpaComment] -> EpAnnComments
EpaComments ([LEpaComment]
cs1 [LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++ [LEpaComment]
cs2)
  EpaComments [LEpaComment]
cs1 <> EpaCommentsBalanced [LEpaComment]
cs2 [LEpaComment]
as2 = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced ([LEpaComment]
cs1 [LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++ [LEpaComment]
cs2) [LEpaComment]
as2
  EpaCommentsBalanced [LEpaComment]
cs1 [LEpaComment]
as1 <> EpaComments [LEpaComment]
cs2 = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced ([LEpaComment]
cs1 [LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++ [LEpaComment]
cs2) [LEpaComment]
as1
  EpaCommentsBalanced [LEpaComment]
cs1 [LEpaComment]
as1 <> EpaCommentsBalanced [LEpaComment]
cs2 [LEpaComment]
as2 = [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced ([LEpaComment]
cs1 [LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++ [LEpaComment]
cs2) ([LEpaComment]
as1[LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++[LEpaComment]
as2)


instance (Monoid a) => Monoid (EpAnn a) where
  mempty :: EpAnn a
mempty = EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed

instance Semigroup AnnListItem where
  (AnnListItem [TrailingAnn]
l1) <> :: AnnListItem -> AnnListItem -> AnnListItem
<> (AnnListItem [TrailingAnn]
l2) = [TrailingAnn] -> AnnListItem
AnnListItem ([TrailingAnn]
l1 [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. Semigroup a => a -> a -> a
<> [TrailingAnn]
l2)

instance Monoid AnnListItem where
  mempty :: AnnListItem
mempty = [TrailingAnn] -> AnnListItem
AnnListItem []


instance Semigroup AnnList where
  (AnnList Maybe Anchor
a1 Maybe AddEpAnn
o1 Maybe AddEpAnn
c1 [AddEpAnn]
r1 [TrailingAnn]
t1) <> :: AnnList -> AnnList -> AnnList
<> (AnnList Maybe Anchor
a2 Maybe AddEpAnn
o2 Maybe AddEpAnn
c2 [AddEpAnn]
r2 [TrailingAnn]
t2)
    = Maybe Anchor
-> Maybe AddEpAnn
-> Maybe AddEpAnn
-> [AddEpAnn]
-> [TrailingAnn]
-> AnnList
AnnList (Maybe Anchor
a1 Maybe Anchor -> Maybe Anchor -> Maybe Anchor
forall a. Semigroup a => a -> a -> a
<> Maybe Anchor
a2) (Maybe AddEpAnn -> Maybe AddEpAnn -> Maybe AddEpAnn
forall {a}. Maybe a -> Maybe a -> Maybe a
c Maybe AddEpAnn
o1 Maybe AddEpAnn
o2) (Maybe AddEpAnn -> Maybe AddEpAnn -> Maybe AddEpAnn
forall {a}. Maybe a -> Maybe a -> Maybe a
c Maybe AddEpAnn
c1 Maybe AddEpAnn
c2) ([AddEpAnn]
r1 [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. Semigroup a => a -> a -> a
<> [AddEpAnn]
r2) ([TrailingAnn]
t1 [TrailingAnn] -> [TrailingAnn] -> [TrailingAnn]
forall a. Semigroup a => a -> a -> a
<> [TrailingAnn]
t2)
    where
      -- Left biased combination for the open and close annotations
      c :: Maybe a -> Maybe a -> Maybe a
c Maybe a
Nothing Maybe a
x = Maybe a
x
      c Maybe a
x Maybe a
Nothing = Maybe a
x
      c Maybe a
f Maybe a
_       = Maybe a
f

instance Monoid AnnList where
  mempty :: AnnList
mempty = Maybe Anchor
-> Maybe AddEpAnn
-> Maybe AddEpAnn
-> [AddEpAnn]
-> [TrailingAnn]
-> AnnList
AnnList Maybe Anchor
forall a. Maybe a
Nothing Maybe AddEpAnn
forall a. Maybe a
Nothing Maybe AddEpAnn
forall a. Maybe a
Nothing [] []

instance Semigroup NameAnn where
  NameAnn
_ <> :: NameAnn -> NameAnn -> NameAnn
<> NameAnn
_ = String -> NameAnn
forall a. String -> a
panic String
"semigroup nameann"

instance Monoid NameAnn where
  mempty :: NameAnn
mempty = [TrailingAnn] -> NameAnn
NameAnnTrailing []


instance Semigroup AnnSortKey where
  AnnSortKey
NoAnnSortKey <> :: AnnSortKey -> AnnSortKey -> AnnSortKey
<> AnnSortKey
x = AnnSortKey
x
  AnnSortKey
x <> AnnSortKey
NoAnnSortKey = AnnSortKey
x
  AnnSortKey [RealSrcSpan]
ls1 <> AnnSortKey [RealSrcSpan]
ls2 = [RealSrcSpan] -> AnnSortKey
AnnSortKey ([RealSrcSpan]
ls1 [RealSrcSpan] -> [RealSrcSpan] -> [RealSrcSpan]
forall a. Semigroup a => a -> a -> a
<> [RealSrcSpan]
ls2)

instance Monoid AnnSortKey where
  mempty :: AnnSortKey
mempty = AnnSortKey
NoAnnSortKey

instance (Outputable a) => Outputable (EpAnn a) where
  ppr :: EpAnn a -> SDoc
ppr (EpAnn Anchor
l a
a EpAnnComments
c)  = String -> SDoc
text String
"EpAnn" SDoc -> SDoc -> SDoc
<+> Anchor -> SDoc
forall a. Outputable a => a -> SDoc
ppr Anchor
l SDoc -> SDoc -> SDoc
<+> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
a SDoc -> SDoc -> SDoc
<+> EpAnnComments -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpAnnComments
c
  ppr EpAnn a
EpAnnNotUsed = String -> SDoc
text String
"EpAnnNotUsed"

instance Outputable Anchor where
  ppr :: Anchor -> SDoc
ppr (Anchor RealSrcSpan
a AnchorOperation
o)        = String -> SDoc
text String
"Anchor" SDoc -> SDoc -> SDoc
<+> RealSrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr RealSrcSpan
a SDoc -> SDoc -> SDoc
<+> AnchorOperation -> SDoc
forall a. Outputable a => a -> SDoc
ppr AnchorOperation
o

instance Outputable AnchorOperation where
  ppr :: AnchorOperation -> SDoc
ppr AnchorOperation
UnchangedAnchor   = String -> SDoc
text String
"UnchangedAnchor"
  ppr (MovedAnchor DeltaPos
d)   = String -> SDoc
text String
"MovedAnchor" SDoc -> SDoc -> SDoc
<+> DeltaPos -> SDoc
forall a. Outputable a => a -> SDoc
ppr DeltaPos
d

instance Outputable DeltaPos where
  ppr :: DeltaPos -> SDoc
ppr (SameLine Int
c) = String -> SDoc
text String
"SameLine" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
c
  ppr (DifferentLine Int
l Int
c) = String -> SDoc
text String
"DifferentLine" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
l SDoc -> SDoc -> SDoc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
c

instance Outputable (GenLocated Anchor EpaComment) where
  ppr :: LEpaComment -> SDoc
ppr (L Anchor
l EpaComment
c) = String -> SDoc
text String
"L" SDoc -> SDoc -> SDoc
<+> Anchor -> SDoc
forall a. Outputable a => a -> SDoc
ppr Anchor
l SDoc -> SDoc -> SDoc
<+> EpaComment -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaComment
c

instance Outputable EpAnnComments where
  ppr :: EpAnnComments -> SDoc
ppr (EpaComments [LEpaComment]
cs) = String -> SDoc
text String
"EpaComments" SDoc -> SDoc -> SDoc
<+> [LEpaComment] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LEpaComment]
cs
  ppr (EpaCommentsBalanced [LEpaComment]
cs [LEpaComment]
ts) = String -> SDoc
text String
"EpaCommentsBalanced" SDoc -> SDoc -> SDoc
<+> [LEpaComment] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LEpaComment]
cs SDoc -> SDoc -> SDoc
<+> [LEpaComment] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LEpaComment]
ts

instance (NamedThing (Located a)) => NamedThing (LocatedAn an a) where
  getName :: LocatedAn an a -> Name
getName (L SrcAnn an
l a
a) = Located a -> Name
forall a. NamedThing a => a -> Name
getName (SrcSpan -> a -> Located a
forall l e. l -> e -> GenLocated l e
L (SrcAnn an -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcAnn an
l) a
a)

instance Outputable AnnContext where
  ppr :: AnnContext -> SDoc
ppr (AnnContext Maybe (IsUnicodeSyntax, EpaLocation)
a [EpaLocation]
o [EpaLocation]
c) = String -> SDoc
text String
"AnnContext" SDoc -> SDoc -> SDoc
<+> Maybe (IsUnicodeSyntax, EpaLocation) -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe (IsUnicodeSyntax, EpaLocation)
a SDoc -> SDoc -> SDoc
<+> [EpaLocation] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [EpaLocation]
o SDoc -> SDoc -> SDoc
<+> [EpaLocation] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [EpaLocation]
c

instance Outputable AnnSortKey where
  ppr :: AnnSortKey -> SDoc
ppr AnnSortKey
NoAnnSortKey    = String -> SDoc
text String
"NoAnnSortKey"
  ppr (AnnSortKey [RealSrcSpan]
ls) = String -> SDoc
text String
"AnnSortKey" SDoc -> SDoc -> SDoc
<+> [RealSrcSpan] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [RealSrcSpan]
ls

instance Outputable IsUnicodeSyntax where
  ppr :: IsUnicodeSyntax -> SDoc
ppr = String -> SDoc
text (String -> SDoc)
-> (IsUnicodeSyntax -> String) -> IsUnicodeSyntax -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsUnicodeSyntax -> String
forall a. Show a => a -> String
show

instance Binary a => Binary (LocatedL a) where
  -- We do not serialise the annotations
    put_ :: BinHandle -> LocatedL a -> IO ()
put_ BinHandle
bh (L SrcSpanAnnL
l a
x) = do
            BinHandle -> SrcSpan -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (SrcSpanAnnL -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
l)
            BinHandle -> a -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh a
x

    get :: BinHandle -> IO (LocatedL a)
get BinHandle
bh = do
            SrcSpan
l <- BinHandle -> IO SrcSpan
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
            a
x <- BinHandle -> IO a
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
            LocatedL a -> IO (LocatedL a)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL -> a -> LocatedL a
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> SrcSpanAnnL
forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
l) a
x)

instance (Outputable a) => Outputable (SrcSpanAnn' a) where
  ppr :: SrcSpanAnn' a -> SDoc
ppr (SrcSpanAnn a
a SrcSpan
l) = String -> SDoc
text String
"SrcSpanAnn" SDoc -> SDoc -> SDoc
<+> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
a SDoc -> SDoc -> SDoc
<+> SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr SrcSpan
l

instance (Outputable a, Outputable e)
     => Outputable (GenLocated (SrcSpanAnn' a) e) where
  ppr :: GenLocated (SrcSpanAnn' a) e -> SDoc
ppr = GenLocated (SrcSpanAnn' a) e -> SDoc
forall l e. (Outputable l, Outputable e) => GenLocated l e -> SDoc
pprLocated

instance Outputable AnnListItem where
  ppr :: AnnListItem -> SDoc
ppr (AnnListItem [TrailingAnn]
ts) = String -> SDoc
text String
"AnnListItem" SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
ts

instance Outputable NameAdornment where
  ppr :: NameAdornment -> SDoc
ppr NameAdornment
NameParens     = String -> SDoc
text String
"NameParens"
  ppr NameAdornment
NameParensHash = String -> SDoc
text String
"NameParensHash"
  ppr NameAdornment
NameBackquotes = String -> SDoc
text String
"NameBackquotes"
  ppr NameAdornment
NameSquare     = String -> SDoc
text String
"NameSquare"

instance Outputable NameAnn where
  ppr :: NameAnn -> SDoc
ppr (NameAnn NameAdornment
a EpaLocation
o EpaLocation
n EpaLocation
c [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnn" SDoc -> SDoc -> SDoc
<+> NameAdornment -> SDoc
forall a. Outputable a => a -> SDoc
ppr NameAdornment
a SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
o SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
n SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
c SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t
  ppr (NameAnnCommas NameAdornment
a EpaLocation
o [EpaLocation]
n EpaLocation
c [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnnCommas" SDoc -> SDoc -> SDoc
<+> NameAdornment -> SDoc
forall a. Outputable a => a -> SDoc
ppr NameAdornment
a SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
o SDoc -> SDoc -> SDoc
<+> [EpaLocation] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [EpaLocation]
n SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
c SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t
  ppr (NameAnnOnly NameAdornment
a EpaLocation
o EpaLocation
c [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnnOnly" SDoc -> SDoc -> SDoc
<+> NameAdornment -> SDoc
forall a. Outputable a => a -> SDoc
ppr NameAdornment
a SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
o SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
c SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t
  ppr (NameAnnRArrow EpaLocation
n [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnnRArrow" SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
n SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t
  ppr (NameAnnQuote EpaLocation
q SrcSpanAnnN
n [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnnQuote" SDoc -> SDoc -> SDoc
<+> EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr EpaLocation
q SDoc -> SDoc -> SDoc
<+> SrcSpanAnnN -> SDoc
forall a. Outputable a => a -> SDoc
ppr SrcSpanAnnN
n SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t
  ppr (NameAnnTrailing [TrailingAnn]
t)
    = String -> SDoc
text String
"NameAnnTrailing" SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t

instance Outputable AnnList where
  ppr :: AnnList -> SDoc
ppr (AnnList Maybe Anchor
a Maybe AddEpAnn
o Maybe AddEpAnn
c [AddEpAnn]
r [TrailingAnn]
t)
    = String -> SDoc
text String
"AnnList" SDoc -> SDoc -> SDoc
<+> Maybe Anchor -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe Anchor
a SDoc -> SDoc -> SDoc
<+> Maybe AddEpAnn -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe AddEpAnn
o SDoc -> SDoc -> SDoc
<+> Maybe AddEpAnn -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe AddEpAnn
c SDoc -> SDoc -> SDoc
<+> [AddEpAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [AddEpAnn]
r SDoc -> SDoc -> SDoc
<+> [TrailingAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TrailingAnn]
t

instance Outputable AnnPragma where
  ppr :: AnnPragma -> SDoc
ppr (AnnPragma AddEpAnn
o AddEpAnn
c [AddEpAnn]
r) = String -> SDoc
text String
"AnnPragma" SDoc -> SDoc -> SDoc
<+> AddEpAnn -> SDoc
forall a. Outputable a => a -> SDoc
ppr AddEpAnn
o SDoc -> SDoc -> SDoc
<+> AddEpAnn -> SDoc
forall a. Outputable a => a -> SDoc
ppr AddEpAnn
c SDoc -> SDoc -> SDoc
<+> [AddEpAnn] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [AddEpAnn]
r