{-# LANGUAGE DeriveDataTypeable #-}

module GHC.Parser.Annotation (
  getAnnotation, getAndRemoveAnnotation,
  getAnnotationComments,getAndRemoveAnnotationComments,
  ApiAnns(..),
  ApiAnnKey,
  AnnKeywordId(..),
  AddAnn(..),mkParensApiAnn,
  AnnotationComment(..),
  IsUnicodeSyntax(..),
  unicodeAnn,
  HasE(..),
  LRdrName -- Exists for haddocks only
  ) where

import GHC.Prelude

import GHC.Types.Name.Reader
import GHC.Utils.Outputable
import GHC.Types.SrcLoc
import qualified Data.Map as Map
import Data.Data


{-
Note [Api 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 "API annotations".

Rather than annotate the resulting parse tree with these locations
directly (this would be a major change to some fairly core data
structures in GHC), we instead capture locations for these elements in a
structure separate from the parse tree, and returned in the
pm_annotations field of the ParsedModule type.

The full ApiAnns type is

> data ApiAnns =
>  ApiAnns
>    { apiAnnItems :: Map.Map ApiAnnKey [RealSrcSpan],
>      apiAnnEofPos :: Maybe RealSrcSpan,
>      apiAnnComments :: Map.Map RealSrcSpan [RealLocated AnnotationComment],
>      apiAnnRogueComments :: [RealLocated AnnotationComment]
>    }

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.

Consequently, the structure that records non-comment elements is logically
a two level map, from the RealSrcSpan of the AST element containing it, to
a map from keywords ('AnnKeyWord') to all locations of the keyword directly
in the AST element:

> type ApiAnnKey = (RealSrcSpan,AnnKeywordId)
>
> Map.Map ApiAnnKey [RealSrcSpan]

So

> let x = 1 in 2 *x

would result in the AST element

  L span (HsLet (binds for x = 1) (2 * x))

and the annotations

  (span,AnnLet) having the location of the 'let' keyword
  (span,AnnEqual) having the location of the '=' sign
  (span,AnnIn)  having the location of the 'in' keyword

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; see #13012).

COMMENT ELEMENTS

Every comment is associated with a *located* AnnotationComment.
We associate comments with the lowest (most specific) AST element
enclosing them:

> Map.Map RealSrcSpan [RealLocated AnnotationComment]

PARSER STATE

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

>  annotations :: [(ApiAnnKey,[RealSrcSpan])],
>  comment_q :: [RealLocated AnnotationComment],
>  annotations_comments :: [(RealSrcSpan,[RealLocated AnnotationComment])]

The 'annotations' and 'annotations_comments' fields are simple: they simply
accumulate annotations that will end up in 'ApiAnns' at the end
(after they are passed to Map.fromList).

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 (at the time we lex a comment, we don't know what the enclosing
AST node of it is, so we can't associate it with a RealSrcSpan in
annotations_comments).

PARSER EMISSION OF ANNOTATIONS

The parser interacts with the lexer using the function

> addAnnotation :: RealSrcSpan -> AnnKeywordId -> RealSrcSpan -> P ()

which takes the AST element RealSrcSpan, the annotation keyword and the
target RealSrcSpan.

This adds the annotation to the `annotations` field of `PState` and
transfers any comments in `comment_q` WHICH ARE ENCLOSED by
the RealSrcSpan of this element to the `annotations_comments`
field.  (Comments which are outside of this annotation are deferred
until later. 'allocateComments' in 'Lexer' is responsible for
making sure we only attach comments that actually fit in the 'SrcSpan'.)

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

-}
-- ---------------------------------------------------------------------

-- If you update this, update the Note [Api annotations] above
data ApiAnns =
  ApiAnns
    { ApiAnns -> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
apiAnnItems :: Map.Map ApiAnnKey [RealSrcSpan],
      ApiAnns -> Maybe RealSrcSpan
apiAnnEofPos :: Maybe RealSrcSpan,
      ApiAnns -> Map RealSrcSpan [RealLocated AnnotationComment]
apiAnnComments :: Map.Map RealSrcSpan [RealLocated AnnotationComment],
      ApiAnns -> [RealLocated AnnotationComment]
apiAnnRogueComments :: [RealLocated AnnotationComment]
    }

-- If you update this, update the Note [Api annotations] above
type ApiAnnKey = (RealSrcSpan,AnnKeywordId)


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

-- | Encapsulated call to addAnnotation, requiring only the SrcSpan of
--   the AST construct the annotation belongs to; together with the
--   AnnKeywordId, this is the key of the annotation map.
--
--   This type is useful for places in the parser where it is not yet
--   known what SrcSpan an annotation should be added to.  The most
--   common situation is when we are parsing a list: the annotations
--   need to be associated with the AST element that *contains* the
--   list, not the list itself.  'AddAnn' lets us defer adding the
--   annotations until we finish parsing the list and are now parsing
--   the enclosing element; we then apply the 'AddAnn' to associate
--   the annotations.  Another common situation is where a common fragment of
--   the AST has been factored out but there is no separate AST node for
--   this fragment (this occurs in class and data declarations). In this
--   case, the annotation belongs to the parent data declaration.
--
--   The usual way an 'AddAnn' is created is using the 'mj' ("make jump")
--   function, and then it can be discharged using the 'ams' function.
data AddAnn = AddAnn AnnKeywordId SrcSpan

-- |Given a 'SrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate
-- 'AddAnn' values for the opening and closing bordering on the start
-- and end of the span
mkParensApiAnn :: SrcSpan -> [AddAnn]
mkParensApiAnn :: SrcSpan -> [AddAnn]
mkParensApiAnn (UnhelpfulSpan UnhelpfulSpanReason
_)  = []
mkParensApiAnn (RealSrcSpan RealSrcSpan
ss Maybe BufSpan
_) = [AnnKeywordId -> SrcSpan -> AddAnn
AddAnn AnnKeywordId
AnnOpenP SrcSpan
lo,AnnKeywordId -> SrcSpan -> AddAnn
AddAnn AnnKeywordId
AnnCloseP SrcSpan
lc]
  where
    f :: FastString
f = RealSrcSpan -> FastString
srcSpanFile RealSrcSpan
ss
    sl :: Int
sl = RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
ss
    sc :: Int
sc = RealSrcSpan -> Int
srcSpanStartCol RealSrcSpan
ss
    el :: Int
el = RealSrcSpan -> Int
srcSpanEndLine RealSrcSpan
ss
    ec :: Int
ec = RealSrcSpan -> Int
srcSpanEndCol RealSrcSpan
ss
    lo :: SrcSpan
lo = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan (RealSrcSpan -> RealSrcLoc
realSrcSpanStart RealSrcSpan
ss)        (FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc FastString
f Int
sl (Int
scInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1))) Maybe BufSpan
forall a. Maybe a
Nothing
    lc :: SrcSpan
lc = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan (FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc FastString
f Int
el (Int
ec Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)) (RealSrcSpan -> RealSrcLoc
realSrcSpanEnd RealSrcSpan
ss))        Maybe BufSpan
forall a. Maybe a
Nothing

