{-# LANGUAGE DeriveDataTypeable #-}

module ApiAnnotation (
  getAnnotation, getAndRemoveAnnotation,
  getAnnotationComments,getAndRemoveAnnotationComments,
  ApiAnns,
  ApiAnnKey,
  AnnKeywordId(..),
  AnnotationComment(..),
  IsUnicodeSyntax(..),
  unicodeAnn,
  HasE(..),
  LRdrName -- Exists for haddocks only
  ) where

import GhcPrelude

import RdrName
import Outputable
import 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

> type ApiAnns = ( Map.Map ApiAnnKey [SrcSpan]                  -- non-comments
>                , Map.Map SrcSpan [Located AnnotationComment]) -- comments

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 SrcSpan 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 = (SrcSpan,AnnKeywordId)
>
> Map.Map ApiAnnKey [SrcSpan]

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 Parser
and RdrHsSyn (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 SrcSpan [Located AnnotationComment]

PARSER STATE

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

>  annotations :: [(ApiAnnKey,[SrcSpan])],
>  comment_q :: [Located AnnotationComment],
>  annotations_comments :: [(SrcSpan,[Located 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 SrcSpan in
annotations_comments).

PARSER EMISSION OF ANNOTATIONS

The parser interacts with the lexer using the function

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

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

This adds the annotation to the `annotations` field of `PState` and
transfers any comments in `comment_q` WHICH ARE ENCLOSED by
the SrcSpan 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://ghc.haskell.org/trac/ghc/wiki/ApiAnnotations

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

-- If you update this, update the Note [Api annotations] above
type ApiAnns = ( Map.Map ApiAnnKey [SrcSpan]
               , Map.Map SrcSpan [Located AnnotationComment])

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


-- | 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 -> SrcSpan -> AnnKeywordId -> [SrcSpan]
getAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> [SrcSpan]
getAnnotation (anns :: Map ApiAnnKey [SrcSpan]
anns,_) span :: SrcSpan
span ann :: AnnKeywordId
ann
   = case ApiAnnKey -> Map ApiAnnKey [SrcSpan] -> Maybe [SrcSpan]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (SrcSpan
span,AnnKeywordId
ann) Map ApiAnnKey [SrcSpan]
anns of
       Nothing -> []
       Just ss :: [SrcSpan]
ss -> [SrcSpan]
ss

-- | 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 -> SrcSpan -> AnnKeywordId
                       -> ([SrcSpan],ApiAnns)
getAndRemoveAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> ([SrcSpan], ApiAnns)
getAndRemoveAnnotation (anns :: Map ApiAnnKey [SrcSpan]
anns,cs :: Map SrcSpan [Located AnnotationComment]
cs) span :: SrcSpan
span ann :: AnnKeywordId
ann
   = case ApiAnnKey -> Map ApiAnnKey [SrcSpan] -> Maybe [SrcSpan]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (SrcSpan
span,AnnKeywordId
ann) Map ApiAnnKey [SrcSpan]
anns of
       Nothing -> ([],(Map ApiAnnKey [SrcSpan]
anns,Map SrcSpan [Located AnnotationComment]
cs))
       Just ss :: [SrcSpan]
ss -> ([SrcSpan]
ss,(ApiAnnKey -> Map ApiAnnKey [SrcSpan] -> Map ApiAnnKey [SrcSpan]
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete (SrcSpan
span,AnnKeywordId
ann) Map ApiAnnKey [SrcSpan]
anns,Map SrcSpan [Located AnnotationComment]
cs))

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

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

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

-- | 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
-- @'DynFlags.DynFlags'@ before parsing.
--
-- The wiki page describing this feature is
-- https://ghc.haskell.org/trac/ghc/wiki/ApiAnnotations
--
-- 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
    | AnnMdo
    | AnnMinus -- ^ '-'
    | AnnModule
    | 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   -- ^ '('
    | AnnOpenPE  -- ^ '$('
    | AnnOpenPTE -- ^ '$$('
    | AnnOpenS   -- ^ '['
    | AnnPackageName
    | AnnPattern
    | AnnProc
    | AnnQualified
    | AnnRarrow -- ^ '->'
    | AnnRarrowU -- ^ '->', unicode variant
    | AnnRec
    | AnnRole
    | AnnSafe
    | AnnSemi -- ^ ';'
    | AnnSimpleQuote -- ^ '''
    | AnnSignature
    | AnnStatic -- ^ 'static'
    | AnnStock
    | AnnThen
    | AnnThIdSplice -- ^ '$'
    | AnnThIdTySplice -- ^ '$$'
    | 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
    | AnnEofPos
    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
$cp1Ord :: Eq AnnKeywordId
Ord, Typeable AnnKeywordId
DataType
Constr
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 d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnKeywordId -> c AnnKeywordId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cAnnEofPos :: Constr
$cAnnRarrowtailU :: Constr
$cAnnRarrowtail :: Constr
$cAnnLarrowtailU :: Constr
$cAnnLarrowtail :: Constr
$cAnnrarrowtailU :: Constr
$cAnnrarrowtail :: Constr
$cAnnlarrowtailU :: Constr
$cAnnlarrowtail :: Constr
$cAnnWhere :: Constr
$cAnnVia :: Constr
$cAnnVbar :: Constr
$cAnnValStr :: Constr
$cAnnVal :: Constr
$cAnnUsing :: Constr
$cAnnUnit :: Constr
$cAnnType :: Constr
$cAnnTilde :: Constr
$cAnnThTyQuote :: Constr
$cAnnThIdTySplice :: Constr
$cAnnThIdSplice :: Constr
$cAnnThen :: Constr
$cAnnStock :: Constr
$cAnnStatic :: Constr
$cAnnSignature :: Constr
$cAnnSimpleQuote :: Constr
$cAnnSemi :: Constr
$cAnnSafe :: Constr
$cAnnRole :: Constr
$cAnnRec :: Constr
$cAnnRarrowU :: Constr
$cAnnRarrow :: Constr
$cAnnQualified :: Constr
$cAnnProc :: Constr
$cAnnPattern :: Constr
$cAnnPackageName :: Constr
$cAnnOpenS :: Constr
$cAnnOpenPTE :: Constr
$cAnnOpenPE :: Constr
$cAnnOpenP :: Constr
$cAnnOpenEQU :: Constr
$cAnnOpenEQ :: Constr
$cAnnOpenE :: Constr
$cAnnOpenC :: Constr
$cAnnOpenBU :: Constr
$cAnnOpenB :: Constr
$cAnnOpen :: Constr
$cAnnOf :: Constr
$cAnnName :: Constr
$cAnnNewtype :: Constr
$cAnnModule :: Constr
$cAnnMinus :: Constr
$cAnnMdo :: Constr
$cAnnLet :: Constr
$cAnnLarrowU :: Constr
$cAnnLarrow :: Constr
$cAnnLam :: Constr
$cAnnInstance :: Constr
$cAnnInfix :: Constr
$cAnnIn :: Constr
$cAnnImport :: Constr
$cAnnIf :: Constr
$cAnnHiding :: Constr
$cAnnHeader :: Constr
$cAnnGroup :: Constr
$cAnnFunId :: Constr
$cAnnForeign :: Constr
$cAnnForallU :: Constr
$cAnnForall :: Constr
$cAnnFamily :: Constr
$cAnnExport :: Constr
$cAnnEqual :: Constr
$cAnnElse :: Constr
$cAnnDotdot :: Constr
$cAnnDot :: Constr
$cAnnDo :: Constr
$cAnnDeriving :: Constr
$cAnnDefault :: Constr
$cAnnDcolonU :: Constr
$cAnnDcolon :: Constr
$cAnnData :: Constr
$cAnnDarrowU :: Constr
$cAnnDarrow :: Constr
$cAnnCommaTuple :: Constr
$cAnnComma :: Constr
$cAnnColon :: Constr
$cAnnCloseS :: Constr
$cAnnCloseP :: Constr
$cAnnCloseQU :: Constr
$cAnnCloseQ :: Constr
$cAnnCloseC :: Constr
$cAnnCloseBU :: Constr
$cAnnCloseB :: Constr
$cAnnClose :: Constr
$cAnnClass :: Constr
$cAnnCase :: Constr
$cAnnBy :: Constr
$cAnnBackquote :: Constr
$cAnnBang :: Constr
$cAnnAt :: Constr
$cAnnAs :: Constr
$cAnnAnyclass :: Constr
$tAnnKeywordId :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnKeywordId -> u
gmapQ :: (forall d. Data d => d -> u) -> AnnKeywordId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnKeywordId -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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 x :: 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
$cp1Ord :: Eq AnnotationComment
Ord, Typeable AnnotationComment
DataType
Constr
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 d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnotationComment -> c AnnotationComment
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cAnnBlockComment :: Constr
$cAnnLineComment :: Constr
$cAnnDocOptions :: Constr
$cAnnDocSection :: Constr
$cAnnDocCommentNamed :: Constr
$cAnnDocCommentPrev :: Constr
$cAnnDocCommentNext :: Constr
$tAnnotationComment :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnotationComment -> u
gmapQ :: (forall d. Data d => d -> u) -> AnnotationComment -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnotationComment -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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 Lexer.x and bringing it in here would create a loop

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

-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen',
--             'ApiAnnotation.AnnClose','ApiAnnotation.AnnComma',
--             'ApiAnnotation.AnnRarrow'
--             'ApiAnnotation.AnnTilde'
--   - May have 'ApiAnnotation.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
$cp1Ord :: Eq IsUnicodeSyntax
Ord, Typeable IsUnicodeSyntax
DataType
Constr
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 d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsUnicodeSyntax -> c IsUnicodeSyntax
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cNormalSyntax :: Constr
$cUnicodeSyntax :: Constr
$tIsUnicodeSyntax :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> IsUnicodeSyntax -> u
gmapQ :: (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IsUnicodeSyntax -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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 AnnForall     = AnnKeywordId
AnnForallU
unicodeAnn AnnDcolon     = AnnKeywordId
AnnDcolonU
unicodeAnn AnnLarrow     = AnnKeywordId
AnnLarrowU
unicodeAnn AnnRarrow     = AnnKeywordId
AnnRarrowU
unicodeAnn AnnDarrow     = AnnKeywordId
AnnDarrowU
unicodeAnn Annlarrowtail = AnnKeywordId
AnnlarrowtailU
unicodeAnn Annrarrowtail = AnnKeywordId
AnnrarrowtailU
unicodeAnn AnnLarrowtail = AnnKeywordId
AnnLarrowtailU
unicodeAnn AnnRarrowtail = AnnKeywordId
AnnRarrowtailU
unicodeAnn AnnOpenB      = AnnKeywordId
AnnOpenBU
unicodeAnn AnnCloseB     = AnnKeywordId
AnnCloseBU
unicodeAnn AnnOpenEQ     = AnnKeywordId
AnnOpenEQU
unicodeAnn AnnCloseQ     = AnnKeywordId
AnnCloseQU
unicodeAnn ann :: 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
$cp1Ord :: Eq HasE
Ord, Typeable HasE
DataType
Constr
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 d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HasE -> c HasE
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cNoE :: Constr
$cHasE :: Constr
$tHasE :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> HasE -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HasE -> u
gmapQ :: (forall d. Data d => d -> u) -> HasE -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HasE -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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)