-- ---------------------------------------------------------------------
-- | Retrieve a list of annotation 'SrcSpan's based on the 'SrcSpan'
-- of the annotated AST element, and the known type of the annotation.
getAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> [RealSrcSpan]
getAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> [RealSrcSpan]
getAnnotation ApiAnns
anns RealSrcSpan
span AnnKeywordId
ann =
  case (RealSrcSpan, AnnKeywordId)
-> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
-> Maybe [RealSrcSpan]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (RealSrcSpan, AnnKeywordId)
ann_key Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
ann_items of
    Maybe [RealSrcSpan]
Nothing -> []
    Just [RealSrcSpan]
ss -> [RealSrcSpan]
ss
  where ann_items :: Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
ann_items = ApiAnns -> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
apiAnnItems ApiAnns
anns
        ann_key :: (RealSrcSpan, AnnKeywordId)
ann_key = (RealSrcSpan
span,AnnKeywordId
ann)

-- | Retrieve a list of annotation 'SrcSpan's based on the 'SrcSpan'
-- of the annotated AST element, and the known type of the annotation.
-- The list is removed from the annotations.
getAndRemoveAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId
                       -> ([RealSrcSpan],ApiAnns)
getAndRemoveAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> ([RealSrcSpan], ApiAnns)
getAndRemoveAnnotation ApiAnns
anns RealSrcSpan
span AnnKeywordId
ann =
  case (RealSrcSpan, AnnKeywordId)
-> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
-> Maybe [RealSrcSpan]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (RealSrcSpan, AnnKeywordId)
ann_key Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
ann_items of
    Maybe [RealSrcSpan]
Nothing -> ([],ApiAnns
anns)
    Just [RealSrcSpan]
ss -> ([RealSrcSpan]
ss,ApiAnns
anns{ apiAnnItems :: Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
apiAnnItems = (RealSrcSpan, AnnKeywordId)
-> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
-> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete (RealSrcSpan, AnnKeywordId)
ann_key Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
ann_items })
  where ann_items :: Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
ann_items = ApiAnns -> Map (RealSrcSpan, AnnKeywordId) [RealSrcSpan]
apiAnnItems ApiAnns
anns
        ann_key :: (RealSrcSpan, AnnKeywordId)
ann_key = (RealSrcSpan
span,AnnKeywordId
ann)

-- |Retrieve the comments allocated to the current 'SrcSpan'
--
--  Note: A given 'SrcSpan' may appear in multiple AST elements,
--  beware of duplicates
getAnnotationComments :: ApiAnns -> RealSrcSpan -> [RealLocated AnnotationComment]
getAnnotationComments :: ApiAnns -> RealSrcSpan -> [RealLocated AnnotationComment]
getAnnotationComments ApiAnns
anns RealSrcSpan
span =
  case RealSrcSpan
-> Map RealSrcSpan [RealLocated AnnotationComment]
-> Maybe [RealLocated AnnotationComment]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup RealSrcSpan
span (ApiAnns -> Map RealSrcSpan [RealLocated AnnotationComment]
apiAnnComments ApiAnns
anns) of
    Just [RealLocated AnnotationComment]
cs -> [RealLocated AnnotationComment]
cs
    Maybe [RealLocated AnnotationComment]
Nothing -> []

-- |Retrieve the comments allocated to the current 'SrcSpan', and
-- remove them from the annotations
getAndRemoveAnnotationComments :: ApiAnns -> RealSrcSpan
                               -> ([RealLocated AnnotationComment],ApiAnns)
getAndRemoveAnnotationComments :: ApiAnns
-> RealSrcSpan -> ([RealLocated AnnotationComment], ApiAnns)
getAndRemoveAnnotationComments ApiAnns
anns RealSrcSpan
span =
  case RealSrcSpan
-> Map RealSrcSpan [RealLocated AnnotationComment]
-> Maybe [RealLocated AnnotationComment]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup RealSrcSpan
span Map RealSrcSpan [RealLocated AnnotationComment]
ann_comments of
    Just [RealLocated AnnotationComment]
cs -> ([RealLocated AnnotationComment]
cs, ApiAnns
anns{ apiAnnComments :: Map RealSrcSpan [RealLocated AnnotationComment]
apiAnnComments = RealSrcSpan
-> Map RealSrcSpan [RealLocated AnnotationComment]
-> Map RealSrcSpan [RealLocated AnnotationComment]
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete RealSrcSpan
span Map RealSrcSpan [RealLocated AnnotationComment]
ann_comments })
    Maybe [RealLocated AnnotationComment]
Nothing -> ([], ApiAnns
anns)
  where ann_comments :: Map RealSrcSpan [RealLocated AnnotationComment]
ann_comments = ApiAnns -> Map RealSrcSpan [RealLocated AnnotationComment]
apiAnnComments ApiAnns
anns

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

-- | API 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 captured in the existing
-- AST.
--
-- The annotations, together with original source comments are made
-- available in the @'pm_annotations'@ field of @'GHC.ParsedModule'@.
-- Comments are only retained if @'Opt_KeepRawTokenStream'@ is set in
-- @'GHC.Driver.Session.DynFlags'@ before parsing.
--
-- The wiki page describing this feature is
-- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations
--
-- Note: in general the names of these are taken from the
-- corresponding token, unless otherwise noted
-- See note [Api 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 -- ^ ')'
    | 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
    | AnnPercentOne -- ^ '%1' -- for HsLinearArrow
    | AnnNewtype
    | AnnName -- ^ where a name loses its location in the AST, this carries it
    | AnnOf
    | AnnOpen    -- ^ '(\#' or '{-\# LANGUAGE' etc
    | AnnOpenB   -- ^ '(|'
    | AnnOpenBU  -- ^ '(|', unicode variant
    | AnnOpenC   -- ^ '{'
    | AnnOpenE   -- ^ '[e|' or '[e||'
    | AnnOpenEQ  -- ^ '[|'
    | AnnOpenEQU -- ^ '[|', unicode variant
    | AnnOpenP   -- ^ '('
    | AnnOpenS   -- ^ '['
    | AnnDollar          -- ^ prefix '$'   -- TemplateHaskell
    | AnnDollarDollar    -- ^ prefix '$$'  -- TemplateHaskell
    | AnnPackageName
    | AnnPattern
    | AnnPercent -- ^ '%' -- for HsExplicitMult
    | 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)

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

data AnnotationComment =
  -- Documentation annotations
    AnnDocCommentNext  String     -- ^ something beginning '-- |'
  | AnnDocCommentPrev  String     -- ^ something beginning '-- ^'
  | AnnDocCommentNamed String     -- ^ something beginning '-- $'
  | AnnDocSection      Int String -- ^ a section heading
  | AnnDocOptions      String     -- ^ doc options (prune, ignore-exports, etc)
  | AnnLineComment     String     -- ^ comment starting by "--"
  | AnnBlockComment    String     -- ^ comment in {- -}
    deriving (AnnotationComment -> AnnotationComment -> Bool
(AnnotationComment -> AnnotationComment -> Bool)
-> (AnnotationComment -> AnnotationComment -> Bool)
-> Eq AnnotationComment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnotationComment -> AnnotationComment -> Bool
$c/= :: AnnotationComment -> AnnotationComment -> Bool
== :: AnnotationComment -> AnnotationComment -> Bool
$c== :: AnnotationComment -> AnnotationComment -> Bool
Eq, Eq AnnotationComment
Eq AnnotationComment
-> (AnnotationComment -> AnnotationComment -> Ordering)
-> (AnnotationComment -> AnnotationComment -> Bool)
-> (AnnotationComment -> AnnotationComment -> Bool)
-> (AnnotationComment -> AnnotationComment -> Bool)
-> (AnnotationComment -> AnnotationComment -> Bool)
-> (AnnotationComment -> AnnotationComment -> AnnotationComment)
-> (AnnotationComment -> AnnotationComment -> AnnotationComment)
-> Ord AnnotationComment
AnnotationComment -> AnnotationComment -> Bool
AnnotationComment -> AnnotationComment -> Ordering
AnnotationComment -> AnnotationComment -> AnnotationComment
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 :: AnnotationComment -> AnnotationComment -> AnnotationComment
$cmin :: AnnotationComment -> AnnotationComment -> AnnotationComment
max :: AnnotationComment -> AnnotationComment -> AnnotationComment
$cmax :: AnnotationComment -> AnnotationComment -> AnnotationComment
>= :: AnnotationComment -> AnnotationComment -> Bool
$c>= :: AnnotationComment -> AnnotationComment -> Bool
> :: AnnotationComment -> AnnotationComment -> Bool
$c> :: AnnotationComment -> AnnotationComment -> Bool
<= :: AnnotationComment -> AnnotationComment -> Bool
$c<= :: AnnotationComment -> AnnotationComment -> Bool
< :: AnnotationComment -> AnnotationComment -> Bool
$c< :: AnnotationComment -> AnnotationComment -> Bool
compare :: AnnotationComment -> AnnotationComment -> Ordering
$ccompare :: AnnotationComment -> AnnotationComment -> Ordering
Ord, Typeable AnnotationComment
Typeable AnnotationComment
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> AnnotationComment
    -> c AnnotationComment)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnotationComment)
-> (AnnotationComment -> Constr)
-> (AnnotationComment -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnotationComment))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnotationComment))
-> ((forall b. Data b => b -> b)
    -> AnnotationComment -> AnnotationComment)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> AnnotationComment -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> AnnotationComment -> m AnnotationComment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnotationComment -> m AnnotationComment)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnotationComment -> m AnnotationComment)
-> Data AnnotationComment
AnnotationComment -> DataType
AnnotationComment -> Constr
(forall b. Data b => b -> b)
-> AnnotationComment -> AnnotationComment
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) -> AnnotationComment -> u
forall u. (forall d. Data d => d -> u) -> AnnotationComment -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnotationComment
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnotationComment -> c AnnotationComment
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnotationComment)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnotationComment)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnotationComment -> m AnnotationComment
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnotationComment -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnotationComment -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnotationComment -> r
gmapT :: (forall b. Data b => b -> b)
-> AnnotationComment -> AnnotationComment
$cgmapT :: (forall b. Data b => b -> b)
-> AnnotationComment -> AnnotationComment
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnotationComment)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnotationComment)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnotationComment)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnotationComment)
dataTypeOf :: AnnotationComment -> DataType
$cdataTypeOf :: AnnotationComment -> DataType
toConstr :: AnnotationComment -> Constr
$ctoConstr :: AnnotationComment -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnotationComment
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnotationComment
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnotationComment -> c AnnotationComment
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnotationComment -> c AnnotationComment
Data, Int -> AnnotationComment -> ShowS
[AnnotationComment] -> ShowS
AnnotationComment -> String
(Int -> AnnotationComment -> ShowS)
-> (AnnotationComment -> String)
-> ([AnnotationComment] -> ShowS)
-> Show AnnotationComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnnotationComment] -> ShowS
$cshowList :: [AnnotationComment] -> ShowS
show :: AnnotationComment -> String
$cshow :: AnnotationComment -> String
showsPrec :: Int -> AnnotationComment -> ShowS
$cshowsPrec :: Int -> AnnotationComment -> 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 AnnotationComment where
  ppr :: AnnotationComment -> SDoc
ppr AnnotationComment
x = String -> SDoc
text (AnnotationComment -> String
forall a. Show a => a -> String
show AnnotationComment
x)

-- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen',
--             'GHC.Parser.Annotation.AnnClose','GHC.Parser.Annotation.AnnComma',
--             'GHC.Parser.Annotation.AnnRarrow'
--             'GHC.Parser.Annotation.AnnTilde'
--   - May have 'GHC.Parser.Annotation.AnnComma' when in a list
type LRdrName = Located RdrName


-- | 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
-- 'ApiAnnotation'
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)