{-# LANGUAGE CPP                       #-}
{-# LANGUAGE ConstraintKinds           #-}
{-# LANGUAGE DataKinds                 #-}
{-# LANGUAGE DeriveDataTypeable        #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts          #-}
{-# LANGUAGE FlexibleInstances         #-}
{-# LANGUAGE LambdaCase                #-}
{-# LANGUAGE MultiParamTypeClasses     #-}
{-# LANGUAGE ScopedTypeVariables       #-}
{-# LANGUAGE StandaloneDeriving        #-}
{-# LANGUAGE TypeApplications          #-}
{-# LANGUAGE TypeFamilyDependencies    #-}
{-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow]
                                      -- in module Language.Haskell.Syntax.Extension

{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-} -- Outputable

{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
-}

-- | Abstract Haskell syntax for expressions.
module GHC.Hs.Expr
  ( module Language.Haskell.Syntax.Expr
  , module GHC.Hs.Expr
  ) where

import Language.Haskell.Syntax.Expr

-- friends:
import GHC.Prelude

import GHC.Hs.Decls
import GHC.Hs.Pat
import GHC.Hs.Lit
import Language.Haskell.Syntax.Extension
import GHC.Hs.Extension
import GHC.Hs.Type
import GHC.Hs.Binds
import GHC.Parser.Annotation

-- others:
import GHC.Tc.Types.Evidence
import GHC.Core.DataCon (FieldLabelString)
import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Types.Basic
import GHC.Types.Fixity
import GHC.Types.SourceText
import GHC.Types.SrcLoc
import GHC.Types.Tickish (CoreTickish)
import GHC.Core.ConLike
import GHC.Unit.Module (ModuleName)
import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Core.Type
import GHC.Builtin.Types (mkTupleStr)
import GHC.Tc.Utils.TcType (TcType, TcTyVar)
import {-# SOURCE #-} GHC.Tc.Types (TcLclEnv)

-- libraries:
import Data.Data hiding (Fixity(..))
import qualified Data.Data as Data (Fixity(..))
import qualified Data.Kind
import Data.Maybe (isJust)
import Data.Foldable ( toList )
import Data.List (uncons)
import Data.Bifunctor (first)

{- *********************************************************************
*                                                                      *
                Expressions proper
*                                                                      *
********************************************************************* -}

-- | Post-Type checking Expression
--
-- PostTcExpr is an evidence expression attached to the syntax tree by the
-- type checker (c.f. postTcType).
type PostTcExpr  = HsExpr GhcTc

-- | Post-Type checking Table
--
-- We use a PostTcTable where there are a bunch of pieces of evidence, more
-- than is convenient to keep individually.
type PostTcTable = [(Name, PostTcExpr)]

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

-- Defining SyntaxExpr in two stages allows for better type inference, because
-- we can declare SyntaxExprGhc to be injective (and closed). Without injectivity,
-- noSyntaxExpr would be ambiguous.
type instance SyntaxExpr (GhcPass p) = SyntaxExprGhc p

type family SyntaxExprGhc (p :: Pass) = (r :: Data.Kind.Type) | r -> p where
  SyntaxExprGhc 'Parsed      = NoExtField
  SyntaxExprGhc 'Renamed     = SyntaxExprRn
  SyntaxExprGhc 'Typechecked = SyntaxExprTc

-- | The function to use in rebindable syntax. See Note [NoSyntaxExpr].
data SyntaxExprRn = SyntaxExprRn (HsExpr GhcRn)
    -- Why is the payload not just a Name?
    -- See Note [Monad fail : Rebindable syntax, overloaded strings] in "GHC.Rename.Expr"
                  | NoSyntaxExprRn

-- | An expression with wrappers, used for rebindable syntax
--
-- This should desugar to
--
-- > syn_res_wrap $ syn_expr (syn_arg_wraps[0] arg0)
-- >                         (syn_arg_wraps[1] arg1) ...
--
-- where the actual arguments come from elsewhere in the AST.
data SyntaxExprTc = SyntaxExprTc { SyntaxExprTc -> HsExpr GhcTc
syn_expr      :: HsExpr GhcTc
                                 , SyntaxExprTc -> [HsWrapper]
syn_arg_wraps :: [HsWrapper]
                                 , SyntaxExprTc -> HsWrapper
syn_res_wrap  :: HsWrapper }
                  | NoSyntaxExprTc  -- See Note [NoSyntaxExpr]

-- | This is used for rebindable-syntax pieces that are too polymorphic
-- for tcSyntaxOp (trS_fmap and the mzip in ParStmt)
noExpr :: HsExpr (GhcPass p)
noExpr :: forall (p :: Pass). HsExpr (GhcPass p)
noExpr = XLitE (GhcPass p) -> HsLit (GhcPass p) -> HsExpr (GhcPass p)
forall p. XLitE p -> HsLit p -> HsExpr p
HsLit XLitE (GhcPass p)
EpAnnCO
noComments (XHsString (GhcPass p) -> FastString -> HsLit (GhcPass p)
forall x. XHsString x -> FastString -> HsLit x
HsString (String -> SourceText
SourceText  String
"noExpr") (String -> FastString
fsLit String
"noExpr"))

noSyntaxExpr :: forall p. IsPass p => SyntaxExpr (GhcPass p)
                              -- Before renaming, and sometimes after
                              -- See Note [NoSyntaxExpr]
noSyntaxExpr :: forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
  GhcPass p
GhcPs -> NoExtField
SyntaxExpr (GhcPass p)
noExtField
  GhcPass p
GhcRn -> SyntaxExpr (GhcPass p)
SyntaxExprRn
NoSyntaxExprRn
  GhcPass p
GhcTc -> SyntaxExpr (GhcPass p)
SyntaxExprTc
NoSyntaxExprTc

-- | Make a 'SyntaxExpr GhcRn' from an expression
-- Used only in getMonadFailOp.
-- See Note [Monad fail : Rebindable syntax, overloaded strings] in "GHC.Rename.Expr"
mkSyntaxExpr :: HsExpr GhcRn -> SyntaxExprRn
mkSyntaxExpr :: HsExpr GhcRn -> SyntaxExprRn
mkSyntaxExpr = HsExpr GhcRn -> SyntaxExprRn
SyntaxExprRn

-- | Make a 'SyntaxExpr' from a 'Name' (the "rn" is because this is used in the
-- renamer).
mkRnSyntaxExpr :: Name -> SyntaxExprRn
mkRnSyntaxExpr :: Name -> SyntaxExprRn
mkRnSyntaxExpr Name
name = HsExpr GhcRn -> SyntaxExprRn
SyntaxExprRn (HsExpr GhcRn -> SyntaxExprRn) -> HsExpr GhcRn -> SyntaxExprRn
forall a b. (a -> b) -> a -> b
$ XVar GhcRn -> XRec GhcRn (IdP GhcRn) -> HsExpr GhcRn
forall p. XVar p -> LIdP p -> HsExpr p
HsVar XVar GhcRn
NoExtField
noExtField (XRec GhcRn (IdP GhcRn) -> HsExpr GhcRn)
-> XRec GhcRn (IdP GhcRn) -> HsExpr GhcRn
forall a b. (a -> b) -> a -> b
$ Name -> GenLocated SrcSpanAnnN Name
forall a an. a -> LocatedAn an a
noLocA Name
name

instance Outputable SyntaxExprRn where
  ppr :: SyntaxExprRn -> SDoc
ppr (SyntaxExprRn HsExpr GhcRn
expr) = HsExpr GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcRn
expr
  ppr SyntaxExprRn
NoSyntaxExprRn      = String -> SDoc
text String
"<no syntax expr>"

instance Outputable SyntaxExprTc where
  ppr :: SyntaxExprTc -> SDoc
ppr (SyntaxExprTc { syn_expr :: SyntaxExprTc -> HsExpr GhcTc
syn_expr      = HsExpr GhcTc
expr
                    , syn_arg_wraps :: SyntaxExprTc -> [HsWrapper]
syn_arg_wraps = [HsWrapper]
arg_wraps
                    , syn_res_wrap :: SyntaxExprTc -> HsWrapper
syn_res_wrap  = HsWrapper
res_wrap })
    = (SDocContext -> Bool) -> (Bool -> SDoc) -> SDoc
forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintExplicitCoercions ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
print_co ->
      (Bool -> SDoc) -> SDoc
getPprDebug ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
debug ->
      if Bool
debug Bool -> Bool -> Bool
|| Bool
print_co
      then HsExpr GhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcTc
expr SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
braces ((HsWrapper -> SDoc) -> [HsWrapper] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas HsWrapper -> SDoc
forall a. Outputable a => a -> SDoc
ppr [HsWrapper]
arg_wraps)
                    SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
braces (HsWrapper -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsWrapper
res_wrap)
      else HsExpr GhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcTc
expr

  ppr SyntaxExprTc
NoSyntaxExprTc = String -> SDoc
text String
"<no syntax expr>"

-- | Extra data fields for a 'RecordUpd', added by the type checker
data RecordUpdTc = RecordUpdTc
      { RecordUpdTc -> [ConLike]
rupd_cons :: [ConLike]
                -- Filled in by the type checker to the
                -- _non-empty_ list of DataCons that have
                -- all the upd'd fields

      , RecordUpdTc -> [Type]
rupd_in_tys  :: [Type]  -- Argument types of *input* record type
      , RecordUpdTc -> [Type]
rupd_out_tys :: [Type]  --             and  *output* record type
                -- For a data family, these are the type args of the
                -- /representation/ type constructor

      , RecordUpdTc -> HsWrapper
rupd_wrap :: HsWrapper  -- See Note [Record Update HsWrapper]
      }

-- | HsWrap appears only in typechecker output
data HsWrap hs_syn = HsWrap HsWrapper      -- the wrapper
                            (hs_syn GhcTc) -- the thing that is wrapped

deriving instance (Data (hs_syn GhcTc), Typeable hs_syn) => Data (HsWrap hs_syn)

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

{-
Note [The life cycle of a TH quotation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When desugaring a bracket (aka quotation), we want to produce Core
code that, when run, will produce the TH syntax tree for the quotation.
To that end, we want to desugar /renamed/ but not /typechecked/ code;
the latter is cluttered with the typechecker's elaboration that should
not appear in the TH syntax tree. So in (HsExpr GhcTc) tree, we must
have a (HsExpr GhcRn) for the quotation itself.

As such, when typechecking both typed and untyped brackets,
we keep a /renamed/ bracket in the extension field.

The HsBracketTc, the GhcTc ext field for both brackets, contains:
  - The renamed quote :: HsQuote GhcRn -- for the desugarer
  - [PendingTcSplice]
  - The type of the quote
  - Maybe QuoteWrapper

Note that (HsBracketTc) stores the untyped (HsQuote GhcRn) for both typed and
untyped brackets. They are treated uniformly by the desugarer, and we can
easily construct untyped brackets from typed ones (with ExpBr).

Typed quotes
~~~~~~~~~~~~
Here is the life cycle of a /typed/ quote [|| e ||], whose datacon is
  HsTypedBracket   (XTypedBracket p)   (LHsExpr p)

  In pass p   (XTypedBracket p)       (LHsExpr p)
  -------------------------------------------
  GhcPs   Annotations only            LHsExpr GhcPs
  GhcRn   Annotations only            LHsExpr GhcRn
  GhcTc   HsBracketTc                 LHsExpr GhcTc: unused!

Note that in the GhcTc tree, the second field (HsExpr GhcTc)
is entirely unused; the desugarer uses the (HsExpr GhcRn) from the
first field.

Untyped quotes
~~~~~~~~~~~~~~
Here is the life cycle of an /untyped/ quote, whose datacon is
   HsUntypedBracket (XUntypedBracket p) (HsQuote p)

Here HsQuote is a sum-type of expressions [| e |], patterns [| p |],
types [| t |] etc.

  In pass p   (XUntypedBracket p)          (HsQuote p)
  -------------------------------------------------------
  GhcPs   Annotations only                 HsQuote GhcPs
  GhcRn   Annotations, [PendingRnSplice]   HsQuote GhcRn
  GhcTc   HsBracketTc                      HsQuote GhcTc: unused!

The difficulty is: the typechecker does not typecheck the body of an
untyped quote, so how do we make a (HsQuote GhcTc) to put in the
second field?

Answer: we use the extension constructor of HsQuote, XQuote, and make
all the other constructors into DataConCantHappen.  That is, the only
non-bottom value of type (HsQuote GhcTc) is (XQuote noExtField). Hence
the instances
  type instance XExpBr GhcTc = DataConCantHappen
  ...etc...

See the related Note [How brackets and nested splices are handled] in GHC.Tc.Gen.Splice
-}

data HsBracketTc = HsBracketTc
  { HsBracketTc -> HsQuote GhcRn
brack_renamed_quote   :: (HsQuote GhcRn)      -- See Note [The life cycle of a TH quotation]
  , HsBracketTc -> Type
brack_ty              :: Type
  , HsBracketTc -> Maybe QuoteWrapper
brack_quote_wrapper   :: (Maybe QuoteWrapper) -- The wrapper to apply type and dictionary argument to the quote.
  , HsBracketTc -> [PendingTcSplice]
brack_pending_splices :: [PendingTcSplice]    -- Output of the type checker is the *original*
                                                  -- renamed expression, plus
                                                  -- _typechecked_ splices to be
                                                  -- pasted back in by the desugarer
  }

type instance XTypedBracket GhcPs = EpAnn [AddEpAnn]
type instance XTypedBracket GhcRn = NoExtField
type instance XTypedBracket GhcTc = HsBracketTc
type instance XUntypedBracket GhcPs = EpAnn [AddEpAnn]
type instance XUntypedBracket GhcRn = [PendingRnSplice] -- See Note [Pending Splices]
                                                        -- Output of the renamer is the *original* renamed expression,
                                                        -- plus _renamed_ splices to be type checked
type instance XUntypedBracket GhcTc = HsBracketTc

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

-- API Annotations types

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

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

type instance XVar           (GhcPass _) = NoExtField

-- Record selectors at parse time are HsVar; they convert to HsRecSel
-- on renaming.
type instance XRecSel              GhcPs = DataConCantHappen
type instance XRecSel              GhcRn = NoExtField
type instance XRecSel              GhcTc = NoExtField

type instance XLam           (GhcPass _) = NoExtField

-- OverLabel not present in GhcTc pass; see GHC.Rename.Expr
-- Note [Handling overloaded and rebindable constructs]
type instance XOverLabel     GhcPs = EpAnnCO
type instance XOverLabel     GhcRn = EpAnnCO
type instance XOverLabel     GhcTc = DataConCantHappen

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

type instance XVar           (GhcPass _) = NoExtField

type instance XUnboundVar    GhcPs = EpAnn EpAnnUnboundVar
type instance XUnboundVar    GhcRn = NoExtField
type instance XUnboundVar    GhcTc = HoleExprRef
  -- We really don't need the whole HoleExprRef; just the IORef EvTerm
  -- would be enough. But then deriving a Data instance becomes impossible.
  -- Much, much easier just to define HoleExprRef with a Data instance and
  -- store the whole structure.

type instance XIPVar         GhcPs = EpAnnCO
type instance XIPVar         GhcRn = EpAnnCO
type instance XIPVar         GhcTc = DataConCantHappen
type instance XOverLitE      (GhcPass _) = EpAnnCO
type instance XLitE          (GhcPass _) = EpAnnCO

type instance XLam           (GhcPass _) = NoExtField

type instance XLamCase       (GhcPass _) = EpAnn [AddEpAnn]

type instance XApp           (GhcPass _) = EpAnnCO

type instance XAppTypeE      GhcPs = SrcSpan -- Where the `@` lives
type instance XAppTypeE      GhcRn = NoExtField
type instance XAppTypeE      GhcTc = Type

-- OpApp not present in GhcTc pass; see GHC.Rename.Expr
-- Note [Handling overloaded and rebindable constructs]
type instance XOpApp         GhcPs = EpAnn [AddEpAnn]
type instance XOpApp         GhcRn = Fixity
type instance XOpApp         GhcTc = DataConCantHappen

-- SectionL, SectionR not present in GhcTc pass; see GHC.Rename.Expr
-- Note [Handling overloaded and rebindable constructs]
type instance XSectionL      GhcPs = EpAnnCO
type instance XSectionR      GhcPs = EpAnnCO
type instance XSectionL      GhcRn = EpAnnCO
type instance XSectionR      GhcRn = EpAnnCO
type instance XSectionL      GhcTc = DataConCantHappen
type instance XSectionR      GhcTc = DataConCantHappen


type instance XNegApp        GhcPs = EpAnn [AddEpAnn]
type instance XNegApp        GhcRn = NoExtField
type instance XNegApp        GhcTc = NoExtField

type instance XPar           (GhcPass _) = EpAnnCO

type instance XExplicitTuple GhcPs = EpAnn [AddEpAnn]
type instance XExplicitTuple GhcRn = NoExtField
type instance XExplicitTuple GhcTc = NoExtField

type instance XExplicitSum   GhcPs = EpAnn AnnExplicitSum
type instance XExplicitSum   GhcRn = NoExtField
type instance XExplicitSum   GhcTc = [Type]

type instance XCase          GhcPs = EpAnn EpAnnHsCase
type instance XCase          GhcRn = NoExtField
type instance XCase          GhcTc = NoExtField

type instance XIf            GhcPs = EpAnn AnnsIf
type instance XIf            GhcRn = NoExtField
type instance XIf            GhcTc = NoExtField

type instance XMultiIf       GhcPs = EpAnn [AddEpAnn]
type instance XMultiIf       GhcRn = NoExtField
type instance XMultiIf       GhcTc = Type

type instance XLet           GhcPs = EpAnnCO
type instance XLet           GhcRn = NoExtField
type instance XLet           GhcTc = NoExtField

type instance XDo            GhcPs = EpAnn AnnList
type instance XDo            GhcRn = NoExtField
type instance XDo            GhcTc = Type

type instance XExplicitList  GhcPs = EpAnn AnnList
type instance XExplicitList  GhcRn = NoExtField
type instance XExplicitList  GhcTc = Type
-- GhcPs: ExplicitList includes all source-level
--   list literals, including overloaded ones
-- GhcRn and GhcTc: ExplicitList used only for list literals
--   that denote Haskell's built-in lists.  Overloaded lists
--   have been expanded away in the renamer
-- See Note [Handling overloaded and rebindable constructs]
-- in  GHC.Rename.Expr

type instance XRecordCon     GhcPs = EpAnn [AddEpAnn]
type instance XRecordCon     GhcRn = NoExtField
type instance XRecordCon     GhcTc = PostTcExpr   -- Instantiated constructor function

type instance XRecordUpd     GhcPs = EpAnn [AddEpAnn]
type instance XRecordUpd     GhcRn = NoExtField
type instance XRecordUpd     GhcTc = RecordUpdTc

type instance XGetField     GhcPs = EpAnnCO
type instance XGetField     GhcRn = NoExtField
type instance XGetField     GhcTc = DataConCantHappen
-- HsGetField is eliminated by the renamer. See [Handling overloaded
-- and rebindable constructs].

type instance XProjection     GhcPs = EpAnn AnnProjection
type instance XProjection     GhcRn = NoExtField
type instance XProjection     GhcTc = DataConCantHappen
-- HsProjection is eliminated by the renamer. See [Handling overloaded
-- and rebindable constructs].

type instance XExprWithTySig GhcPs = EpAnn [AddEpAnn]
type instance XExprWithTySig GhcRn = NoExtField
type instance XExprWithTySig GhcTc = NoExtField

type instance XArithSeq      GhcPs = EpAnn [AddEpAnn]
type instance XArithSeq      GhcRn = NoExtField
type instance XArithSeq      GhcTc = PostTcExpr

type instance XSpliceE       (GhcPass _) = EpAnnCO
type instance XProc          (GhcPass _) = EpAnn [AddEpAnn]

type instance XStatic        GhcPs = EpAnn [AddEpAnn]
type instance XStatic        GhcRn = NameSet
type instance XStatic        GhcTc = (NameSet, Type)
  -- Free variables and type of expression, this is stored for convenience as wiring in
  -- StaticPtr is a bit tricky (see #20150)

type instance XPragE         (GhcPass _) = NoExtField

type instance Anno [LocatedA ((StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr)))))] = SrcSpanAnnL
type instance Anno (StmtLR GhcRn GhcRn (LocatedA (body GhcRn))) = SrcSpanAnnA

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

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

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

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

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

type instance XSCC           (GhcPass _) = EpAnn AnnPragma
type instance XXPragE        (GhcPass _) = DataConCantHappen

type instance XCDotFieldOcc (GhcPass _) = EpAnn AnnFieldLabel
type instance XXDotFieldOcc (GhcPass _) = DataConCantHappen

type instance XPresent         (GhcPass _) = EpAnn [AddEpAnn]

type instance XMissing         GhcPs = EpAnn EpaLocation
type instance XMissing         GhcRn = NoExtField
type instance XMissing         GhcTc = Scaled Type

type instance XXTupArg         (GhcPass _) = DataConCantHappen

tupArgPresent :: HsTupArg (GhcPass p) -> Bool
tupArgPresent :: forall (p :: Pass). HsTupArg (GhcPass p) -> Bool
tupArgPresent (Present {}) = Bool
True
tupArgPresent (Missing {}) = Bool
False


{- *********************************************************************
*                                                                      *
            XXExpr: the extension constructor of HsExpr
*                                                                      *
********************************************************************* -}

type instance XXExpr GhcPs = DataConCantHappen
type instance XXExpr GhcRn = HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
type instance XXExpr GhcTc = XXExprGhcTc
-- HsExpansion: see Note [Rebindable syntax and HsExpansion] below


data XXExprGhcTc
  = WrapExpr        -- Type and evidence application and abstractions
      {-# UNPACK #-} !(HsWrap HsExpr)

  | ExpansionExpr   -- See Note [Rebindable syntax and HsExpansion] below
      {-# UNPACK #-} !(HsExpansion (HsExpr GhcRn) (HsExpr GhcTc))

  | ConLikeTc      -- Result of typechecking a data-con
                   -- See Note [Typechecking data constructors] in
                   --     GHC.Tc.Gen.Head
                   -- The two arguments describe how to eta-expand
                   -- the data constructor when desugaring
        ConLike [TcTyVar] [Scaled TcType]

  ---------------------------------------
  -- Haskell program coverage (Hpc) Support

  | HsTick
     CoreTickish
     (LHsExpr GhcTc)                    -- sub-expression

  | HsBinTick
     Int                                -- module-local tick number for True
     Int                                -- module-local tick number for False
     (LHsExpr GhcTc)                    -- sub-expression


{- *********************************************************************
*                                                                      *
            Pretty-printing expressions
*                                                                      *
********************************************************************* -}

instance (OutputableBndrId p) => Outputable (HsExpr (GhcPass p)) where
    ppr :: HsExpr (GhcPass p) -> SDoc
ppr HsExpr (GhcPass p)
expr = HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr (GhcPass p)
expr

-----------------------
-- pprExpr, pprLExpr, pprBinds call pprDeeper;
-- the underscore versions do not
pprLExpr :: (OutputableBndrId p) => LHsExpr (GhcPass p) -> SDoc
pprLExpr :: forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
pprLExpr (L SrcSpanAnnA
_ HsExpr (GhcPass p)
e) = HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr (GhcPass p)
e

pprExpr :: (OutputableBndrId p) => HsExpr (GhcPass p) -> SDoc
pprExpr :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr (GhcPass p)
e | HsExpr (GhcPass p) -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr (GhcPass p)
e Bool -> Bool -> Bool
|| HsExpr (GhcPass p) -> Bool
forall id. HsExpr id -> Bool
isQuietHsExpr HsExpr (GhcPass p)
e =            HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
e
          | Bool
otherwise                           = SDoc -> SDoc
pprDeeper (HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
e)

isQuietHsExpr :: HsExpr id -> Bool
-- Parentheses do display something, but it gives little info and
-- if we go deeper when we go inside them then we get ugly things
-- like (...)
isQuietHsExpr :: forall id. HsExpr id -> Bool
isQuietHsExpr (HsPar {})        = Bool
True
-- applications don't display anything themselves
isQuietHsExpr (HsApp {})        = Bool
True
isQuietHsExpr (HsAppType {})    = Bool
True
isQuietHsExpr (OpApp {})        = Bool
True
isQuietHsExpr HsExpr id
_ = Bool
False

pprBinds :: (OutputableBndrId idL, OutputableBndrId idR)
         => HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds :: forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBindsLR (GhcPass idL) (GhcPass idR)
b = SDoc -> SDoc
pprDeeper (HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsLocalBindsLR (GhcPass idL) (GhcPass idR)
b)

-----------------------
ppr_lexpr :: (OutputableBndrId p) => LHsExpr (GhcPass p) -> SDoc
ppr_lexpr :: forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
e = HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e)

ppr_expr :: forall p. (OutputableBndrId p)
         => HsExpr (GhcPass p) -> SDoc
ppr_expr :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr (HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v))   = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
v
ppr_expr (HsUnboundVar XUnboundVar (GhcPass p)
_ OccName
uv) = OccName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc OccName
uv
ppr_expr (HsRecSel XRecSel (GhcPass p)
_ FieldOcc (GhcPass p)
f)      = FieldOcc (GhcPass p) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc FieldOcc (GhcPass p)
f
ppr_expr (HsIPVar XIPVar (GhcPass p)
_ HsIPName
v)       = HsIPName -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsIPName
v
ppr_expr (HsOverLabel XOverLabel (GhcPass p)
_ FastString
l)   = Char -> SDoc
char Char
'#' SDoc -> SDoc -> SDoc
<> FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
l
ppr_expr (HsLit XLitE (GhcPass p)
_ HsLit (GhcPass p)
lit)       = HsLit (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsLit (GhcPass p)
lit
ppr_expr (HsOverLit XOverLitE (GhcPass p)
_ HsOverLit (GhcPass p)
lit)   = HsOverLit (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsOverLit (GhcPass p)
lit
ppr_expr (HsPar XPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e LHsToken ")" (GhcPass p)
_)     = SDoc -> SDoc
parens (XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
e)

ppr_expr (HsPragE XPragE (GhcPass p)
_ HsPragE (GhcPass p)
prag XRec (GhcPass p) (HsExpr (GhcPass p))
e) = [SDoc] -> SDoc
sep [HsPragE (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsPragE (GhcPass p)
prag, XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
e]

ppr_expr e :: HsExpr (GhcPass p)
e@(HsApp {})        = HsExpr (GhcPass p)
-> [Either
      (XRec (GhcPass p) (HsExpr (GhcPass p)))
      (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps HsExpr (GhcPass p)
e []
ppr_expr e :: HsExpr (GhcPass p)
e@(HsAppType {})    = HsExpr (GhcPass p)
-> [Either
      (XRec (GhcPass p) (HsExpr (GhcPass p)))
      (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps HsExpr (GhcPass p)
e []

ppr_expr (OpApp XOpApp (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e1 XRec (GhcPass p) (HsExpr (GhcPass p))
op XRec (GhcPass p) (HsExpr (GhcPass p))
e2)
  | Just SDoc
pp_op <- HsExpr (GhcPass p) -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op)
  = SDoc -> SDoc
pp_infixly SDoc
pp_op
  | Bool
otherwise
  = SDoc
pp_prefixly

  where
    pp_e1 :: SDoc
pp_e1 = PprPrec -> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
opPrec XRec (GhcPass p) (HsExpr (GhcPass p))
e1   -- In debug mode, add parens
    pp_e2 :: SDoc
pp_e2 = PprPrec -> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
opPrec XRec (GhcPass p) (HsExpr (GhcPass p))
e2   -- to make precedence clear

    pp_prefixly :: SDoc
pp_prefixly
      = SDoc -> Int -> SDoc -> SDoc
hang (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op) Int
2 ([SDoc] -> SDoc
sep [SDoc
pp_e1, SDoc
pp_e2])

    pp_infixly :: SDoc -> SDoc
pp_infixly SDoc
pp_op
      = SDoc -> Int -> SDoc -> SDoc
hang SDoc
pp_e1 Int
2 ([SDoc] -> SDoc
sep [SDoc
pp_op, Int -> SDoc -> SDoc
nest Int
2 SDoc
pp_e2])

ppr_expr (NegApp XNegApp (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e SyntaxExpr (GhcPass p)
_) = Char -> SDoc
char Char
'-' SDoc -> SDoc -> SDoc
<+> PprPrec -> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
appPrec XRec (GhcPass p) (HsExpr (GhcPass p))
e

ppr_expr (SectionL XSectionL (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr XRec (GhcPass p) (HsExpr (GhcPass p))
op)
  | Just SDoc
pp_op <- HsExpr (GhcPass p) -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op)
  = SDoc -> SDoc
pp_infixly SDoc
pp_op
  | Bool
otherwise
  = SDoc
pp_prefixly
  where
    pp_expr :: SDoc
pp_expr = PprPrec -> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
opPrec XRec (GhcPass p) (HsExpr (GhcPass p))
expr

    pp_prefixly :: SDoc
pp_prefixly = SDoc -> Int -> SDoc -> SDoc
hang ([SDoc] -> SDoc
hsep [String -> SDoc
text String
" \\ x_ ->", GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op])
                       Int
4 ([SDoc] -> SDoc
hsep [SDoc
pp_expr, String -> SDoc
text String
"x_ )"])

    pp_infixly :: SDoc -> SDoc
pp_infixly SDoc
v = ([SDoc] -> SDoc
sep [SDoc
pp_expr, SDoc
v])

ppr_expr (SectionR XSectionR (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
op XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
  | Just SDoc
pp_op <- HsExpr (GhcPass p) -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op)
  = SDoc -> SDoc
pp_infixly SDoc
pp_op
  | Bool
otherwise
  = SDoc
pp_prefixly
  where
    pp_expr :: SDoc
pp_expr = PprPrec -> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
opPrec XRec (GhcPass p) (HsExpr (GhcPass p))
expr

    pp_prefixly :: SDoc
pp_prefixly = SDoc -> Int -> SDoc -> SDoc
hang ([SDoc] -> SDoc
hsep [String -> SDoc
text String
"( \\ x_ ->", GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
op, String -> SDoc
text String
"x_"])
                       Int
4 (SDoc
pp_expr SDoc -> SDoc -> SDoc
<> SDoc
rparen)

    pp_infixly :: SDoc -> SDoc
pp_infixly SDoc
v = [SDoc] -> SDoc
sep [SDoc
v, SDoc
pp_expr]

ppr_expr (ExplicitTuple XExplicitTuple (GhcPass p)
_ [HsTupArg (GhcPass p)]
exprs Boxity
boxity)
    -- Special-case unary boxed tuples so that they are pretty-printed as
    -- `Solo x`, not `(x)`
  | [Present XPresent (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr] <- [HsTupArg (GhcPass p)]
exprs
  , Boxity
Boxed <- Boxity
boxity
  = [SDoc] -> SDoc
hsep [String -> SDoc
text (Boxity -> Int -> String
mkTupleStr Boxity
Boxed Int
1), GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr]
  | Bool
otherwise
  = TupleSort -> SDoc -> SDoc
tupleParens (Boxity -> TupleSort
boxityTupleSort Boxity
boxity) ([SDoc] -> SDoc
fcat ([HsTupArg (GhcPass p)] -> [SDoc]
forall {p :: Pass}.
(OutputableBndr (IdGhcP p),
 OutputableBndr (IdGhcP (NoGhcTcPass p)), IsPass p,
 Outputable (GenLocated (Anno (IdGhcP p)) (IdGhcP p)),
 Outputable
   (GenLocated
      (Anno (IdGhcP (NoGhcTcPass p))) (IdGhcP (NoGhcTcPass p)))) =>
[HsTupArg (GhcPass p)] -> [SDoc]
ppr_tup_args [HsTupArg (GhcPass p)]
exprs))
  where
    ppr_tup_args :: [HsTupArg (GhcPass p)] -> [SDoc]
ppr_tup_args []               = []
    ppr_tup_args (Present XPresent (GhcPass p)
_ LHsExpr (GhcPass p)
e : [HsTupArg (GhcPass p)]
es) = (LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
e SDoc -> SDoc -> SDoc
<> [HsTupArg (GhcPass p)] -> SDoc
forall {id}. [HsTupArg id] -> SDoc
punc [HsTupArg (GhcPass p)]
es) SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: [HsTupArg (GhcPass p)] -> [SDoc]
ppr_tup_args [HsTupArg (GhcPass p)]
es
    ppr_tup_args (Missing XMissing (GhcPass p)
_   : [HsTupArg (GhcPass p)]
es) = [HsTupArg (GhcPass p)] -> SDoc
forall {id}. [HsTupArg id] -> SDoc
punc [HsTupArg (GhcPass p)]
es SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: [HsTupArg (GhcPass p)] -> [SDoc]
ppr_tup_args [HsTupArg (GhcPass p)]
es

    punc :: [HsTupArg id] -> SDoc
punc (Present {} : [HsTupArg id]
_) = SDoc
comma SDoc -> SDoc -> SDoc
<> SDoc
space
    punc (Missing {} : [HsTupArg id]
_) = SDoc
comma
    punc (XTupArg {} : [HsTupArg id]
_) = SDoc
comma SDoc -> SDoc -> SDoc
<> SDoc
space
    punc []               = SDoc
empty

ppr_expr (ExplicitSum XExplicitSum (GhcPass p)
_ Int
alt Int
arity XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
  = String -> SDoc
text String
"(#" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
ppr_bars (Int
alt Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) SDoc -> SDoc -> SDoc
<+> GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr SDoc -> SDoc -> SDoc
<+> Int -> SDoc
ppr_bars (Int
arity Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
alt) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"#)"
  where
    ppr_bars :: Int -> SDoc
ppr_bars Int
n = [SDoc] -> SDoc
hsep (Int -> SDoc -> [SDoc]
forall a. Int -> a -> [a]
replicate Int
n (Char -> SDoc
char Char
'|'))

ppr_expr (HsLam XLam (GhcPass p)
_ MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches)
  = MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
matches

ppr_expr (HsLamCase XLamCase (GhcPass p)
_ LamCaseVariant
lc_variant MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches)
  = [SDoc] -> SDoc
sep [ [SDoc] -> SDoc
sep [LamCaseVariant -> SDoc
lamCaseKeyword LamCaseVariant
lc_variant],
          Int -> SDoc -> SDoc
nest Int
2 (MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
matches) ]

ppr_expr (HsCase XCase (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr matches :: MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches@(MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = L SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (Match (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts }))
  = [SDoc] -> SDoc
sep [ [SDoc] -> SDoc
sep [String -> SDoc
text String
"case", Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr), String -> SDoc
text String
"of"],
          SDoc
pp_alts ]
  where
    pp_alts :: SDoc
pp_alts | [GenLocated
   SrcSpanAnnA
   (Match (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [GenLocated
   SrcSpanAnnA
   (Match (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts = String -> SDoc
text String
"{}"
            | Bool
otherwise = Int -> SDoc -> SDoc
nest Int
2 (MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
matches)

ppr_expr (HsIf XIf (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e1 XRec (GhcPass p) (HsExpr (GhcPass p))
e2 XRec (GhcPass p) (HsExpr (GhcPass p))
e3)
  = [SDoc] -> SDoc
sep [[SDoc] -> SDoc
hsep [String -> SDoc
text String
"if", Int -> SDoc -> SDoc
nest Int
2 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1), String -> SDoc
text String
"then"],
         Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e2),
         String -> SDoc
text String
"else",
         Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e3)]

ppr_expr (HsMultiIf XMultiIf (GhcPass p)
_ [LGRHS (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))]
alts)
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"if") Int
3  ([SDoc] -> SDoc
vcat ((GenLocated
   (SrcAnn NoEpAnns)
   (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      (SrcAnn NoEpAnns)
      (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  (SrcAnn NoEpAnns)
  (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall {a} {p} {l}.
(Outputable a,
 Outputable (XRec p (StmtLR p p (XRec p (HsExpr p)))),
 Outputable (XXGRHS p a)) =>
GenLocated l (GRHS p a) -> SDoc
ppr_alt [LGRHS (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts))
  where ppr_alt :: GenLocated l (GRHS p a) -> SDoc
ppr_alt (L l
_ (GRHS XCGRHS p a
_ [XRec p (StmtLR p p (XRec p (HsExpr p)))]
guards a
expr)) =
          SDoc -> Int -> SDoc -> SDoc
hang SDoc
vbar Int
2 ([SDoc] -> SDoc
ppr_one [SDoc]
one_alt)
          where
            ppr_one :: [SDoc] -> SDoc
ppr_one [] = String -> SDoc
forall a. String -> a
panic String
"ppr_exp HsMultiIf"
            ppr_one (SDoc
h:[SDoc]
t) = SDoc -> Int -> SDoc -> SDoc
hang SDoc
h Int
2 ([SDoc] -> SDoc
sep [SDoc]
t)
            one_alt :: [SDoc]
one_alt = [ [XRec p (StmtLR p p (XRec p (HsExpr p)))] -> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [XRec p (StmtLR p p (XRec p (HsExpr p)))]
guards
                      , String -> SDoc
text String
"->" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
pprDeeper (a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
expr) ]
        ppr_alt (L l
_ (XGRHS XXGRHS p a
x)) = XXGRHS p a -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXGRHS p a
x

-- special case: let ... in let ...
ppr_expr (HsLet XLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ expr :: XRec (GhcPass p) (HsExpr (GhcPass p))
expr@(L SrcSpanAnnA
_ (HsLet XLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
_ LHsToken "in" (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
_)))
  = [SDoc] -> SDoc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"let") Int
2 ([SDoc] -> SDoc
hsep [HsLocalBinds (GhcPass p) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBinds (GhcPass p)
binds, String -> SDoc
text String
"in"]),
         XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
expr]

ppr_expr (HsLet XLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
  = [SDoc] -> SDoc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"let") Int
2 (HsLocalBinds (GhcPass p) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBinds (GhcPass p)
binds),
         SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"in")  Int
2 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr)]

ppr_expr (HsDo XDo (GhcPass p)
_ HsDoFlavour
do_or_list_comp (L SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts)) = HsDoFlavour
-> [LStmt
      (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))]
-> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
HsDoFlavour -> [LStmt (GhcPass p) body] -> SDoc
pprDo HsDoFlavour
do_or_list_comp [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts

ppr_expr (ExplicitList XExplicitList (GhcPass p)
_ [XRec (GhcPass p) (HsExpr (GhcPass p))]
exprs)
  = SDoc -> SDoc
brackets (([SDoc] -> SDoc) -> [SDoc] -> SDoc
pprDeeperList [SDoc] -> SDoc
fsep (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ((GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (HsExpr (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr [XRec (GhcPass p) (HsExpr (GhcPass p))]
[GenLocated SrcSpanAnnA (HsExpr (GhcPass p))]
exprs)))

ppr_expr (RecordCon { rcon_con :: forall p. HsExpr p -> XRec p (ConLikeP p)
rcon_con = XRec (GhcPass p) (ConLikeP (GhcPass p))
con, rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_flds = HsRecordBinds (GhcPass p)
rbinds })
  = SDoc -> Int -> SDoc -> SDoc
hang SDoc
pp_con Int
2 (HsRecFields
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr HsRecordBinds (GhcPass p)
HsRecFields
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
rbinds)
  where
    -- con :: ConLikeP (GhcPass p)
    -- so we need case analysis to know to print it
    pp_con :: SDoc
pp_con = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
               GhcPass p
GhcPs -> GenLocated SrcSpanAnnN RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (ConLikeP (GhcPass p))
GenLocated SrcSpanAnnN RdrName
con
               GhcPass p
GhcRn -> GenLocated SrcSpanAnnN Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (ConLikeP (GhcPass p))
GenLocated SrcSpanAnnN Name
con
               GhcPass p
GhcTc -> GenLocated SrcSpanAnnN ConLike -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (ConLikeP (GhcPass p))
GenLocated SrcSpanAnnN ConLike
con

ppr_expr (RecordUpd { rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_expr = L SrcSpanAnnA
_ HsExpr (GhcPass p)
aexp, rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Either [LHsRecUpdField (GhcPass p)] [LHsRecUpdProj (GhcPass p)]
flds })
  = case Either [LHsRecUpdField (GhcPass p)] [LHsRecUpdProj (GhcPass p)]
flds of
      Left [LHsRecUpdField (GhcPass p)]
rbinds -> SDoc -> Int -> SDoc -> SDoc
hang (HsExpr (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr (GhcPass p)
aexp) Int
2 (SDoc -> SDoc
braces ([SDoc] -> SDoc
fsep (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ((GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdField (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
rbinds))))
      Right [LHsRecUpdProj (GhcPass p)]
pbinds -> SDoc -> Int -> SDoc -> SDoc
hang (HsExpr (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr (GhcPass p)
aexp) Int
2 (SDoc -> SDoc
braces ([SDoc] -> SDoc
fsep (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ((GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdProj (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
pbinds))))

ppr_expr (HsGetField { gf_expr :: forall p. HsExpr p -> LHsExpr p
gf_expr = L SrcSpanAnnA
_ HsExpr (GhcPass p)
fexp, gf_field :: forall p. HsExpr p -> XRec p (DotFieldOcc p)
gf_field = XRec (GhcPass p) (DotFieldOcc (GhcPass p))
field })
  = HsExpr (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr (GhcPass p)
fexp SDoc -> SDoc -> SDoc
<> SDoc
dot SDoc -> SDoc -> SDoc
<> GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (DotFieldOcc (GhcPass p))
GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))
field

ppr_expr (HsProjection { proj_flds :: forall p. HsExpr p -> NonEmpty (XRec p (DotFieldOcc p))
proj_flds = NonEmpty (XRec (GhcPass p) (DotFieldOcc (GhcPass p)))
flds }) = SDoc -> SDoc
parens ([SDoc] -> SDoc
hcat (SDoc
dot SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
dot ((GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)) -> SDoc)
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ([GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
 -> [SDoc])
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> a -> b
$ NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)))
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (XRec (GhcPass p) (DotFieldOcc (GhcPass p)))
NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)))
flds))))

ppr_expr (ExprWithTySig XExprWithTySig (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr LHsSigWcType (NoGhcTc (GhcPass p))
sig)
  = SDoc -> Int -> SDoc -> SDoc
hang (Int -> SDoc -> SDoc
nest Int
2 (XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
expr) SDoc -> SDoc -> SDoc
<+> SDoc
dcolon)
         Int
4 (HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsSigType (GhcPass (NoGhcTcPass p))))
sig)

ppr_expr (ArithSeq XArithSeq (GhcPass p)
_ Maybe (SyntaxExpr (GhcPass p))
_ ArithSeqInfo (GhcPass p)
info) = SDoc -> SDoc
brackets (ArithSeqInfo (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ArithSeqInfo (GhcPass p)
info)

ppr_expr (HsSpliceE XSpliceE (GhcPass p)
_ HsSplice (GhcPass p)
s)         = HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
pprSplice HsSplice (GhcPass p)
s

ppr_expr (HsTypedBracket XTypedBracket (GhcPass p)
b XRec (GhcPass p) (HsExpr (GhcPass p))
e)
  = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
    GhcPass p
GhcPs -> SDoc -> SDoc
thTyBrackets (GenLocated SrcSpanAnnA (HsExpr (GhcPass 'Parsed)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass 'Parsed))
e)
    GhcPass p
GhcRn -> SDoc -> SDoc
thTyBrackets (GenLocated SrcSpanAnnA (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr GhcRn)
e)
    GhcPass p
GhcTc | HsBracketTc HsQuote GhcRn
_  Type
_ty Maybe QuoteWrapper
_wrap [PendingTcSplice]
ps <- XTypedBracket (GhcPass p)
b ->
      SDoc -> SDoc
thTyBrackets (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e) SDoc -> [PendingTcSplice] -> SDoc
`ppr_with_pending_tc_splices` [PendingTcSplice]
ps
ppr_expr (HsUntypedBracket XUntypedBracket (GhcPass p)
b HsQuote (GhcPass p)
q)
  = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
    GhcPass p
GhcPs -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q
    GhcPass p
GhcRn -> case XUntypedBracket (GhcPass p)
b of
      [] -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q
      XUntypedBracket (GhcPass p)
ps -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"pending(rn)" SDoc -> SDoc -> SDoc
<+> [PendingRnSplice] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [PendingRnSplice]
XUntypedBracket (GhcPass p)
ps
    GhcPass p
GhcTc | HsBracketTc HsQuote GhcRn
rnq  Type
_ty Maybe QuoteWrapper
_wrap [PendingTcSplice]
ps <- XUntypedBracket (GhcPass p)
b ->
      HsQuote GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote GhcRn
rnq SDoc -> [PendingTcSplice] -> SDoc
`ppr_with_pending_tc_splices` [PendingTcSplice]
ps

ppr_expr (HsProc XProc (GhcPass p)
_ LPat (GhcPass p)
pat (L SrcAnn NoEpAnns
_ (HsCmdTop XCmdTop (GhcPass p)
_ LHsCmd (GhcPass p)
cmd)))
  = [SDoc] -> SDoc
hsep [String -> SDoc
text String
"proc", GenLocated SrcSpanAnnA (Pat (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
pat, String -> SDoc
text String
"->", GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsCmd (GhcPass p)
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
cmd]

ppr_expr (HsStatic XStatic (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e)
  = [SDoc] -> SDoc
hsep [String -> SDoc
text String
"static", GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e]

ppr_expr (XExpr XXExpr (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
  GhcPs -> ppr x
#endif
  GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
  GhcPass p
GhcTc -> XXExprGhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
XXExprGhcTc
x

instance Outputable XXExprGhcTc where
  ppr :: XXExprGhcTc -> SDoc
ppr (WrapExpr (HsWrap HsWrapper
co_fn HsExpr GhcTc
e))
    = HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper HsWrapper
co_fn (\Bool
_parens -> HsExpr GhcTc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr GhcTc
e)

  ppr (ExpansionExpr HsExpansion (HsExpr GhcRn) (HsExpr GhcTc)
e)
    = HsExpansion (HsExpr GhcRn) (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpansion (HsExpr GhcRn) (HsExpr GhcTc)
e -- e is an HsExpansion, we print the original
            -- expression (LHsExpr GhcPs), not the
            -- desugared one (LHsExpr GhcTc).

  ppr (ConLikeTc ConLike
con [Id]
_ [Scaled Type]
_) = ConLike -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc ConLike
con
   -- Used in error messages generated by
   -- the pattern match overlap checker

  ppr (HsTick CoreTickish
tickish LHsExpr GhcTc
exp) =
    SDoc -> SDoc -> SDoc
pprTicks (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
exp) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
      CoreTickish -> SDoc
forall a. Outputable a => a -> SDoc
ppr CoreTickish
tickish SDoc -> SDoc -> SDoc
<+> LHsExpr GhcTc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr GhcTc
exp

  ppr (HsBinTick Int
tickIdTrue Int
tickIdFalse LHsExpr GhcTc
exp) =
    SDoc -> SDoc -> SDoc
pprTicks (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
exp) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
      [SDoc] -> SDoc
hcat [String -> SDoc
text String
"bintick<",
            Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
tickIdTrue,
            String -> SDoc
text String
",",
            Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
tickIdFalse,
            String -> SDoc
text String
">(",
            GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
exp, String -> SDoc
text String
")"]

ppr_infix_expr :: forall p. (OutputableBndrId p) => HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v))    = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP p
v)
ppr_infix_expr (HsRecSel XRecSel (GhcPass p)
_ FieldOcc (GhcPass p)
f)       = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (FieldOcc (GhcPass p) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc FieldOcc (GhcPass p)
f)
ppr_infix_expr (HsUnboundVar XUnboundVar (GhcPass p)
_ OccName
occ) = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (OccName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc OccName
occ)
ppr_infix_expr (XExpr XXExpr (GhcPass p)
x)            = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 901
                                        GhcPs -> Nothing
#endif
                                        GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Maybe SDoc
ppr_infix_expr_rn XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
                                        GhcPass p
GhcTc -> XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc XXExpr (GhcPass p)
XXExprGhcTc
x
ppr_infix_expr HsExpr (GhcPass p)
_ = Maybe SDoc
forall a. Maybe a
Nothing

ppr_infix_expr_rn :: HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Maybe SDoc
ppr_infix_expr_rn :: HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Maybe SDoc
ppr_infix_expr_rn (HsExpanded HsExpr GhcRn
a HsExpr GhcRn
_) = HsExpr GhcRn -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr HsExpr GhcRn
a

ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc (WrapExpr (HsWrap HsWrapper
_ HsExpr GhcTc
e))          = HsExpr GhcTc -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr HsExpr GhcTc
e
ppr_infix_expr_tc (ExpansionExpr (HsExpanded HsExpr GhcRn
a HsExpr GhcTc
_)) = HsExpr GhcRn -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr HsExpr GhcRn
a
ppr_infix_expr_tc (ConLikeTc {})                   = Maybe SDoc
forall a. Maybe a
Nothing
ppr_infix_expr_tc (HsTick {})                      = Maybe SDoc
forall a. Maybe a
Nothing
ppr_infix_expr_tc (HsBinTick {})                   = Maybe SDoc
forall a. Maybe a
Nothing

ppr_apps :: (OutputableBndrId p)
         => HsExpr (GhcPass p)
         -> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
         -> SDoc
ppr_apps :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps (HsApp XApp (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
fun) LHsExpr (GhcPass p)
arg)        [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
args
  = HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps HsExpr (GhcPass p)
fun (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
-> Either
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
     (HsWildCardBndrs
        (GhcPass (NoGhcTcPass p))
        (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
forall a b. a -> Either a b
Left LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
arg Either
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
  (HsWildCardBndrs
     (GhcPass (NoGhcTcPass p))
     (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
forall a. a -> [a] -> [a]
: [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
[Either
   (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
   (HsWildCardBndrs
      (GhcPass (NoGhcTcPass p))
      (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
args)
ppr_apps (HsAppType XAppTypeE (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
fun) LHsWcType (NoGhcTc (GhcPass p))
arg)    [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
args
  = HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps HsExpr (GhcPass p)
fun (HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
-> Either
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
     (HsWildCardBndrs
        (GhcPass (NoGhcTcPass p))
        (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
forall a b. b -> Either a b
Right LHsWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
arg Either
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
  (HsWildCardBndrs
     (GhcPass (NoGhcTcPass p))
     (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
forall a. a -> [a] -> [a]
: [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
[Either
   (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
   (HsWildCardBndrs
      (GhcPass (NoGhcTcPass p))
      (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
args)
ppr_apps HsExpr (GhcPass p)
fun [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
args = SDoc -> Int -> SDoc -> SDoc
hang (HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
fun) Int
2 ([SDoc] -> SDoc
fsep ((Either
   (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
   (HsWildCardBndrs
      (GhcPass (NoGhcTcPass p))
      (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
 -> SDoc)
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Either
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
  (HsWildCardBndrs
     (GhcPass (NoGhcTcPass p))
     (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> SDoc
forall {a} {a}. (Outputable a, Outputable a) => Either a a -> SDoc
pp [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
[Either
   (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
   (HsWildCardBndrs
      (GhcPass (NoGhcTcPass p))
      (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
args))
  where
    pp :: Either a a -> SDoc
pp (Left a
arg)                             = a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
arg
    -- pp (Right (LHsWcTypeX (HsWC { hswc_body = L _ arg })))
    --   = char '@' <> pprHsType arg
    pp (Right a
arg)
      = String -> SDoc
text String
"@" SDoc -> SDoc -> SDoc
<> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
arg


pprDebugParendExpr :: (OutputableBndrId p)
                   => PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr :: forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprDebugParendExpr PprPrec
p LHsExpr (GhcPass p)
expr
  = (Bool -> SDoc) -> SDoc
getPprDebug ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \case
      Bool
True  -> PprPrec -> LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprParendLExpr PprPrec
p LHsExpr (GhcPass p)
expr
      Bool
False -> LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
pprLExpr         LHsExpr (GhcPass p)
expr

pprParendLExpr :: (OutputableBndrId p)
               => PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprParendLExpr :: forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LHsExpr (GhcPass p) -> SDoc
pprParendLExpr PprPrec
p (L SrcSpanAnnA
_ HsExpr (GhcPass p)
e) = PprPrec -> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> HsExpr (GhcPass p) -> SDoc
pprParendExpr PprPrec
p HsExpr (GhcPass p)
e

pprParendExpr :: (OutputableBndrId p)
              => PprPrec -> HsExpr (GhcPass p) -> SDoc
pprParendExpr :: forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> HsExpr (GhcPass p) -> SDoc
pprParendExpr PprPrec
p HsExpr (GhcPass p)
expr
  | PprPrec -> HsExpr (GhcPass p) -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
p HsExpr (GhcPass p)
expr = SDoc -> SDoc
parens (HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr (GhcPass p)
expr)
  | Bool
otherwise                = HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr HsExpr (GhcPass p)
expr
        -- Using pprLExpr makes sure that we go 'deeper'
        -- I think that is usually (always?) right

-- | @'hsExprNeedsParens' p e@ returns 'True' if the expression @e@ needs
-- parentheses under precedence @p@.
hsExprNeedsParens :: forall p. IsPass p => PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens :: forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec = HsExpr (GhcPass p) -> Bool
go
  where
    go :: HsExpr (GhcPass p) -> Bool
    go :: HsExpr (GhcPass p) -> Bool
go (HsVar{})                      = Bool
False
    go (HsUnboundVar{})               = Bool
False
    go (HsIPVar{})                    = Bool
False
    go (HsOverLabel{})                = Bool
False
    go (HsLit XLitE (GhcPass p)
_ HsLit (GhcPass p)
l)                    = PprPrec -> HsLit (GhcPass p) -> Bool
forall x. PprPrec -> HsLit x -> Bool
hsLitNeedsParens PprPrec
prec HsLit (GhcPass p)
l
    go (HsOverLit XOverLitE (GhcPass p)
_ HsOverLit (GhcPass p)
ol)               = PprPrec -> HsOverLit (GhcPass p) -> Bool
forall x. PprPrec -> HsOverLit x -> Bool
hsOverLitNeedsParens PprPrec
prec HsOverLit (GhcPass p)
ol
    go (HsPar{})                      = Bool
False
    go (HsApp{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (HsAppType {})                 = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (OpApp{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
opPrec
    go (NegApp{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (SectionL{})                   = Bool
True
    go (SectionR{})                   = Bool
True
    -- Special-case unary boxed tuple applications so that they are
    -- parenthesized as `Identity (Solo x)`, not `Identity Solo x` (#18612)
    -- See Note [One-tuples] in GHC.Builtin.Types
    go (ExplicitTuple XExplicitTuple (GhcPass p)
_ [Present{}] Boxity
Boxed)
                                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (ExplicitTuple{})              = Bool
False
    go (ExplicitSum{})                = Bool
False
    go (HsLam{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsLamCase{})                  = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsCase{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsIf{})                       = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsMultiIf{})                  = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsLet{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsDo XDo (GhcPass p)
_ HsDoFlavour
sc XRec (GhcPass p) [ExprLStmt (GhcPass p)]
_)
      | HsDoFlavour -> Bool
isDoComprehensionContext HsDoFlavour
sc   = Bool
False
      | Bool
otherwise                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (ExplicitList{})               = Bool
False
    go (RecordUpd{})                  = Bool
False
    go (ExprWithTySig{})              = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
sigPrec
    go (ArithSeq{})                   = Bool
False
    go (HsPragE{})                    = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (HsSpliceE{})                  = Bool
False
    go (HsTypedBracket{})             = Bool
False
    go (HsUntypedBracket{})           = Bool
False
    go (HsProc{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsStatic{})                   = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (RecordCon{})                  = Bool
False
    go (HsRecSel{})                   = Bool
False
    go (HsProjection{})               = Bool
True
    go (HsGetField{})                 = Bool
False
    go (XExpr XXExpr (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
                     GhcPass p
GhcTc -> XXExprGhcTc -> Bool
go_x_tc XXExpr (GhcPass p)
XXExprGhcTc
x
                     GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
go_x_rn XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
#if __GLASGOW_HASKELL__ <= 900
                     GhcPs -> True
#endif

    go_x_tc :: XXExprGhcTc -> Bool
    go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr (HsWrap HsWrapper
_ HsExpr GhcTc
e))          = PprPrec -> HsExpr GhcTc -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcTc
e
    go_x_tc (ExpansionExpr (HsExpanded HsExpr GhcRn
a HsExpr GhcTc
_)) = PprPrec -> HsExpr GhcRn -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcRn
a
    go_x_tc (ConLikeTc {})                   = Bool
False
    go_x_tc (HsTick CoreTickish
_ (L SrcSpanAnnA
_ HsExpr GhcTc
e))               = PprPrec -> HsExpr GhcTc -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcTc
e
    go_x_tc (HsBinTick Int
_ Int
_ (L SrcSpanAnnA
_ HsExpr GhcTc
e))          = PprPrec -> HsExpr GhcTc -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcTc
e

    go_x_rn :: HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
    go_x_rn :: HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
go_x_rn (HsExpanded HsExpr GhcRn
a HsExpr GhcRn
_) = PprPrec -> HsExpr GhcRn -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcRn
a


-- | Parenthesize an expression without token information
gHsPar :: LHsExpr (GhcPass id) -> HsExpr (GhcPass id)
gHsPar :: forall (id :: Pass). LHsExpr (GhcPass id) -> HsExpr (GhcPass id)
gHsPar LHsExpr (GhcPass id)
e = XPar (GhcPass id)
-> LHsToken "(" (GhcPass id)
-> LHsExpr (GhcPass id)
-> LHsToken ")" (GhcPass id)
-> HsExpr (GhcPass id)
forall p.
XPar p -> LHsToken "(" p -> LHsExpr p -> LHsToken ")" p -> HsExpr p
HsPar XPar (GhcPass id)
EpAnnCO
forall a. EpAnn a
noAnn LHsToken "(" (GhcPass id)
GenLocated TokenLocation (HsToken "(")
forall (tok :: Symbol). GenLocated TokenLocation (HsToken tok)
noHsTok LHsExpr (GhcPass id)
e LHsToken ")" (GhcPass id)
GenLocated TokenLocation (HsToken ")")
forall (tok :: Symbol). GenLocated TokenLocation (HsToken tok)
noHsTok

-- | @'parenthesizeHsExpr' p e@ checks if @'hsExprNeedsParens' p e@ is true,
-- and if so, surrounds @e@ with an 'HsPar'. Otherwise, it simply returns @e@.
parenthesizeHsExpr :: IsPass p => PprPrec -> LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
parenthesizeHsExpr :: forall (p :: Pass).
IsPass p =>
PprPrec -> LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
parenthesizeHsExpr PprPrec
p le :: LHsExpr (GhcPass p)
le@(L SrcSpanAnnA
loc HsExpr (GhcPass p)
e)
  | PprPrec -> HsExpr (GhcPass p) -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
p HsExpr (GhcPass p)
e = SrcSpanAnnA
-> HsExpr (GhcPass p)
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (LHsExpr (GhcPass p) -> HsExpr (GhcPass p)
forall (id :: Pass). LHsExpr (GhcPass id) -> HsExpr (GhcPass id)
gHsPar LHsExpr (GhcPass p)
le)
  | Bool
otherwise             = LHsExpr (GhcPass p)
le

stripParensLHsExpr :: LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
stripParensLHsExpr :: forall (p :: Pass). LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
stripParensLHsExpr (L SrcSpanAnnA
_ (HsPar XPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ LHsExpr (GhcPass p)
e LHsToken ")" (GhcPass p)
_)) = LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
forall (p :: Pass). LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
stripParensLHsExpr LHsExpr (GhcPass p)
e
stripParensLHsExpr LHsExpr (GhcPass p)
e = LHsExpr (GhcPass p)
e

stripParensHsExpr :: HsExpr (GhcPass p) -> HsExpr (GhcPass p)
stripParensHsExpr :: forall (p :: Pass). HsExpr (GhcPass p) -> HsExpr (GhcPass p)
stripParensHsExpr (HsPar XPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
e) LHsToken ")" (GhcPass p)
_) = HsExpr (GhcPass p) -> HsExpr (GhcPass p)
forall (p :: Pass). HsExpr (GhcPass p) -> HsExpr (GhcPass p)
stripParensHsExpr HsExpr (GhcPass p)
e
stripParensHsExpr HsExpr (GhcPass p)
e = HsExpr (GhcPass p)
e

isAtomicHsExpr :: forall p. IsPass p => HsExpr (GhcPass p) -> Bool
-- True of a single token
isAtomicHsExpr :: forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr (HsVar {})        = Bool
True
isAtomicHsExpr (HsLit {})        = Bool
True
isAtomicHsExpr (HsOverLit {})    = Bool
True
isAtomicHsExpr (HsIPVar {})      = Bool
True
isAtomicHsExpr (HsOverLabel {})  = Bool
True
isAtomicHsExpr (HsUnboundVar {}) = Bool
True
isAtomicHsExpr (HsRecSel{})      = Bool
True
isAtomicHsExpr (XExpr XXExpr (GhcPass p)
x)
  | GhcPass p
GhcTc <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p          = XXExprGhcTc -> Bool
go_x_tc XXExpr (GhcPass p)
XXExprGhcTc
x
  | GhcPass p
GhcRn <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p          = HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
forall {p :: Pass} {expanded}.
IsPass p =>
HsExpansion (HsExpr (GhcPass p)) expanded -> Bool
go_x_rn XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
  where
    go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr      (HsWrap HsWrapper
_ HsExpr GhcTc
e))     = HsExpr GhcTc -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr GhcTc
e
    go_x_tc (ExpansionExpr (HsExpanded HsExpr GhcRn
a HsExpr GhcTc
_)) = HsExpr GhcRn -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr GhcRn
a
    go_x_tc (ConLikeTc {})                   = Bool
True
    go_x_tc (HsTick {}) = Bool
False
    go_x_tc (HsBinTick {}) = Bool
False

    go_x_rn :: HsExpansion (HsExpr (GhcPass p)) expanded -> Bool
go_x_rn (HsExpanded HsExpr (GhcPass p)
a expanded
_) = HsExpr (GhcPass p) -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr (GhcPass p)
a

isAtomicHsExpr HsExpr (GhcPass p)
_ = Bool
False

instance Outputable (HsPragE (GhcPass p)) where
  ppr :: HsPragE (GhcPass p) -> SDoc
ppr (HsPragSCC XSCC (GhcPass p)
_ SourceText
st (StringLiteral SourceText
stl FastString
lbl Maybe RealSrcSpan
_)) =
    SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (String -> SDoc
text String
"{-# SCC")
     -- no doublequotes if stl empty, for the case where the SCC was written
     -- without quotes.
    SDoc -> SDoc -> SDoc
<+> SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
stl (FastString -> SDoc
ftext FastString
lbl) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"#-}"


{- *********************************************************************
*                                                                      *
             HsExpansion and rebindable syntax
*                                                                      *
********************************************************************* -}

{- Note [Rebindable syntax and HsExpansion]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We implement rebindable syntax (RS) support by performing a desugaring
in the renamer. We transform GhcPs expressions and patterns affected by
RS into the appropriate desugared form, but **annotated with the original
expression/pattern**.

Let us consider a piece of code like:

    {-# LANGUAGE RebindableSyntax #-}
    ifThenElse :: Char -> () -> () -> ()
    ifThenElse _ _ _ = ()
    x = if 'a' then () else True

The parsed AST for the RHS of x would look something like (slightly simplified):

    L locif (HsIf (L loca 'a') (L loctrue ()) (L locfalse True))

Upon seeing such an AST with RS on, we could transform it into a
mere function call, as per the RS rules, equivalent to the
following function application:

    ifThenElse 'a' () True

which doesn't typecheck. But GHC would report an error about
not being able to match the third argument's type (Bool) with the
expected type: (), in the expression _as desugared_, i.e in
the aforementioned function application. But the user never
wrote a function application! This would be pretty bad.

To remedy this, instead of transforming the original HsIf
node into mere applications of 'ifThenElse', we keep the
original 'if' expression around too, using the TTG
XExpr extension point to allow GHC to construct an
'HsExpansion' value that will keep track of the original
expression in its first field, and the desugared one in the
second field. The resulting renamed AST would look like:

    L locif (XExpr
      (HsExpanded
        (HsIf (L loca 'a')
              (L loctrue ())
              (L locfalse True)
        )
        (App (L generatedSrcSpan
                (App (L generatedSrcSpan
                        (App (L generatedSrcSpan (Var ifThenElse))
                             (L loca 'a')
                        )
                     )
                     (L loctrue ())
                )
             )
             (L locfalse True)
        )
      )
    )

When comes the time to typecheck the program, we end up calling
tcMonoExpr on the AST above. If this expression gives rise to
a type error, then it will appear in a context line and GHC
will pretty-print it using the 'Outputable (HsExpansion a b)'
instance defined below, which *only prints the original
expression*. This is the gist of the idea, but is not quite
enough to recover the error messages that we had with the
SyntaxExpr-based, typechecking/desugaring-to-core time
implementation of rebindable syntax. The key idea is to decorate
some elements of the desugared expression so as to be able to
give them a special treatment when typechecking the desugared
expression, to print a different context line or skip one
altogether.

Whenever we 'setSrcSpan' a 'generatedSrcSpan', we update a field in
TcLclEnv called 'tcl_in_gen_code', setting it to True, which indicates that we
entered generated code, i.e code fabricated by the compiler when rebinding some
syntax. If someone tries to push some error context line while that field is set
to True, the pushing won't actually happen and the context line is just dropped.
Once we 'setSrcSpan' a real span (for an expression that was in the original
source code), we set 'tcl_in_gen_code' back to False, indicating that we
"emerged from the generated code tunnel", and that the expressions we will be
processing are relevant to report in context lines again.

You might wonder why TcLclEnv has both
   tcl_loc         :: RealSrcSpan
   tcl_in_gen_code :: Bool
Could we not store a Maybe RealSrcSpan? The problem is that we still
generate constraints when processing generated code, and a CtLoc must
contain a RealSrcSpan -- otherwise, error messages might appear
without source locations. So tcl_loc keeps the RealSrcSpan of the last
location spotted that wasn't generated; it's as good as we're going to
get in generated code. Once we get to sub-trees that are not
generated, then we update the RealSrcSpan appropriately, and set the
tcl_in_gen_code Bool to False.

---

An overview of the constructs that are desugared in this way is laid out in
Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr.

A general recipe to follow this approach for new constructs could go as follows:

- Remove any GhcRn-time SyntaxExpr extensions to the relevant constructor for your
  construct, in HsExpr or related syntax data types.
- At renaming-time:
    - take your original node of interest (HsIf above)
    - rename its subexpressions/subpatterns (condition and true/false
      branches above)
    - construct the suitable "rebound"-and-renamed result (ifThenElse call
      above), where the 'SrcSpan' attached to any _fabricated node_ (the
      HsVar/HsApp nodes, above) is set to 'generatedSrcSpan'
    - take both the original node and that rebound-and-renamed result and wrap
      them into an expansion construct:
        for expressions, XExpr (HsExpanded <original node> <desugared>)
        for patterns, XPat (HsPatExpanded <original node> <desugared>)
 - At typechecking-time:
    - remove any logic that was previously dealing with your rebindable
      construct, typically involving [tc]SyntaxOp, SyntaxExpr and friends.
    - the XExpr (HsExpanded ... ...) case in tcExpr already makes sure that we
      typecheck the desugared expression while reporting the original one in
      errors
-}

{- Note [Overview of record dot syntax]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the note that explains all the moving parts for record dot
syntax.

The language extensions @OverloadedRecordDot@ and
@OverloadedRecordUpdate@ (providing "record dot syntax") are
implemented using the techniques of Note [Rebindable syntax and
HsExpansion].

When OverloadedRecordDot is enabled:
- Field selection expressions
  - e.g. foo.bar.baz
  - Have abstract syntax HsGetField
  - After renaming are XExpr (HsExpanded (HsGetField ...) (getField @"..."...)) expressions
- Field selector expressions e.g. (.x.y)
  - Have abstract syntax HsProjection
  - After renaming are XExpr (HsExpanded (HsProjection ...) ((getField @"...") . (getField @"...") . ...) expressions

When OverloadedRecordUpdate is enabled:
- Record update expressions
  - e.g. a{foo.bar=1, quux="corge", baz}
  - Have abstract syntax RecordUpd
    - With rupd_flds containting a Right
    - See Note [RecordDotSyntax field updates] (in Language.Haskell.Syntax.Expr)
  - After renaming are XExpr (HsExpanded (RecordUpd ...) (setField@"..." ...) expressions
    - Note that this is true for all record updates even for those that do not involve '.'

When OverloadedRecordDot is enabled and RebindableSyntax is not
enabled the name 'getField' is resolved to GHC.Records.getField. When
OverloadedRecordDot is enabled and RebindableSyntax is enabled the
name 'getField' is whatever in-scope name that is.

When OverloadedRecordUpd is enabled and RebindableSyntax is not
enabled it is an error for now (temporary while we wait on native
setField support; see
https://gitlab.haskell.org/ghc/ghc/-/issues/16232). When
OverloadedRecordUpd is enabled and RebindableSyntax is enabled the
names 'getField' and 'setField' are whatever in-scope names they are.
-}

-- See Note [Rebindable syntax and HsExpansion] just above.
data HsExpansion orig expanded
  = HsExpanded orig expanded
  deriving Typeable (HsExpansion orig expanded)
Typeable (HsExpansion orig expanded)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HsExpansion orig expanded
    -> c (HsExpansion orig expanded))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (HsExpansion orig expanded))
-> (HsExpansion orig expanded -> Constr)
-> (HsExpansion orig expanded -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c (HsExpansion orig expanded)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (HsExpansion orig expanded)))
-> ((forall b. Data b => b -> b)
    -> HsExpansion orig expanded -> HsExpansion orig expanded)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> HsExpansion orig expanded
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> HsExpansion orig expanded
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> HsExpansion orig expanded -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u) -> HsExpansion orig expanded -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsExpansion orig expanded -> m (HsExpansion orig expanded))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsExpansion orig expanded -> m (HsExpansion orig expanded))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsExpansion orig expanded -> m (HsExpansion orig expanded))
-> Data (HsExpansion orig expanded)
HsExpansion orig expanded -> Constr
HsExpansion orig expanded -> DataType
(forall b. Data b => b -> b)
-> HsExpansion orig expanded -> HsExpansion orig expanded
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) -> HsExpansion orig expanded -> u
forall u.
(forall d. Data d => d -> u) -> HsExpansion orig expanded -> [u]
forall {orig} {expanded}.
(Data orig, Data expanded) =>
Typeable (HsExpansion orig expanded)
forall orig expanded.
(Data orig, Data expanded) =>
HsExpansion orig expanded -> Constr
forall orig expanded.
(Data orig, Data expanded) =>
HsExpansion orig expanded -> DataType
forall orig expanded.
(Data orig, Data expanded) =>
(forall b. Data b => b -> b)
-> HsExpansion orig expanded -> HsExpansion orig expanded
forall orig expanded u.
(Data orig, Data expanded) =>
Int
-> (forall d. Data d => d -> u) -> HsExpansion orig expanded -> u
forall orig expanded u.
(Data orig, Data expanded) =>
(forall d. Data d => d -> u) -> HsExpansion orig expanded -> [u]
forall orig expanded r r'.
(Data orig, Data expanded) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
forall orig expanded r r'.
(Data orig, Data expanded) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
forall orig expanded (m :: * -> *).
(Data orig, Data expanded, Monad m) =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
forall orig expanded (m :: * -> *).
(Data orig, Data expanded, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
forall orig expanded (c :: * -> *).
(Data orig, Data expanded) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HsExpansion orig expanded)
forall orig expanded (c :: * -> *).
(Data orig, Data expanded) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HsExpansion orig expanded
-> c (HsExpansion orig expanded)
forall orig expanded (t :: * -> *) (c :: * -> *).
(Data orig, Data expanded, Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (HsExpansion orig expanded))
forall orig expanded (t :: * -> * -> *) (c :: * -> *).
(Data orig, Data expanded, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (HsExpansion orig expanded))
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HsExpansion orig expanded)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HsExpansion orig expanded
-> c (HsExpansion orig expanded)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (HsExpansion orig expanded))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (HsExpansion orig expanded))
$cgfoldl :: forall orig expanded (c :: * -> *).
(Data orig, Data expanded) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HsExpansion orig expanded
-> c (HsExpansion orig expanded)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HsExpansion orig expanded
-> c (HsExpansion orig expanded)
$cgunfold :: forall orig expanded (c :: * -> *).
(Data orig, Data expanded) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HsExpansion orig expanded)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (HsExpansion orig expanded)
$ctoConstr :: forall orig expanded.
(Data orig, Data expanded) =>
HsExpansion orig expanded -> Constr
toConstr :: HsExpansion orig expanded -> Constr
$cdataTypeOf :: forall orig expanded.
(Data orig, Data expanded) =>
HsExpansion orig expanded -> DataType
dataTypeOf :: HsExpansion orig expanded -> DataType
$cdataCast1 :: forall orig expanded (t :: * -> *) (c :: * -> *).
(Data orig, Data expanded, Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (HsExpansion orig expanded))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (HsExpansion orig expanded))
$cdataCast2 :: forall orig expanded (t :: * -> * -> *) (c :: * -> *).
(Data orig, Data expanded, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (HsExpansion orig expanded))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (HsExpansion orig expanded))
$cgmapT :: forall orig expanded.
(Data orig, Data expanded) =>
(forall b. Data b => b -> b)
-> HsExpansion orig expanded -> HsExpansion orig expanded
gmapT :: (forall b. Data b => b -> b)
-> HsExpansion orig expanded -> HsExpansion orig expanded
$cgmapQl :: forall orig expanded r r'.
(Data orig, Data expanded) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
$cgmapQr :: forall orig expanded r r'.
(Data orig, Data expanded) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> HsExpansion orig expanded
-> r
$cgmapQ :: forall orig expanded u.
(Data orig, Data expanded) =>
(forall d. Data d => d -> u) -> HsExpansion orig expanded -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> HsExpansion orig expanded -> [u]
$cgmapQi :: forall orig expanded u.
(Data orig, Data expanded) =>
Int
-> (forall d. Data d => d -> u) -> HsExpansion orig expanded -> u
gmapQi :: forall u.
Int
-> (forall d. Data d => d -> u) -> HsExpansion orig expanded -> u
$cgmapM :: forall orig expanded (m :: * -> *).
(Data orig, Data expanded, Monad m) =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
$cgmapMp :: forall orig expanded (m :: * -> *).
(Data orig, Data expanded, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
$cgmapMo :: forall orig expanded (m :: * -> *).
(Data orig, Data expanded, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HsExpansion orig expanded -> m (HsExpansion orig expanded)
Data

-- | Just print the original expression (the @a@).
instance (Outputable a, Outputable b) => Outputable (HsExpansion a b) where
  ppr :: HsExpansion a b -> SDoc
ppr (HsExpanded a
orig b
expanded)
    = SDoc -> SDoc -> SDoc
ifPprDebug ([SDoc] -> SDoc
vcat [a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
orig, SDoc -> SDoc
braces (String -> SDoc
text String
"Expansion:" SDoc -> SDoc -> SDoc
<+> b -> SDoc
forall a. Outputable a => a -> SDoc
ppr b
expanded)])
                 (a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
orig)


{-
************************************************************************
*                                                                      *
\subsection{Commands (in arrow abstractions)}
*                                                                      *
************************************************************************
-}

type instance XCmdArrApp  GhcPs = EpAnn AddEpAnn
type instance XCmdArrApp  GhcRn = NoExtField
type instance XCmdArrApp  GhcTc = Type

type instance XCmdArrForm GhcPs = EpAnn AnnList
type instance XCmdArrForm GhcRn = NoExtField
type instance XCmdArrForm GhcTc = NoExtField

type instance XCmdApp     (GhcPass _) = EpAnnCO
type instance XCmdLam     (GhcPass _) = NoExtField
type instance XCmdPar     (GhcPass _) = EpAnnCO

type instance XCmdCase    GhcPs = EpAnn EpAnnHsCase
type instance XCmdCase    GhcRn = NoExtField
type instance XCmdCase    GhcTc = NoExtField

type instance XCmdLamCase (GhcPass _) = EpAnn [AddEpAnn]

type instance XCmdIf      GhcPs = EpAnn AnnsIf
type instance XCmdIf      GhcRn = NoExtField
type instance XCmdIf      GhcTc = NoExtField

type instance XCmdLet     GhcPs = EpAnnCO
type instance XCmdLet     GhcRn = NoExtField
type instance XCmdLet     GhcTc = NoExtField

type instance XCmdDo      GhcPs = EpAnn AnnList
type instance XCmdDo      GhcRn = NoExtField
type instance XCmdDo      GhcTc = Type

type instance XCmdWrap    (GhcPass _) = NoExtField

type instance XXCmd       GhcPs = DataConCantHappen
type instance XXCmd       GhcRn = DataConCantHappen
type instance XXCmd       GhcTc = HsWrap HsCmd

type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd (GhcPass pr))))]
  = SrcSpanAnnL

    -- If   cmd :: arg1 --> res
    --      wrap :: arg1 "->" arg2
    -- Then (XCmd (HsWrap wrap cmd)) :: arg2 --> res

data CmdTopTc
  = CmdTopTc Type    -- Nested tuple of inputs on the command's stack
             Type    -- return type of the command
             (CmdSyntaxTable GhcTc) -- See Note [CmdSyntaxTable]

type instance XCmdTop  GhcPs = NoExtField
type instance XCmdTop  GhcRn = CmdSyntaxTable GhcRn -- See Note [CmdSyntaxTable]
type instance XCmdTop  GhcTc = CmdTopTc

type instance XXCmdTop (GhcPass _) = DataConCantHappen

instance (OutputableBndrId p) => Outputable (HsCmd (GhcPass p)) where
    ppr :: HsCmd (GhcPass p) -> SDoc
ppr HsCmd (GhcPass p)
cmd = HsCmd (GhcPass p) -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
pprCmd HsCmd (GhcPass p)
cmd

-----------------------
-- pprCmd and pprLCmd call pprDeeper;
-- the underscore versions do not
pprLCmd :: (OutputableBndrId p) => LHsCmd (GhcPass p) -> SDoc
pprLCmd :: forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
pprLCmd (L SrcSpanAnnA
_ HsCmd (GhcPass p)
c) = HsCmd (GhcPass p) -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
pprCmd HsCmd (GhcPass p)
c

pprCmd :: (OutputableBndrId p) => HsCmd (GhcPass p) -> SDoc
pprCmd :: forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
pprCmd HsCmd (GhcPass p)
c | HsCmd (GhcPass p) -> Bool
forall id. HsCmd id -> Bool
isQuietHsCmd HsCmd (GhcPass p)
c =            HsCmd (GhcPass p) -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
ppr_cmd HsCmd (GhcPass p)
c
         | Bool
otherwise      = SDoc -> SDoc
pprDeeper (HsCmd (GhcPass p) -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
ppr_cmd HsCmd (GhcPass p)
c)

isQuietHsCmd :: HsCmd id -> Bool
-- Parentheses do display something, but it gives little info and
-- if we go deeper when we go inside them then we get ugly things
-- like (...)
isQuietHsCmd :: forall id. HsCmd id -> Bool
isQuietHsCmd (HsCmdPar {}) = Bool
True
-- applications don't display anything themselves
isQuietHsCmd (HsCmdApp {}) = Bool
True
isQuietHsCmd HsCmd id
_ = Bool
False

-----------------------
ppr_lcmd :: (OutputableBndrId p) => LHsCmd (GhcPass p) -> SDoc
ppr_lcmd :: forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
ppr_lcmd LHsCmd (GhcPass p)
c = HsCmd (GhcPass p) -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
ppr_cmd (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> HsCmd (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmd (GhcPass p)
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
c)

ppr_cmd :: forall p. (OutputableBndrId p
                     ) => HsCmd (GhcPass p) -> SDoc
ppr_cmd :: forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
ppr_cmd (HsCmdPar XCmdPar (GhcPass p)
_ LHsToken "(" (GhcPass p)
_ XRec (GhcPass p) (HsCmd (GhcPass p))
c LHsToken ")" (GhcPass p)
_) = SDoc -> SDoc
parens (XRec (GhcPass p) (HsCmd (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
ppr_lcmd XRec (GhcPass p) (HsCmd (GhcPass p))
c)

ppr_cmd (HsCmdApp XCmdApp (GhcPass p)
_ XRec (GhcPass p) (HsCmd (GhcPass p))
c LHsExpr (GhcPass p)
e)
  = let (GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
fun, [LHsExpr (GhcPass p)]
args) = GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
-> [LHsExpr (GhcPass p)]
-> (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)),
    [LHsExpr (GhcPass p)])
forall {id} {l}.
(XRec id (HsCmd id) ~ GenLocated l (HsCmd id)) =>
GenLocated l (HsCmd id)
-> [XRec id (HsExpr id)]
-> (GenLocated l (HsCmd id), [XRec id (HsExpr id)])
collect_args XRec (GhcPass p) (HsCmd (GhcPass p))
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
c [LHsExpr (GhcPass p)
e] in
    SDoc -> Int -> SDoc -> SDoc
hang (XRec (GhcPass p) (HsCmd (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
ppr_lcmd XRec (GhcPass p) (HsCmd (GhcPass p))
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
fun) Int
2 ([SDoc] -> SDoc
sep ((GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (HsExpr (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsExpr (GhcPass p)]
[GenLocated SrcSpanAnnA (HsExpr (GhcPass p))]
args))
  where
    collect_args :: GenLocated l (HsCmd id)
-> [XRec id (HsExpr id)]
-> (GenLocated l (HsCmd id), [XRec id (HsExpr id)])
collect_args (L l
_ (HsCmdApp XCmdApp id
_ XRec id (HsCmd id)
fun XRec id (HsExpr id)
arg)) [XRec id (HsExpr id)]
args = GenLocated l (HsCmd id)
-> [XRec id (HsExpr id)]
-> (GenLocated l (HsCmd id), [XRec id (HsExpr id)])
collect_args XRec id (HsCmd id)
GenLocated l (HsCmd id)
fun (XRec id (HsExpr id)
argXRec id (HsExpr id)
-> [XRec id (HsExpr id)] -> [XRec id (HsExpr id)]
forall a. a -> [a] -> [a]
:[XRec id (HsExpr id)]
args)
    collect_args GenLocated l (HsCmd id)
fun [XRec id (HsExpr id)]
args = (GenLocated l (HsCmd id)
fun, [XRec id (HsExpr id)]
args)

ppr_cmd (HsCmdLam XCmdLam (GhcPass p)
_ MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
matches

ppr_cmd (HsCmdCase XCmdCase (GhcPass p)
_ LHsExpr (GhcPass p)
expr MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
sep [ [SDoc] -> SDoc
sep [String -> SDoc
text String
"case", Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
expr), String -> SDoc
text String
"of"],
          Int -> SDoc -> SDoc
nest Int
2 (MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
matches) ]

ppr_cmd (HsCmdLamCase XCmdLamCase (GhcPass p)
_ LamCaseVariant
lc_variant MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
sep [ LamCaseVariant -> SDoc
lamCaseKeyword LamCaseVariant
lc_variant, Int -> SDoc -> SDoc
nest Int
2 (MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
matches) ]

ppr_cmd (HsCmdIf XCmdIf (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ LHsExpr (GhcPass p)
e XRec (GhcPass p) (HsCmd (GhcPass p))
ct XRec (GhcPass p) (HsCmd (GhcPass p))
ce)
  = [SDoc] -> SDoc
sep [[SDoc] -> SDoc
hsep [String -> SDoc
text String
"if", Int -> SDoc -> SDoc
nest Int
2 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e), String -> SDoc
text String
"then"],
         Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsCmd (GhcPass p))
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
ct),
         String -> SDoc
text String
"else",
         Int -> SDoc -> SDoc
nest Int
4 (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsCmd (GhcPass p))
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
ce)]

-- special case: let ... in let ...
ppr_cmd (HsCmdLet XCmdLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ cmd :: XRec (GhcPass p) (HsCmd (GhcPass p))
cmd@(L SrcSpanAnnA
_ (HsCmdLet {})))
  = [SDoc] -> SDoc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"let") Int
2 ([SDoc] -> SDoc
hsep [HsLocalBinds (GhcPass p) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBinds (GhcPass p)
binds, String -> SDoc
text String
"in"]),
         XRec (GhcPass p) (HsCmd (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
ppr_lcmd XRec (GhcPass p) (HsCmd (GhcPass p))
cmd]

ppr_cmd (HsCmdLet XCmdLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ XRec (GhcPass p) (HsCmd (GhcPass p))
cmd)
  = [SDoc] -> SDoc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"let") Int
2 (HsLocalBinds (GhcPass p) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBinds (GhcPass p)
binds),
         SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"in")  Int
2 (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsCmd (GhcPass p))
GenLocated SrcSpanAnnA (HsCmd (GhcPass p))
cmd)]

ppr_cmd (HsCmdDo XCmdDo (GhcPass p)
_ (L SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsCmd (GhcPass p))))]
stmts))  = [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))]
-> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprArrowExpr [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsCmd (GhcPass p))))]
stmts

ppr_cmd (HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
arrow LHsExpr (GhcPass p)
arg HsArrAppType
HsFirstOrderApp Bool
True)
  = [SDoc] -> SDoc
hsep [LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arrow, SDoc
larrowt, LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arg]
ppr_cmd (HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
arrow LHsExpr (GhcPass p)
arg HsArrAppType
HsFirstOrderApp Bool
False)
  = [SDoc] -> SDoc
hsep [LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arg, SDoc
arrowt, LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arrow]
ppr_cmd (HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
arrow LHsExpr (GhcPass p)
arg HsArrAppType
HsHigherOrderApp Bool
True)
  = [SDoc] -> SDoc
hsep [LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arrow, SDoc
larrowtt, LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arg]
ppr_cmd (HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
arrow LHsExpr (GhcPass p)
arg HsArrAppType
HsHigherOrderApp Bool
False)
  = [SDoc] -> SDoc
hsep [LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arg, SDoc
arrowtt, LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr LHsExpr (GhcPass p)
arrow]

ppr_cmd (HsCmdArrForm XCmdArrForm (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
op) LexicalFixity
ps_fix Maybe Fixity
rn_fix [LHsCmdTop (GhcPass p)]
args)
  | HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v) <- HsExpr (GhcPass p)
op
  = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
ppr_cmd_infix IdGhcP p
v
  | GhcPass p
GhcTc <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p
  , XExpr (ConLikeTc ConLike
c [Id]
_ [Scaled Type]
_) <- HsExpr (GhcPass p)
op
  = Name -> SDoc
forall a. OutputableBndr a => a -> SDoc
ppr_cmd_infix (ConLike -> Name
conLikeName ConLike
c)
  | Bool
otherwise
  = SDoc
fall_through
  where
    fall_through :: SDoc
fall_through = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"(|" SDoc -> SDoc -> SDoc
<+> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
op)
                      Int
4 ([SDoc] -> SDoc
sep ((GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p)) -> SDoc)
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg(HsCmdTop (GhcPass p) -> SDoc)
-> (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
    -> HsCmdTop (GhcPass p))
-> GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LHsCmdTop (GhcPass p)]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))]
args) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"|)")

    ppr_cmd_infix :: OutputableBndr v => v -> SDoc
    ppr_cmd_infix :: forall a. OutputableBndr a => a -> SDoc
ppr_cmd_infix v
v
      | [LHsCmdTop (GhcPass p)
arg1, LHsCmdTop (GhcPass p)
arg2] <- [LHsCmdTop (GhcPass p)]
args
      , Maybe Fixity -> Bool
forall a. Maybe a -> Bool
isJust Maybe Fixity
rn_fix Bool -> Bool -> Bool
|| LexicalFixity
ps_fix LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
      = SDoc -> Int -> SDoc -> SDoc
hang (HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
arg1))
           Int
4 ([SDoc] -> SDoc
sep [ v -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc v
v, HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
arg2)])
      | Bool
otherwise
      = SDoc
fall_through

ppr_cmd (XCmd XXCmd (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
  GhcPs -> ppr x
  GhcRn -> ppr x
#endif
  GhcPass p
GhcTc -> case XXCmd (GhcPass p)
x of
    HsWrap HsWrapper
w HsCmd GhcTc
cmd -> HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper HsWrapper
w (\Bool
_ -> SDoc -> SDoc
parens (HsCmd GhcTc -> SDoc
forall (p :: Pass). OutputableBndrId p => HsCmd (GhcPass p) -> SDoc
ppr_cmd HsCmd GhcTc
cmd))

pprCmdArg :: (OutputableBndrId p) => HsCmdTop (GhcPass p) -> SDoc
pprCmdArg :: forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg (HsCmdTop XCmdTop (GhcPass p)
_ LHsCmd (GhcPass p)
cmd)
  = LHsCmd (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsCmd (GhcPass p) -> SDoc
ppr_lcmd LHsCmd (GhcPass p)
cmd

instance (OutputableBndrId p) => Outputable (HsCmdTop (GhcPass p)) where
    ppr :: HsCmdTop (GhcPass p) -> SDoc
ppr = HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg

{-
************************************************************************
*                                                                      *
\subsection{@Match@, @GRHSs@, and @GRHS@ datatypes}
*                                                                      *
************************************************************************
-}

type instance XMG         GhcPs b = NoExtField
type instance XMG         GhcRn b = NoExtField
type instance XMG         GhcTc b = MatchGroupTc

type instance XXMatchGroup (GhcPass _) b = DataConCantHappen

type instance XCMatch (GhcPass _) b = EpAnn [AddEpAnn]
type instance XXMatch (GhcPass _) b = DataConCantHappen

instance (OutputableBndrId pr, Outputable body)
            => Outputable (Match (GhcPass pr) body) where
  ppr :: Match (GhcPass pr) body -> SDoc
ppr = Match (GhcPass pr) body -> SDoc
forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatch

isEmptyMatchGroup :: MatchGroup (GhcPass p) body -> Bool
isEmptyMatchGroup :: forall (p :: Pass) body. MatchGroup (GhcPass p) body -> Bool
isEmptyMatchGroup (MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = XRec (GhcPass p) [LMatch (GhcPass p) body]
ms }) = [GenLocated
   (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([GenLocated
    (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
 -> Bool)
-> [GenLocated
      (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
-> Bool
forall a b. (a -> b) -> a -> b
$ GenLocated
  (Anno
     [GenLocated
        (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)])
  [GenLocated
     (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
-> [GenLocated
      (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) [LMatch (GhcPass p) body]
GenLocated
  (Anno
     [GenLocated
        (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)])
  [GenLocated
     (Anno (Match (GhcPass p) body)) (Match (GhcPass p) body)]
ms

-- | Is there only one RHS in this list of matches?
isSingletonMatchGroup :: [LMatch (GhcPass p) body] -> Bool
isSingletonMatchGroup :: forall (p :: Pass) body. [LMatch (GhcPass p) body] -> Bool
isSingletonMatchGroup [LMatch (GhcPass p) body]
matches
  | [L Anno (Match (GhcPass p) body)
_ Match (GhcPass p) body
match] <- [LMatch (GhcPass p) body]
matches
  , Match { m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs { grhssGRHSs :: forall p body. GRHSs p body -> [LGRHS p body]
grhssGRHSs = [LGRHS (GhcPass p) body
_] } } <- Match (GhcPass p) body
match
  = Bool
True
  | Bool
otherwise
  = Bool
False

matchGroupArity :: MatchGroup (GhcPass id) body -> Arity
-- Precondition: MatchGroup is non-empty
-- This is called before type checking, when mg_arg_tys is not set
matchGroupArity :: forall (id :: Pass) body. MatchGroup (GhcPass id) body -> Int
matchGroupArity (MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = XRec (GhcPass id) [LMatch (GhcPass id) body]
alts })
  | L Anno
  [GenLocated
     (Anno (Match (GhcPass id) body)) (Match (GhcPass id) body)]
_ (GenLocated
  (Anno (Match (GhcPass id) body)) (Match (GhcPass id) body)
alt1:[GenLocated
   (Anno (Match (GhcPass id) body)) (Match (GhcPass id) body)]
_) <- XRec (GhcPass id) [LMatch (GhcPass id) body]
alts = [GenLocated SrcSpanAnnA (Pat (GhcPass id))] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (LMatch (GhcPass id) body -> [LPat (GhcPass id)]
forall (id :: Pass) body.
LMatch (GhcPass id) body -> [LPat (GhcPass id)]
hsLMatchPats LMatch (GhcPass id) body
GenLocated
  (Anno (Match (GhcPass id) body)) (Match (GhcPass id) body)
alt1)
  | Bool
otherwise        = String -> Int
forall a. String -> a
panic String
"matchGroupArity"

hsLMatchPats :: LMatch (GhcPass id) body -> [LPat (GhcPass id)]
hsLMatchPats :: forall (id :: Pass) body.
LMatch (GhcPass id) body -> [LPat (GhcPass id)]
hsLMatchPats (L Anno (Match (GhcPass id) body)
_ (Match { m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat (GhcPass id)]
pats })) = [LPat (GhcPass id)]
pats

-- We keep the type checker happy by providing EpAnnComments.  They
-- can only be used if they follow a `where` keyword with no binds,
-- but in that case the comment is attached to the following parsed
-- item. So this can never be used in practice.
type instance XCGRHSs (GhcPass _) _ = EpAnnComments

type instance XXGRHSs (GhcPass _) _ = DataConCantHappen

data GrhsAnn
  = GrhsAnn {
      GrhsAnn -> Maybe EpaLocation
ga_vbar :: Maybe EpaLocation, -- TODO:AZ do we need this?
      GrhsAnn -> AddEpAnn
ga_sep  :: AddEpAnn -- ^ Match separator location
      } deriving (Typeable GrhsAnn
Typeable GrhsAnn
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> GrhsAnn -> c GrhsAnn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c GrhsAnn)
-> (GrhsAnn -> Constr)
-> (GrhsAnn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c GrhsAnn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GrhsAnn))
-> ((forall b. Data b => b -> b) -> GrhsAnn -> GrhsAnn)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r)
-> (forall u. (forall d. Data d => d -> u) -> GrhsAnn -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> GrhsAnn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn)
-> Data GrhsAnn
GrhsAnn -> Constr
GrhsAnn -> DataType
(forall b. Data b => b -> b) -> GrhsAnn -> GrhsAnn
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) -> GrhsAnn -> u
forall u. (forall d. Data d => d -> u) -> GrhsAnn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GrhsAnn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GrhsAnn -> c GrhsAnn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c GrhsAnn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GrhsAnn)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GrhsAnn -> c GrhsAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GrhsAnn -> c GrhsAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GrhsAnn
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GrhsAnn
$ctoConstr :: GrhsAnn -> Constr
toConstr :: GrhsAnn -> Constr
$cdataTypeOf :: GrhsAnn -> DataType
dataTypeOf :: GrhsAnn -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c GrhsAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c GrhsAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GrhsAnn)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GrhsAnn)
$cgmapT :: (forall b. Data b => b -> b) -> GrhsAnn -> GrhsAnn
gmapT :: (forall b. Data b => b -> b) -> GrhsAnn -> GrhsAnn
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GrhsAnn -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> GrhsAnn -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> GrhsAnn -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> GrhsAnn -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> GrhsAnn -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GrhsAnn -> m GrhsAnn
Data)

type instance XCGRHS (GhcPass _) _ = EpAnn GrhsAnn
                                   -- Location of matchSeparator
                                   -- TODO:AZ does this belong on the GRHS, or GRHSs?

type instance XXGRHS (GhcPass _) b = DataConCantHappen

pprMatches :: (OutputableBndrId idR, Outputable body)
           => MatchGroup (GhcPass idR) body -> SDoc
pprMatches :: forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = XRec (GhcPass idR) [LMatch (GhcPass idR) body]
matches }
    = [SDoc] -> SDoc
vcat ((Match (GhcPass idR) body -> SDoc)
-> [Match (GhcPass idR) body] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Match (GhcPass idR) body -> SDoc
forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatch ((GenLocated
   (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)
 -> Match (GhcPass idR) body)
-> [GenLocated
      (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)]
-> [Match (GhcPass idR) body]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)
-> Match (GhcPass idR) body
forall l e. GenLocated l e -> e
unLoc (GenLocated
  (Anno
     [GenLocated
        (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)])
  [GenLocated
     (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)]
-> [GenLocated
      (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)]
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass idR) [LMatch (GhcPass idR) body]
GenLocated
  (Anno
     [GenLocated
        (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)])
  [GenLocated
     (Anno (Match (GhcPass idR) body)) (Match (GhcPass idR) body)]
matches)))
      -- Don't print the type; it's only a place-holder before typechecking

-- Exported to GHC.Hs.Binds, which can't see the defn of HsMatchContext
pprFunBind :: (OutputableBndrId idR)
           => MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR)) -> SDoc
pprFunBind :: forall (idR :: Pass).
OutputableBndrId idR =>
MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR)) -> SDoc
pprFunBind MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR))
matches = MatchGroup
  (GhcPass idR) (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR))
MatchGroup
  (GhcPass idR) (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
matches

-- Exported to GHC.Hs.Binds, which can't see the defn of HsMatchContext
pprPatBind :: forall bndr p . (OutputableBndrId bndr,
                               OutputableBndrId p)
           => LPat (GhcPass bndr) -> GRHSs (GhcPass p) (LHsExpr (GhcPass p)) -> SDoc
pprPatBind :: forall (bndr :: Pass) (p :: Pass).
(OutputableBndrId bndr, OutputableBndrId p) =>
LPat (GhcPass bndr)
-> GRHSs (GhcPass p) (LHsExpr (GhcPass p)) -> SDoc
pprPatBind LPat (GhcPass bndr)
pat GRHSs (GhcPass p) (LHsExpr (GhcPass p))
grhss
 = [SDoc] -> SDoc
sep [GenLocated SrcSpanAnnA (Pat (GhcPass bndr)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat (GhcPass bndr)
GenLocated SrcSpanAnnA (Pat (GhcPass bndr))
pat,
       Int -> SDoc -> SDoc
nest Int
2 (HsMatchContext (GhcPass p)
-> GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs (HsMatchContext (GhcPass p)
forall p. HsMatchContext p
PatBindRhs :: HsMatchContext (GhcPass p)) GRHSs (GhcPass p) (LHsExpr (GhcPass p))
GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
grhss)]

pprMatch :: (OutputableBndrId idR, Outputable body)
         => Match (GhcPass idR) body -> SDoc
pprMatch :: forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatch (Match { m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat (GhcPass idR)]
pats, m_ctxt :: forall p body. Match p body -> HsMatchContext p
m_ctxt = HsMatchContext (GhcPass idR)
ctxt, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs (GhcPass idR) body
grhss })
  = [SDoc] -> SDoc
sep [ [SDoc] -> SDoc
sep (SDoc
herald SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: (GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> GenLocated SrcSpanAnnA (Pat (GhcPass idR))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
appPrec) [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
other_pats)
        , Int -> SDoc -> SDoc
nest Int
2 (HsMatchContext (GhcPass idR) -> GRHSs (GhcPass idR) body -> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext (GhcPass idR)
ctxt GRHSs (GhcPass idR) body
grhss) ]
  where
    (SDoc
herald, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
other_pats)
        = case HsMatchContext (GhcPass idR)
ctxt of
            FunRhs {mc_fun :: forall p. HsMatchContext p -> LIdP (NoGhcTc p)
mc_fun=L Anno (IdGhcP (NoGhcTcPass idR))
_ IdGhcP (NoGhcTcPass idR)
fun, mc_fixity :: forall p. HsMatchContext p -> LexicalFixity
mc_fixity=LexicalFixity
fixity, mc_strictness :: forall p. HsMatchContext p -> SrcStrictness
mc_strictness=SrcStrictness
strictness}
                | SrcStrictness
SrcStrict <- SrcStrictness
strictness
                -> Bool
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. HasCallStack => Bool -> a -> a
assert ([GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)     -- A strict variable binding
                   (Char -> SDoc
char Char
'!'SDoc -> SDoc -> SDoc
<>IdGhcP (NoGhcTcPass idR) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP (NoGhcTcPass idR)
fun, [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

                | LexicalFixity
Prefix <- LexicalFixity
fixity
                -> (IdGhcP (NoGhcTcPass idR) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP (NoGhcTcPass idR)
fun, [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats) -- f x y z = e
                                            -- Not pprBndr; the AbsBinds will
                                            -- have printed the signature
                | Bool
otherwise
                -> case [LPat (GhcPass idR)]
pats of
                     (LPat (GhcPass idR)
p1:LPat (GhcPass idR)
p2:[LPat (GhcPass idR)]
rest)
                        | [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
rest -> (SDoc
pp_infix, [])           -- x &&& y = e
                        | Bool
otherwise -> (SDoc -> SDoc
parens SDoc
pp_infix, [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
rest)  -- (x &&& y) z = e
                        where
                          pp_infix :: SDoc
pp_infix = PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
opPrec LPat (GhcPass idR)
p1
                                     SDoc -> SDoc -> SDoc
<+> IdGhcP (NoGhcTcPass idR) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP (NoGhcTcPass idR)
fun
                                     SDoc -> SDoc -> SDoc
<+> PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
opPrec LPat (GhcPass idR)
p2
                     [LPat (GhcPass idR)]
_ -> String
-> SDoc -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprMatch" (HsMatchContext (GhcPass idR) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsMatchContext (GhcPass idR)
ctxt SDoc -> SDoc -> SDoc
$$ [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            HsMatchContext (GhcPass idR)
LambdaExpr -> (Char -> SDoc
char Char
'\\', [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            -- We don't simply return (empty, pats) to avoid introducing an
            -- additional `nest 2` via the empty herald
            LamCaseAlt LamCaseVariant
LamCases ->
              (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
     [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
    -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]))
-> Maybe
     (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
      [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (SDoc
empty, []) ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
    [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
 -> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
     [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
 -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]))
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
    [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a b. (a -> b) -> a -> b
$ PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
appPrec) ([GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
-> Maybe
     (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
      [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. [a] -> Maybe (a, [a])
uncons [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            ArrowMatchCtxt (ArrowLamCaseAlt LamCaseVariant
LamCases) ->
              (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
     [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
    -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]))
-> Maybe
     (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
      [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (SDoc
empty, []) ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
    [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
 -> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
     [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
 -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]))
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
    [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a b. (a -> b) -> a -> b
$ PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
appPrec) ([GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
-> Maybe
     (GenLocated SrcSpanAnnA (Pat (GhcPass idR)),
      [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. [a] -> Maybe (a, [a])
uncons [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            ArrowMatchCtxt HsArrowMatchContext
KappaExpr -> (Char -> SDoc
char Char
'\\', [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            ArrowMatchCtxt HsArrowMatchContext
ProcExpr -> (String -> SDoc
text String
"proc", [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            HsMatchContext (GhcPass idR)
_ -> case [LPat (GhcPass idR)]
pats of
                   []    -> (SDoc
empty, [])
                   [LPat (GhcPass idR)
pat] -> (GenLocated SrcSpanAnnA (Pat (GhcPass idR)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat (GhcPass idR)
GenLocated SrcSpanAnnA (Pat (GhcPass idR))
pat, [])  -- No parens around the single pat in a case
                   [LPat (GhcPass idR)]
_     -> String
-> SDoc -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprMatch" (HsMatchContext (GhcPass idR) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsMatchContext (GhcPass idR)
ctxt SDoc -> SDoc -> SDoc
$$ [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

pprGRHSs :: (OutputableBndrId idR, Outputable body)
         => HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs :: forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext passL
ctxt (GRHSs XCGRHSs (GhcPass idR) body
_ [LGRHS (GhcPass idR) body]
grhss HsLocalBinds (GhcPass idR)
binds)
  = [SDoc] -> SDoc
vcat ((GenLocated
   (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
 -> SDoc)
-> [GenLocated
      (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext passL
ctxt (GRHS (GhcPass idR) body -> SDoc)
-> (GenLocated
      (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
    -> GRHS (GhcPass idR) body)
-> GenLocated
     (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated
  (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
-> GRHS (GhcPass idR) body
forall l e. GenLocated l e -> e
unLoc) [LGRHS (GhcPass idR) body]
[GenLocated
   (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)]
grhss)
  -- Print the "where" even if the contents of the binds is empty. Only
  -- EmptyLocalBinds means no "where" keyword
 SDoc -> SDoc -> SDoc
$$ Bool -> SDoc -> SDoc
ppUnless (HsLocalBinds (GhcPass idR) -> Bool
forall a b. HsLocalBindsLR a b -> Bool
eqEmptyLocalBinds HsLocalBinds (GhcPass idR)
binds)
      (String -> SDoc
text String
"where" SDoc -> SDoc -> SDoc
$$ Int -> SDoc -> SDoc
nest Int
4 (HsLocalBinds (GhcPass idR) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBinds (GhcPass idR)
binds))

pprGRHS :: (OutputableBndrId idR, Outputable body)
        => HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS :: forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext passL
ctxt (GRHS XCGRHS (GhcPass idR) body
_ [] body
body)
 =  HsMatchContext passL -> body -> SDoc
forall body passL.
Outputable body =>
HsMatchContext passL -> body -> SDoc
pp_rhs HsMatchContext passL
ctxt body
body

pprGRHS HsMatchContext passL
ctxt (GRHS XCGRHS (GhcPass idR) body
_ [GuardLStmt (GhcPass idR)]
guards body
body)
 = [SDoc] -> SDoc
sep [SDoc
vbar SDoc -> SDoc -> SDoc
<+> [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idR)
      (GhcPass idR)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))))]
-> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [GuardLStmt (GhcPass idR)]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idR)
      (GhcPass idR)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))))]
guards, HsMatchContext passL -> body -> SDoc
forall body passL.
Outputable body =>
HsMatchContext passL -> body -> SDoc
pp_rhs HsMatchContext passL
ctxt body
body]

pp_rhs :: Outputable body => HsMatchContext passL -> body -> SDoc
pp_rhs :: forall body passL.
Outputable body =>
HsMatchContext passL -> body -> SDoc
pp_rhs HsMatchContext passL
ctxt body
rhs = HsMatchContext passL -> SDoc
forall p. HsMatchContext p -> SDoc
matchSeparator HsMatchContext passL
ctxt SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
pprDeeper (body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
rhs)

instance Outputable GrhsAnn where
  ppr :: GrhsAnn -> SDoc
ppr (GrhsAnn Maybe EpaLocation
v AddEpAnn
s) = String -> SDoc
text String
"GrhsAnn" SDoc -> SDoc -> SDoc
<+> Maybe EpaLocation -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe EpaLocation
v SDoc -> SDoc -> SDoc
<+> AddEpAnn -> SDoc
forall a. Outputable a => a -> SDoc
ppr AddEpAnn
s

{-
************************************************************************
*                                                                      *
\subsection{Do stmts and list comprehensions}
*                                                                      *
************************************************************************
-}

-- Extra fields available post typechecking for RecStmt.
data RecStmtTc =
  RecStmtTc
     { RecStmtTc -> Type
recS_bind_ty :: Type       -- S in (>>=) :: Q -> (R -> S) -> T
     , RecStmtTc -> [HsExpr GhcTc]
recS_later_rets :: [PostTcExpr] -- (only used in the arrow version)
     , RecStmtTc -> [HsExpr GhcTc]
recS_rec_rets :: [PostTcExpr] -- These expressions correspond 1-to-1
                                  -- with recS_later_ids and recS_rec_ids,
                                  -- and are the expressions that should be
                                  -- returned by the recursion.
                                  -- They may not quite be the Ids themselves,
                                  -- because the Id may be *polymorphic*, but
                                  -- the returned thing has to be *monomorphic*,
                                  -- so they may be type applications

      , RecStmtTc -> Type
recS_ret_ty :: Type        -- The type of
                                   -- do { stmts; return (a,b,c) }
                                   -- With rebindable syntax the type might not
                                   -- be quite as simple as (m (tya, tyb, tyc)).
      }


type instance XLastStmt        (GhcPass _) (GhcPass _) b = NoExtField

type instance XBindStmt        (GhcPass _) GhcPs b = EpAnn [AddEpAnn]
type instance XBindStmt        (GhcPass _) GhcRn b = XBindStmtRn
type instance XBindStmt        (GhcPass _) GhcTc b = XBindStmtTc

data XBindStmtRn = XBindStmtRn
  { XBindStmtRn -> SyntaxExpr GhcRn
xbsrn_bindOp :: SyntaxExpr GhcRn
  , XBindStmtRn -> FailOperator GhcRn
xbsrn_failOp :: FailOperator GhcRn
  }

data XBindStmtTc = XBindStmtTc
  { XBindStmtTc -> SyntaxExpr GhcTc
xbstc_bindOp :: SyntaxExpr GhcTc
  , XBindStmtTc -> Type
xbstc_boundResultType :: Type -- If (>>=) :: Q -> (R -> S) -> T, this is S
  , XBindStmtTc -> Type
xbstc_boundResultMult :: Mult -- If (>>=) :: Q -> (R -> S) -> T, this is S
  , XBindStmtTc -> FailOperator GhcTc
xbstc_failOp :: FailOperator GhcTc
  }

type instance XApplicativeStmt (GhcPass _) GhcPs b = NoExtField
type instance XApplicativeStmt (GhcPass _) GhcRn b = NoExtField
type instance XApplicativeStmt (GhcPass _) GhcTc b = Type

type instance XBodyStmt        (GhcPass _) GhcPs b = NoExtField
type instance XBodyStmt        (GhcPass _) GhcRn b = NoExtField
type instance XBodyStmt        (GhcPass _) GhcTc b = Type

type instance XLetStmt         (GhcPass _) (GhcPass _) b = EpAnn [AddEpAnn]

type instance XParStmt         (GhcPass _) GhcPs b = NoExtField
type instance XParStmt         (GhcPass _) GhcRn b = NoExtField
type instance XParStmt         (GhcPass _) GhcTc b = Type

type instance XTransStmt       (GhcPass _) GhcPs b = EpAnn [AddEpAnn]
type instance XTransStmt       (GhcPass _) GhcRn b = NoExtField
type instance XTransStmt       (GhcPass _) GhcTc b = Type

type instance XRecStmt         (GhcPass _) GhcPs b = EpAnn AnnList
type instance XRecStmt         (GhcPass _) GhcRn b = NoExtField
type instance XRecStmt         (GhcPass _) GhcTc b = RecStmtTc

type instance XXStmtLR         (GhcPass _) (GhcPass _) b = DataConCantHappen

type instance XParStmtBlock  (GhcPass pL) (GhcPass pR) = NoExtField
type instance XXParStmtBlock (GhcPass pL) (GhcPass pR) = DataConCantHappen

type instance XApplicativeArgOne GhcPs = NoExtField
type instance XApplicativeArgOne GhcRn = FailOperator GhcRn
type instance XApplicativeArgOne GhcTc = FailOperator GhcTc

type instance XApplicativeArgMany (GhcPass _) = NoExtField
type instance XXApplicativeArg    (GhcPass _) = DataConCantHappen

instance (Outputable (StmtLR (GhcPass idL) (GhcPass idL) (LHsExpr (GhcPass idL))),
          Outputable (XXParStmtBlock (GhcPass idL) (GhcPass idR)))
        => Outputable (ParStmtBlock (GhcPass idL) (GhcPass idR)) where
  ppr :: ParStmtBlock (GhcPass idL) (GhcPass idR) -> SDoc
ppr (ParStmtBlock XParStmtBlock (GhcPass idL) (GhcPass idR)
_ [ExprLStmt (GhcPass idL)]
stmts [IdP (GhcPass idR)]
_ SyntaxExpr (GhcPass idR)
_) = [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
-> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [ExprLStmt (GhcPass idL)]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
stmts

instance (OutputableBndrId pl, OutputableBndrId pr,
                 Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA,
          Outputable body)
         => Outputable (StmtLR (GhcPass pl) (GhcPass pr) body) where
    ppr :: StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
ppr StmtLR (GhcPass pl) (GhcPass pr) body
stmt = StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
forall (pl :: Pass) (pr :: Pass) body.
(OutputableBndrId pl, OutputableBndrId pr,
 Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA,
 Outputable body) =>
StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
pprStmt StmtLR (GhcPass pl) (GhcPass pr) body
stmt

pprStmt :: forall idL idR body . (OutputableBndrId idL,
                                  OutputableBndrId idR,
                 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
                                  Outputable body)
        => (StmtLR (GhcPass idL) (GhcPass idR) body) -> SDoc
pprStmt :: forall (pl :: Pass) (pr :: Pass) body.
(OutputableBndrId pl, OutputableBndrId pr,
 Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA,
 Outputable body) =>
StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
pprStmt (LastStmt XLastStmt (GhcPass idL) (GhcPass idR) body
_ body
expr Maybe Bool
m_dollar_stripped SyntaxExpr (GhcPass idR)
_)
  = SDoc -> SDoc
whenPprDebug (String -> SDoc
text String
"[last]") SDoc -> SDoc -> SDoc
<+>
      (case Maybe Bool
m_dollar_stripped of
        Just Bool
True -> String -> SDoc
text String
"return $"
        Just Bool
False -> String -> SDoc
text String
"return"
        Maybe Bool
Nothing -> SDoc
empty) SDoc -> SDoc -> SDoc
<+>
      body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
expr
pprStmt (BindStmt XBindStmt (GhcPass idL) (GhcPass idR) body
_ LPat (GhcPass idL)
pat body
expr)  = GenLocated SrcSpanAnnA (Pat (GhcPass idL)) -> body -> SDoc
forall pat expr.
(Outputable pat, Outputable expr) =>
pat -> expr -> SDoc
pprBindStmt LPat (GhcPass idL)
GenLocated SrcSpanAnnA (Pat (GhcPass idL))
pat body
expr
pprStmt (LetStmt XLetStmt (GhcPass idL) (GhcPass idR) body
_ HsLocalBindsLR (GhcPass idL) (GhcPass idR)
binds)      = [SDoc] -> SDoc
hsep [String -> SDoc
text String
"let", HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprBinds HsLocalBindsLR (GhcPass idL) (GhcPass idR)
binds]
pprStmt (BodyStmt XBodyStmt (GhcPass idL) (GhcPass idR) body
_ body
expr SyntaxExpr (GhcPass idR)
_ SyntaxExpr (GhcPass idR)
_)  = body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
expr
pprStmt (ParStmt XParStmt (GhcPass idL) (GhcPass idR) body
_ [ParStmtBlock (GhcPass idL) (GhcPass idR)]
stmtss HsExpr (GhcPass idR)
_ SyntaxExpr (GhcPass idR)
_) = [SDoc] -> SDoc
sep (SDoc -> [SDoc] -> [SDoc]
punctuate (String -> SDoc
text String
" | ") ((ParStmtBlock (GhcPass idL) (GhcPass idR) -> SDoc)
-> [ParStmtBlock (GhcPass idL) (GhcPass idR)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map ParStmtBlock (GhcPass idL) (GhcPass idR) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [ParStmtBlock (GhcPass idL) (GhcPass idR)]
stmtss))

pprStmt (TransStmt { trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_stmts = [ExprLStmt (GhcPass idL)]
stmts, trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_by = Maybe (LHsExpr (GhcPass idR))
by
                   , trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_using = LHsExpr (GhcPass idR)
using, trS_form :: forall idL idR body. StmtLR idL idR body -> TransForm
trS_form = TransForm
form })
  = [SDoc] -> SDoc
sep ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ((GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (StmtLR
         (GhcPass idL)
         (GhcPass idL)
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [ExprLStmt (GhcPass idL)]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
stmts [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++ [Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))
-> TransForm
-> SDoc
forall body.
Outputable body =>
Maybe body -> body -> TransForm -> SDoc
pprTransStmt Maybe (LHsExpr (GhcPass idR))
Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
by LHsExpr (GhcPass idR)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))
using TransForm
form])

pprStmt (RecStmt { recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts = XRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body]
segment, recS_rec_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_rec_ids = [IdP (GhcPass idR)]
rec_ids
                 , recS_later_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_later_ids = [IdP (GhcPass idR)]
later_ids })
  = String -> SDoc
text String
"rec" SDoc -> SDoc -> SDoc
<+>
    [SDoc] -> SDoc
vcat [ [LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts (GenLocated
  (Anno
     [GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)])
  [GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)]
-> [GenLocated
      SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)]
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body]
GenLocated
  (Anno
     [GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)])
  [GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)]
segment)
         , SDoc -> SDoc
whenPprDebug ([SDoc] -> SDoc
vcat [ String -> SDoc
text String
"rec_ids=" SDoc -> SDoc -> SDoc
<> [IdGhcP idR] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IdP (GhcPass idR)]
[IdGhcP idR]
rec_ids
                            , String -> SDoc
text String
"later_ids=" SDoc -> SDoc -> SDoc
<> [IdGhcP idR] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IdP (GhcPass idR)]
[IdGhcP idR]
later_ids])]

pprStmt (ApplicativeStmt XApplicativeStmt (GhcPass idL) (GhcPass idR) body
_ [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
args Maybe (SyntaxExpr (GhcPass idR))
mb_join)
  = (PprStyle -> SDoc) -> SDoc
getPprStyle ((PprStyle -> SDoc) -> SDoc) -> (PprStyle -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \PprStyle
style ->
      if PprStyle -> Bool
userStyle PprStyle
style
         then SDoc
pp_for_user
         else SDoc
pp_debug
  where
  -- make all the Applicative stuff invisible in error messages by
  -- flattening the whole ApplicativeStmt nest back to a sequence
  -- of statements.
   pp_for_user :: SDoc
pp_for_user = [SDoc] -> SDoc
vcat ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ ((SyntaxExprGhc idR, ApplicativeArg (GhcPass idL)) -> [SDoc])
-> [(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprGhc idR, ApplicativeArg (GhcPass idL)) -> [SDoc]
forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
[(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))]
args

   -- ppr directly rather than transforming here, because we need to
   -- inject a "return" which is hard when we're polymorphic in the id
   -- type.
   flattenStmt :: ExprLStmt (GhcPass idL) -> [SDoc]
   flattenStmt :: ExprLStmt (GhcPass idL) -> [SDoc]
flattenStmt (L SrcSpanAnnA
_ (ApplicativeStmt XApplicativeStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
_ [(SyntaxExpr (GhcPass idL), ApplicativeArg (GhcPass idL))]
args Maybe (SyntaxExpr (GhcPass idL))
_)) = ((SyntaxExprGhc idL, ApplicativeArg (GhcPass idL)) -> [SDoc])
-> [(SyntaxExprGhc idL, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprGhc idL, ApplicativeArg (GhcPass idL)) -> [SDoc]
forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg [(SyntaxExpr (GhcPass idL), ApplicativeArg (GhcPass idL))]
[(SyntaxExprGhc idL, ApplicativeArg (GhcPass idL))]
args
   flattenStmt ExprLStmt (GhcPass idL)
stmt = [GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr ExprLStmt (GhcPass idL)
GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
stmt]

   flattenArg :: forall a . (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
   flattenArg :: forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg (a
_, ApplicativeArgOne XApplicativeArgOne (GhcPass idL)
_ LPat (GhcPass idL)
pat LHsExpr (GhcPass idL)
expr Bool
isBody)
     | Bool
isBody =  [GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass idL)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
expr] -- See Note [Applicative BodyStmt]
     | Bool
otherwise = [GenLocated SrcSpanAnnA (Pat (GhcPass idL))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)) -> SDoc
forall pat expr.
(Outputable pat, Outputable expr) =>
pat -> expr -> SDoc
pprBindStmt LPat (GhcPass idL)
GenLocated SrcSpanAnnA (Pat (GhcPass idL))
pat LHsExpr (GhcPass idL)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
expr]
   flattenArg (a
_, ApplicativeArgMany XApplicativeArgMany (GhcPass idL)
_ [ExprLStmt (GhcPass idL)]
stmts HsExpr (GhcPass idL)
_ LPat (GhcPass idL)
_ HsDoFlavour
_) =
     (GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
 -> [SDoc])
-> [GenLocated
      SrcSpanAnnA
      (StmtLR
         (GhcPass idL)
         (GhcPass idL)
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
-> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ExprLStmt (GhcPass idL) -> [SDoc]
GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
-> [SDoc]
flattenStmt [ExprLStmt (GhcPass idL)]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
stmts

   pp_debug :: SDoc
pp_debug =
     let
         ap_expr :: SDoc
ap_expr = [SDoc] -> SDoc
sep (SDoc -> [SDoc] -> [SDoc]
punctuate (String -> SDoc
text String
" |") (((SyntaxExprGhc idR, ApplicativeArg (GhcPass idL)) -> SDoc)
-> [(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (SyntaxExprGhc idR, ApplicativeArg (GhcPass idL)) -> SDoc
forall a. (a, ApplicativeArg (GhcPass idL)) -> SDoc
pp_arg [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
[(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))]
args))
     in
       SDoc -> SDoc
whenPprDebug (if Maybe (SyntaxExprGhc idR) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (SyntaxExpr (GhcPass idR))
Maybe (SyntaxExprGhc idR)
mb_join then String -> SDoc
text String
"[join]" else SDoc
empty) SDoc -> SDoc -> SDoc
<+>
       (if [(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))] -> Int -> Bool
forall a. [a] -> Int -> Bool
lengthAtLeast [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
[(SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))]
args Int
2 then SDoc -> SDoc
parens else SDoc -> SDoc
forall a. a -> a
id) SDoc
ap_expr

   pp_arg :: (a, ApplicativeArg (GhcPass idL)) -> SDoc
   pp_arg :: forall a. (a, ApplicativeArg (GhcPass idL)) -> SDoc
pp_arg (a
_, ApplicativeArg (GhcPass idL)
applicativeArg) = ApplicativeArg (GhcPass idL) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ApplicativeArg (GhcPass idL)
applicativeArg

pprBindStmt :: (Outputable pat, Outputable expr) => pat -> expr -> SDoc
pprBindStmt :: forall pat expr.
(Outputable pat, Outputable expr) =>
pat -> expr -> SDoc
pprBindStmt pat
pat expr
expr = [SDoc] -> SDoc
hsep [pat -> SDoc
forall a. Outputable a => a -> SDoc
ppr pat
pat, SDoc
larrow, expr -> SDoc
forall a. Outputable a => a -> SDoc
ppr expr
expr]

instance (OutputableBndrId idL)
      => Outputable (ApplicativeArg (GhcPass idL)) where
  ppr :: ApplicativeArg (GhcPass idL) -> SDoc
ppr = ApplicativeArg (GhcPass idL) -> SDoc
forall (idL :: Pass).
OutputableBndrId idL =>
ApplicativeArg (GhcPass idL) -> SDoc
pprArg

pprArg :: forall idL . (OutputableBndrId idL) => ApplicativeArg (GhcPass idL) -> SDoc
pprArg :: forall (idL :: Pass).
OutputableBndrId idL =>
ApplicativeArg (GhcPass idL) -> SDoc
pprArg (ApplicativeArgOne XApplicativeArgOne (GhcPass idL)
_ LPat (GhcPass idL)
pat LHsExpr (GhcPass idL)
expr Bool
isBody)
  | Bool
isBody = GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass idL)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
expr -- See Note [Applicative BodyStmt]
  | Bool
otherwise = GenLocated SrcSpanAnnA (Pat (GhcPass idL))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)) -> SDoc
forall pat expr.
(Outputable pat, Outputable expr) =>
pat -> expr -> SDoc
pprBindStmt LPat (GhcPass idL)
GenLocated SrcSpanAnnA (Pat (GhcPass idL))
pat LHsExpr (GhcPass idL)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
expr
pprArg (ApplicativeArgMany XApplicativeArgMany (GhcPass idL)
_ [ExprLStmt (GhcPass idL)]
stmts HsExpr (GhcPass idL)
return LPat (GhcPass idL)
pat HsDoFlavour
ctxt) =
     GenLocated SrcSpanAnnA (Pat (GhcPass idL)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat (GhcPass idL)
GenLocated SrcSpanAnnA (Pat (GhcPass idL))
pat SDoc -> SDoc -> SDoc
<+>
     String -> SDoc
text String
"<-" SDoc -> SDoc -> SDoc
<+>
     HsDoFlavour
-> [LStmt
      (GhcPass idL) (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))]
-> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
HsDoFlavour -> [LStmt (GhcPass p) body] -> SDoc
pprDo HsDoFlavour
ctxt ([ExprLStmt (GhcPass idL)]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
stmts [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass idL)
      (GhcPass idL)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
-> [GenLocated
      SrcSpanAnnA
      (StmtLR
         (GhcPass idL)
         (GhcPass idL)
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
-> [GenLocated
      SrcSpanAnnA
      (StmtLR
         (GhcPass idL)
         (GhcPass idL)
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))]
forall a. [a] -> [a] -> [a]
++
                   [StmtLR
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
-> GenLocated
     SrcSpanAnnA
     (StmtLR
        (GhcPass idL)
        (GhcPass idL)
        (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
forall a an. a -> LocatedAn an a
noLocA (XLastStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
-> Maybe Bool
-> SyntaxExpr (GhcPass idL)
-> StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt XLastStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
NoExtField
noExtField (HsExpr (GhcPass idL)
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
forall a an. a -> LocatedAn an a
noLocA HsExpr (GhcPass idL)
return) Maybe Bool
forall a. Maybe a
Nothing SyntaxExpr (GhcPass idL)
forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr)])

pprTransformStmt :: (OutputableBndrId p)
                 => [IdP (GhcPass p)] -> LHsExpr (GhcPass p)
                 -> Maybe (LHsExpr (GhcPass p)) -> SDoc
pprTransformStmt :: forall (p :: Pass).
OutputableBndrId p =>
[IdP (GhcPass p)]
-> LHsExpr (GhcPass p) -> Maybe (LHsExpr (GhcPass p)) -> SDoc
pprTransformStmt [IdP (GhcPass p)]
bndrs LHsExpr (GhcPass p)
using Maybe (LHsExpr (GhcPass p))
by
  = [SDoc] -> SDoc
sep [ String -> SDoc
text String
"then" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
whenPprDebug (SDoc -> SDoc
braces ([IdGhcP p] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IdP (GhcPass p)]
[IdGhcP p]
bndrs))
        , Int -> SDoc -> SDoc
nest Int
2 (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
using)
        , Int -> SDoc -> SDoc
nest Int
2 (Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))) -> SDoc
forall body. Outputable body => Maybe body -> SDoc
pprBy Maybe (LHsExpr (GhcPass p))
Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
by)]

pprTransStmt :: Outputable body => Maybe body -> body -> TransForm -> SDoc
pprTransStmt :: forall body.
Outputable body =>
Maybe body -> body -> TransForm -> SDoc
pprTransStmt Maybe body
by body
using TransForm
ThenForm
  = [SDoc] -> SDoc
sep [ String -> SDoc
text String
"then", Int -> SDoc -> SDoc
nest Int
2 (body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
using), Int -> SDoc -> SDoc
nest Int
2 (Maybe body -> SDoc
forall body. Outputable body => Maybe body -> SDoc
pprBy Maybe body
by)]
pprTransStmt Maybe body
by body
using TransForm
GroupForm
  = [SDoc] -> SDoc
sep [ String -> SDoc
text String
"then group", Int -> SDoc -> SDoc
nest Int
2 (Maybe body -> SDoc
forall body. Outputable body => Maybe body -> SDoc
pprBy Maybe body
by), Int -> SDoc -> SDoc
nest Int
2 (String -> SDoc
text String
"using" SDoc -> SDoc -> SDoc
<+> body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
using)]

pprBy :: Outputable body => Maybe body -> SDoc
pprBy :: forall body. Outputable body => Maybe body -> SDoc
pprBy Maybe body
Nothing  = SDoc
empty
pprBy (Just body
e) = String -> SDoc
text String
"by" SDoc -> SDoc -> SDoc
<+> body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
e

pprDo :: (OutputableBndrId p, Outputable body,
                 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA
         )
      => HsDoFlavour -> [LStmt (GhcPass p) body] -> SDoc
pprDo :: forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
HsDoFlavour -> [LStmt (GhcPass p) body] -> SDoc
pprDo (DoExpr Maybe ModuleName
m)    [LStmt (GhcPass p) body]
stmts =
  Maybe ModuleName -> SDoc
ppr_module_name_prefix Maybe ModuleName
m SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"do"  SDoc -> SDoc -> SDoc
<+> [LStmt (GhcPass p) body] -> SDoc
forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts [LStmt (GhcPass p) body]
stmts
pprDo HsDoFlavour
GhciStmtCtxt  [LStmt (GhcPass p) body]
stmts = String -> SDoc
text String
"do"  SDoc -> SDoc -> SDoc
<+> [LStmt (GhcPass p) body] -> SDoc
forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts [LStmt (GhcPass p) body]
stmts
pprDo (MDoExpr Maybe ModuleName
m)   [LStmt (GhcPass p) body]
stmts =
  Maybe ModuleName -> SDoc
ppr_module_name_prefix Maybe ModuleName
m SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"mdo"  SDoc -> SDoc -> SDoc
<+> [LStmt (GhcPass p) body] -> SDoc
forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts [LStmt (GhcPass p) body]
stmts
pprDo HsDoFlavour
ListComp      [LStmt (GhcPass p) body]
stmts = SDoc -> SDoc
brackets    (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [LStmt (GhcPass p) body] -> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprComp [LStmt (GhcPass p) body]
stmts
pprDo HsDoFlavour
MonadComp     [LStmt (GhcPass p) body]
stmts = SDoc -> SDoc
brackets    (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [LStmt (GhcPass p) body] -> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprComp [LStmt (GhcPass p) body]
stmts

pprArrowExpr :: (OutputableBndrId p, Outputable body,
                 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA
         )
      => [LStmt (GhcPass p) body] -> SDoc
pprArrowExpr :: forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprArrowExpr [LStmt (GhcPass p) body]
stmts = String -> SDoc
text String
"do"  SDoc -> SDoc -> SDoc
<+> [LStmt (GhcPass p) body] -> SDoc
forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts [LStmt (GhcPass p) body]
stmts

ppr_module_name_prefix :: Maybe ModuleName -> SDoc
ppr_module_name_prefix :: Maybe ModuleName -> SDoc
ppr_module_name_prefix = \case
  Maybe ModuleName
Nothing -> SDoc
empty
  Just ModuleName
module_name -> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
module_name SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'.'

ppr_do_stmts :: (OutputableBndrId idL, OutputableBndrId idR,
                 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
                 Outputable body)
             => [LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
-- Print a bunch of do stmts
ppr_do_stmts :: forall (idL :: Pass) (idR :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 Outputable body) =>
[LStmtLR (GhcPass idL) (GhcPass idR) body] -> SDoc
ppr_do_stmts [LStmtLR (GhcPass idL) (GhcPass idR) body]
stmts = ([SDoc] -> SDoc) -> [SDoc] -> SDoc
pprDeeperList [SDoc] -> SDoc
vcat ((GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LStmtLR (GhcPass idL) (GhcPass idR) body]
[GenLocated SrcSpanAnnA (StmtLR (GhcPass idL) (GhcPass idR) body)]
stmts)

pprComp :: (OutputableBndrId p, Outputable body,
                 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA)
        => [LStmt (GhcPass p) body] -> SDoc
pprComp :: forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprComp [LStmt (GhcPass p) body]
quals     -- Prints:  body | qual1, ..., qualn
  | Just ([GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
initStmts, L SrcSpanAnnA
_ (LastStmt XLastStmt (GhcPass p) (GhcPass p) body
_ body
body Maybe Bool
_ SyntaxExpr (GhcPass p)
_)) <- [GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
-> Maybe
     ([GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)],
      GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body))
forall a. [a] -> Maybe ([a], a)
snocView [LStmt (GhcPass p) body]
[GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
quals
  = if [GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
initStmts
       -- If there are no statements in a list comprehension besides the last
       -- one, we simply treat it like a normal list. This does arise
       -- occasionally in code that GHC generates, e.g., in implementations of
       -- 'range' for derived 'Ix' instances for product datatypes with exactly
       -- one constructor (e.g., see #12583).
       then body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
body
       else SDoc -> Int -> SDoc -> SDoc
hang (body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
body SDoc -> SDoc -> SDoc
<+> SDoc
vbar) Int
2 ([LStmt (GhcPass p) body] -> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprQuals [LStmt (GhcPass p) body]
[GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
initStmts)
  | Bool
otherwise
  = String -> SDoc -> SDoc
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprComp" ([LStmt (GhcPass p) body] -> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprQuals [LStmt (GhcPass p) body]
quals)

pprQuals :: (OutputableBndrId p, Outputable body,
                 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA)
         => [LStmt (GhcPass p) body] -> SDoc
-- Show list comprehension qualifiers separated by commas
pprQuals :: forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprQuals [LStmt (GhcPass p) body]
quals = [GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
-> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [LStmt (GhcPass p) body]
[GenLocated SrcSpanAnnA (StmtLR (GhcPass p) (GhcPass p) body)]
quals

{-
************************************************************************
*                                                                      *
                Template Haskell quotation brackets
*                                                                      *
************************************************************************
-}

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

type instance XTypedSplice   (GhcPass _) = EpAnn [AddEpAnn]
type instance XUntypedSplice (GhcPass _) = EpAnn [AddEpAnn]
type instance XQuasiQuote    (GhcPass _) = NoExtField
type instance XSpliced       (GhcPass _) = NoExtField
type instance XXSplice       GhcPs       = DataConCantHappen
type instance XXSplice       GhcRn       = DataConCantHappen
type instance XXSplice       GhcTc       = HsSplicedT

-- See Note [Running typed splices in the zonker]
-- These are the arguments that are passed to `GHC.Tc.Gen.Splice.runTopSplice`
data DelayedSplice =
  DelayedSplice
    TcLclEnv          -- The local environment to run the splice in
    (LHsExpr GhcRn)   -- The original renamed expression
    TcType            -- The result type of running the splice, unzonked
    (LHsExpr GhcTc)   -- The typechecked expression to run and splice in the result

-- A Data instance which ignores the argument of 'DelayedSplice'.
instance Data DelayedSplice where
  gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DelayedSplice
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ Constr
_ = String -> c DelayedSplice
forall a. String -> a
panic String
"DelayedSplice"
  toConstr :: DelayedSplice -> Constr
toConstr  DelayedSplice
a   = DataType -> String -> [String] -> Fixity -> Constr
mkConstr (DelayedSplice -> DataType
forall a. Data a => a -> DataType
dataTypeOf DelayedSplice
a) String
"DelayedSplice" [] Fixity
Data.Prefix
  dataTypeOf :: DelayedSplice -> DataType
dataTypeOf DelayedSplice
a  = String -> [Constr] -> DataType
mkDataType String
"HsExpr.DelayedSplice" [DelayedSplice -> Constr
forall a. Data a => a -> Constr
toConstr DelayedSplice
a]

-- See Note [Pending Splices]
type SplicePointName = Name

-- | Pending Renamer Splice
data PendingRnSplice
  = PendingRnSplice UntypedSpliceFlavour SplicePointName (LHsExpr GhcRn)

-- | Pending Type-checker Splice
data PendingTcSplice
  = PendingTcSplice SplicePointName (LHsExpr GhcTc)

{-
Note [Pending Splices]
~~~~~~~~~~~~~~~~~~~~~~
When we rename an untyped bracket, we name and lift out all the nested
splices, so that when the typechecker hits the bracket, it can
typecheck those nested splices without having to walk over the untyped
bracket code.  So for example
    [| f $(g x) |]
looks like

    HsUntypedBracket _ (HsApp (HsVar "f") (HsSpliceE _ (HsUntypedSplice sn (g x)))

which the renamer rewrites to

    HsUntypedBracket
        [PendingRnSplice UntypedExpSplice sn (g x)]
        (HsApp (HsVar f) (HsSpliceE _ (HsUntypedSplice sn (g x)))

* The 'sn' is the Name of the splice point, the SplicePointName

* The PendingRnExpSplice gives the splice that splice-point name maps to;
  and the typechecker can now conveniently find these sub-expressions

* Note that a nested splice, such as the `$(g x)` now appears twice:
  - In the PendingRnSplice: this is the version that will later be typechecked
  - In the HsSpliceE in the body of the bracket. This copy is used only for pretty printing.

There are four varieties of pending splices generated by the renamer,
distinguished by their UntypedSpliceFlavour

 * Pending expression splices (UntypedExpSplice), e.g.,
       [|$(f x) + 2|]

   UntypedExpSplice is also used for
     * quasi-quotes, where the pending expression expands to
          $(quoter "...blah...")
       (see GHC.Rename.Splice.makePending, HsQuasiQuote case)

     * cross-stage lifting, where the pending expression expands to
          $(lift x)
       (see GHC.Rename.Splice.checkCrossStageLifting)

 * Pending pattern splices (UntypedPatSplice), e.g.,
       [| \$(f x) -> x |]

 * Pending type splices (UntypedTypeSplice), e.g.,
       [| f :: $(g x) |]

 * Pending declaration (UntypedDeclSplice), e.g.,
       [| let $(f x) in ... |]

There is a fifth variety of pending splice, which is generated by the type
checker:

  * Pending *typed* expression splices, (PendingTcSplice), e.g.,
        [||1 + $$(f 2)||]
-}

instance OutputableBndrId p
       => Outputable (HsSplicedThing (GhcPass p)) where
  ppr :: HsSplicedThing (GhcPass p) -> SDoc
ppr (HsSplicedExpr HsExpr (GhcPass p)
e) = HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
e
  ppr (HsSplicedTy   HsType (GhcPass p)
t) = HsType (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsType (GhcPass p)
t
  ppr (HsSplicedPat  Pat (GhcPass p)
p) = Pat (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr Pat (GhcPass p)
p

instance (OutputableBndrId p) => Outputable (HsSplice (GhcPass p)) where
  ppr :: HsSplice (GhcPass p) -> SDoc
ppr HsSplice (GhcPass p)
s = HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
pprSplice HsSplice (GhcPass p)
s

pprPendingSplice :: (OutputableBndrId p)
                 => SplicePointName -> LHsExpr (GhcPass p) -> SDoc
pprPendingSplice :: forall (p :: Pass).
OutputableBndrId p =>
Name -> LHsExpr (GhcPass p) -> SDoc
pprPendingSplice Name
n LHsExpr (GhcPass p)
e = SDoc -> SDoc
angleBrackets (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
n SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<+> GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
forall (p :: Pass). LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
stripParensLHsExpr LHsExpr (GhcPass p)
e))

pprSpliceDecl ::  (OutputableBndrId p)
          => HsSplice (GhcPass p) -> SpliceExplicitFlag -> SDoc
pprSpliceDecl :: forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SpliceExplicitFlag -> SDoc
pprSpliceDecl e :: HsSplice (GhcPass p)
e@HsQuasiQuote{} SpliceExplicitFlag
_ = HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
pprSplice HsSplice (GhcPass p)
e
pprSpliceDecl HsSplice (GhcPass p)
e SpliceExplicitFlag
ExplicitSplice   = String -> SDoc
text String
"$" SDoc -> SDoc -> SDoc
<> HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
ppr_splice_decl HsSplice (GhcPass p)
e
pprSpliceDecl HsSplice (GhcPass p)
e SpliceExplicitFlag
ImplicitSplice   = HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
ppr_splice_decl HsSplice (GhcPass p)
e

ppr_splice_decl :: (OutputableBndrId p)
                => HsSplice (GhcPass p) -> SDoc
ppr_splice_decl :: forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
ppr_splice_decl (HsUntypedSplice XUntypedSplice (GhcPass p)
_ SpliceDecoration
_ IdP (GhcPass p)
n LHsExpr (GhcPass p)
e) = SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice SDoc
empty IdP (GhcPass p)
n LHsExpr (GhcPass p)
e SDoc
empty
ppr_splice_decl HsSplice (GhcPass p)
e = HsSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
pprSplice HsSplice (GhcPass p)
e

pprSplice :: forall p. (OutputableBndrId p) => HsSplice (GhcPass p) -> SDoc
pprSplice :: forall (p :: Pass).
OutputableBndrId p =>
HsSplice (GhcPass p) -> SDoc
pprSplice (HsTypedSplice XTypedSplice (GhcPass p)
_ SpliceDecoration
DollarSplice IdP (GhcPass p)
n LHsExpr (GhcPass p)
e)
  = SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice (String -> SDoc
text String
"$$") IdP (GhcPass p)
n LHsExpr (GhcPass p)
e SDoc
empty
pprSplice (HsTypedSplice XTypedSplice (GhcPass p)
_ SpliceDecoration
BareSplice IdP (GhcPass p)
_ LHsExpr (GhcPass p)
_ )
  = String -> SDoc
forall a. String -> a
panic String
"Bare typed splice"  -- impossible
pprSplice (HsUntypedSplice XUntypedSplice (GhcPass p)
_ SpliceDecoration
DollarSplice IdP (GhcPass p)
n LHsExpr (GhcPass p)
e)
  = SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice (String -> SDoc
text String
"$")  IdP (GhcPass p)
n LHsExpr (GhcPass p)
e SDoc
empty
pprSplice (HsUntypedSplice XUntypedSplice (GhcPass p)
_ SpliceDecoration
BareSplice IdP (GhcPass p)
n LHsExpr (GhcPass p)
e)
  = SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice SDoc
empty  IdP (GhcPass p)
n LHsExpr (GhcPass p)
e SDoc
empty
pprSplice (HsQuasiQuote XQuasiQuote (GhcPass p)
_ IdP (GhcPass p)
n IdP (GhcPass p)
q SrcSpan
_ FastString
s)      = IdGhcP p -> IdGhcP p -> FastString -> SDoc
forall p. OutputableBndr p => p -> p -> FastString -> SDoc
ppr_quasi IdP (GhcPass p)
IdGhcP p
n IdP (GhcPass p)
IdGhcP p
q FastString
s
pprSplice (HsSpliced XSpliced (GhcPass p)
_ ThModFinalizers
_ HsSplicedThing (GhcPass p)
thing)         = HsSplicedThing (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsSplicedThing (GhcPass p)
thing
pprSplice (XSplice XXSplice (GhcPass p)
x)                   = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
                                            GhcPs -> dataConCantHappen x
                                            GhcRn -> dataConCantHappen x
#endif
                                            GhcPass p
GhcTc -> case XXSplice (GhcPass p)
x of
                                                       HsSplicedT DelayedSplice
_ -> String -> SDoc
text String
"Unevaluated typed splice"

ppr_quasi :: OutputableBndr p => p -> p -> FastString -> SDoc
ppr_quasi :: forall p. OutputableBndr p => p -> p -> FastString -> SDoc
ppr_quasi p
n p
quoter FastString
quote = SDoc -> SDoc
whenPprDebug (SDoc -> SDoc
brackets (p -> SDoc
forall a. Outputable a => a -> SDoc
ppr p
n)) SDoc -> SDoc -> SDoc
<>
                           Char -> SDoc
char Char
'[' SDoc -> SDoc -> SDoc
<> p -> SDoc
forall a. Outputable a => a -> SDoc
ppr p
quoter SDoc -> SDoc -> SDoc
<> SDoc
vbar SDoc -> SDoc -> SDoc
<>
                           FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
quote SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"|]"

ppr_splice :: (OutputableBndrId p)
           => SDoc -> (IdP (GhcPass p)) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice :: forall (p :: Pass).
OutputableBndrId p =>
SDoc -> IdP (GhcPass p) -> LHsExpr (GhcPass p) -> SDoc -> SDoc
ppr_splice SDoc
herald IdP (GhcPass p)
n LHsExpr (GhcPass p)
e SDoc
trail
    = SDoc
herald SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
whenPprDebug (SDoc -> SDoc
brackets (IdGhcP p -> SDoc
forall a. Outputable a => a -> SDoc
ppr IdP (GhcPass p)
IdGhcP p
n)) SDoc -> SDoc -> SDoc
<> GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e SDoc -> SDoc -> SDoc
<> SDoc
trail


type instance XExpBr  GhcPs       = NoExtField
type instance XPatBr  GhcPs       = NoExtField
type instance XDecBrL GhcPs       = NoExtField
type instance XDecBrG GhcPs       = NoExtField
type instance XTypBr  GhcPs       = NoExtField
type instance XVarBr  GhcPs       = NoExtField
type instance XXQuote GhcPs       = DataConCantHappen

type instance XExpBr  GhcRn       = NoExtField
type instance XPatBr  GhcRn       = NoExtField
type instance XDecBrL GhcRn       = NoExtField
type instance XDecBrG GhcRn       = NoExtField
type instance XTypBr  GhcRn       = NoExtField
type instance XVarBr  GhcRn       = NoExtField
type instance XXQuote GhcRn       = DataConCantHappen

-- See Note [The life cycle of a TH quotation]
type instance XExpBr  GhcTc       = DataConCantHappen
type instance XPatBr  GhcTc       = DataConCantHappen
type instance XDecBrL GhcTc       = DataConCantHappen
type instance XDecBrG GhcTc       = DataConCantHappen
type instance XTypBr  GhcTc       = DataConCantHappen
type instance XVarBr  GhcTc       = DataConCantHappen
type instance XXQuote GhcTc       = NoExtField

instance OutputableBndrId p
          => Outputable (HsQuote (GhcPass p)) where
  ppr :: HsQuote (GhcPass p) -> SDoc
ppr = HsQuote (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsQuote (GhcPass p) -> SDoc
pprHsQuote
    where
      pprHsQuote :: forall p. (OutputableBndrId p)
                   => HsQuote (GhcPass p) -> SDoc
      pprHsQuote :: forall (p :: Pass).
OutputableBndrId p =>
HsQuote (GhcPass p) -> SDoc
pprHsQuote (ExpBr XExpBr (GhcPass p)
_ LHsExpr (GhcPass p)
e)   = SDoc -> SDoc -> SDoc
thBrackets SDoc
empty (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e)
      pprHsQuote (PatBr XPatBr (GhcPass p)
_ LPat (GhcPass p)
p)   = SDoc -> SDoc -> SDoc
thBrackets (Char -> SDoc
char Char
'p') (GenLocated SrcSpanAnnA (Pat (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat (GhcPass p)
GenLocated SrcSpanAnnA (Pat (GhcPass p))
p)
      pprHsQuote (DecBrG XDecBrG (GhcPass p)
_ HsGroup (GhcPass p)
gp) = SDoc -> SDoc -> SDoc
thBrackets (Char -> SDoc
char Char
'd') (HsGroup (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsGroup (GhcPass p)
gp)
      pprHsQuote (DecBrL XDecBrL (GhcPass p)
_ [LHsDecl (GhcPass p)]
ds) = SDoc -> SDoc -> SDoc
thBrackets (Char -> SDoc
char Char
'd') ([SDoc] -> SDoc
vcat ((GenLocated SrcSpanAnnA (HsDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (HsDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (HsDecl (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (HsDecl (GhcPass p))]
ds))
      pprHsQuote (TypBr XTypBr (GhcPass p)
_ LHsType (GhcPass p)
t)   = SDoc -> SDoc -> SDoc
thBrackets (Char -> SDoc
char Char
't') (GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
t)
      pprHsQuote (VarBr XVarBr (GhcPass p)
_ Bool
True LIdP (GhcPass p)
n)
        = Char -> SDoc
char Char
'\'' SDoc -> SDoc -> SDoc
<> IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n)
      pprHsQuote (VarBr XVarBr (GhcPass p)
_ Bool
False LIdP (GhcPass p)
n)
        = String -> SDoc
text String
"''" SDoc -> SDoc -> SDoc
<> IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n)
      pprHsQuote (XQuote XXQuote (GhcPass p)
b)  = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ <= 900
          GhcPs -> dataConCantHappen b
          GhcRn -> dataConCantHappen b
#endif
          GhcPass p
GhcTc -> String -> SDoc -> SDoc
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprHsQuote: `HsQuote GhcTc` shouldn't exist" (NoExtField -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXQuote (GhcPass p)
NoExtField
b)
                   -- See Note [The life cycle of a TH quotation]

thBrackets :: SDoc -> SDoc -> SDoc
thBrackets :: SDoc -> SDoc -> SDoc
thBrackets SDoc
pp_kind SDoc
pp_body = Char -> SDoc
char Char
'[' SDoc -> SDoc -> SDoc
<> SDoc
pp_kind SDoc -> SDoc -> SDoc
<> SDoc
vbar SDoc -> SDoc -> SDoc
<+>
                             SDoc
pp_body SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"|]"

thTyBrackets :: SDoc -> SDoc
thTyBrackets :: SDoc -> SDoc
thTyBrackets SDoc
pp_body = String -> SDoc
text String
"[||" SDoc -> SDoc -> SDoc
<+> SDoc
pp_body SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"||]"

instance Outputable PendingRnSplice where
  ppr :: PendingRnSplice -> SDoc
ppr (PendingRnSplice UntypedSpliceFlavour
_ Name
n LHsExpr GhcRn
e) = Name -> LHsExpr GhcRn -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Name -> LHsExpr (GhcPass p) -> SDoc
pprPendingSplice Name
n LHsExpr GhcRn
e

instance Outputable PendingTcSplice where
  ppr :: PendingTcSplice -> SDoc
ppr (PendingTcSplice Name
n LHsExpr GhcTc
e) = Name -> LHsExpr GhcTc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Name -> LHsExpr (GhcPass p) -> SDoc
pprPendingSplice Name
n LHsExpr GhcTc
e

ppr_with_pending_tc_splices :: SDoc -> [PendingTcSplice] -> SDoc
ppr_with_pending_tc_splices :: SDoc -> [PendingTcSplice] -> SDoc
ppr_with_pending_tc_splices SDoc
x [] = SDoc
x
ppr_with_pending_tc_splices SDoc
x [PendingTcSplice]
ps = SDoc
x SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"pending(tc)" SDoc -> SDoc -> SDoc
<+> [PendingTcSplice] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [PendingTcSplice]
ps

{-
************************************************************************
*                                                                      *
\subsection{Enumerations and list comprehensions}
*                                                                      *
************************************************************************
-}

instance OutputableBndrId p
         => Outputable (ArithSeqInfo (GhcPass p)) where
    ppr :: ArithSeqInfo (GhcPass p) -> SDoc
ppr (From LHsExpr (GhcPass p)
e1)             = [SDoc] -> SDoc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
pp_dotdot]
    ppr (FromThen LHsExpr (GhcPass p)
e1 LHsExpr (GhcPass p)
e2)      = [SDoc] -> SDoc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
comma, SDoc
space, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e2, SDoc
pp_dotdot]
    ppr (FromTo LHsExpr (GhcPass p)
e1 LHsExpr (GhcPass p)
e3)        = [SDoc] -> SDoc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
pp_dotdot, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e3]
    ppr (FromThenTo LHsExpr (GhcPass p)
e1 LHsExpr (GhcPass p)
e2 LHsExpr (GhcPass p)
e3)
      = [SDoc] -> SDoc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
comma, SDoc
space, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e2, SDoc
pp_dotdot, GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e3]

pp_dotdot :: SDoc
pp_dotdot :: SDoc
pp_dotdot = String -> SDoc
text String
" .. "

{-
************************************************************************
*                                                                      *
\subsection{HsMatchCtxt}
*                                                                      *
************************************************************************
-}

instance OutputableBndrId p => Outputable (HsMatchContext (GhcPass p)) where
  ppr :: HsMatchContext (GhcPass p) -> SDoc
ppr m :: HsMatchContext (GhcPass p)
m@(FunRhs{})            = String -> SDoc
text String
"FunRhs" SDoc -> SDoc -> SDoc
<+> GenLocated (Anno (IdGhcP (NoGhcTcPass p))) (IdGhcP (NoGhcTcPass p))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsMatchContext (GhcPass p) -> LIdP (NoGhcTc (GhcPass p))
forall p. HsMatchContext p -> LIdP (NoGhcTc p)
mc_fun HsMatchContext (GhcPass p)
m) SDoc -> SDoc -> SDoc
<+> LexicalFixity -> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsMatchContext (GhcPass p) -> LexicalFixity
forall p. HsMatchContext p -> LexicalFixity
mc_fixity HsMatchContext (GhcPass p)
m)
  ppr HsMatchContext (GhcPass p)
LambdaExpr              = String -> SDoc
text String
"LambdaExpr"
  ppr HsMatchContext (GhcPass p)
CaseAlt                 = String -> SDoc
text String
"CaseAlt"
  ppr (LamCaseAlt LamCaseVariant
lc_variant) = String -> SDoc
text String
"LamCaseAlt" SDoc -> SDoc -> SDoc
<+> LamCaseVariant -> SDoc
forall a. Outputable a => a -> SDoc
ppr LamCaseVariant
lc_variant
  ppr HsMatchContext (GhcPass p)
IfAlt                   = String -> SDoc
text String
"IfAlt"
  ppr (ArrowMatchCtxt HsArrowMatchContext
c)      = String -> SDoc
text String
"ArrowMatchCtxt" SDoc -> SDoc -> SDoc
<+> HsArrowMatchContext -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsArrowMatchContext
c
  ppr HsMatchContext (GhcPass p)
PatBindRhs              = String -> SDoc
text String
"PatBindRhs"
  ppr HsMatchContext (GhcPass p)
PatBindGuards           = String -> SDoc
text String
"PatBindGuards"
  ppr HsMatchContext (GhcPass p)
RecUpd                  = String -> SDoc
text String
"RecUpd"
  ppr (StmtCtxt HsStmtContext (GhcPass p)
_)            = String -> SDoc
text String
"StmtCtxt _"
  ppr HsMatchContext (GhcPass p)
ThPatSplice             = String -> SDoc
text String
"ThPatSplice"
  ppr HsMatchContext (GhcPass p)
ThPatQuote              = String -> SDoc
text String
"ThPatQuote"
  ppr HsMatchContext (GhcPass p)
PatSyn                  = String -> SDoc
text String
"PatSyn"

instance Outputable LamCaseVariant where
  ppr :: LamCaseVariant -> SDoc
ppr = String -> SDoc
text (String -> SDoc)
-> (LamCaseVariant -> String) -> LamCaseVariant -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    LamCaseVariant
LamCase  -> String
"LamCase"
    LamCaseVariant
LamCases -> String
"LamCases"

instance Outputable HsArrowMatchContext where
  ppr :: HsArrowMatchContext -> SDoc
ppr HsArrowMatchContext
ProcExpr                     = String -> SDoc
text String
"ProcExpr"
  ppr HsArrowMatchContext
ArrowCaseAlt                 = String -> SDoc
text String
"ArrowCaseAlt"
  ppr (ArrowLamCaseAlt LamCaseVariant
lc_variant) = SDoc -> SDoc
parens (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
text String
"ArrowLamCaseAlt" SDoc -> SDoc -> SDoc
<+> LamCaseVariant -> SDoc
forall a. Outputable a => a -> SDoc
ppr LamCaseVariant
lc_variant
  ppr HsArrowMatchContext
KappaExpr                    = String -> SDoc
text String
"KappaExpr"

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

instance OutputableBndrId p
      => Outputable (HsStmtContext (GhcPass p)) where
    ppr :: HsStmtContext (GhcPass p) -> SDoc
ppr = HsStmtContext (GhcPass p) -> SDoc
forall p.
(Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) =>
HsStmtContext p -> SDoc
pprStmtContext

-- Used to generate the string for a *runtime* error message
matchContextErrString :: OutputableBndrId p
                      => HsMatchContext (GhcPass p) -> SDoc
matchContextErrString :: forall (p :: Pass).
OutputableBndrId p =>
HsMatchContext (GhcPass p) -> SDoc
matchContextErrString (FunRhs{mc_fun :: forall p. HsMatchContext p -> LIdP (NoGhcTc p)
mc_fun=L Anno (IdGhcP (NoGhcTcPass p))
_ IdGhcP (NoGhcTcPass p)
fun})      = String -> SDoc
text String
"function" SDoc -> SDoc -> SDoc
<+> IdGhcP (NoGhcTcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr IdGhcP (NoGhcTcPass p)
fun
matchContextErrString HsMatchContext (GhcPass p)
CaseAlt                       = String -> SDoc
text String
"case"
matchContextErrString (LamCaseAlt LamCaseVariant
lc_variant)       = LamCaseVariant -> SDoc
lamCaseKeyword LamCaseVariant
lc_variant
matchContextErrString HsMatchContext (GhcPass p)
IfAlt                         = String -> SDoc
text String
"multi-way if"
matchContextErrString HsMatchContext (GhcPass p)
PatBindRhs                    = String -> SDoc
text String
"pattern binding"
matchContextErrString HsMatchContext (GhcPass p)
PatBindGuards                 = String -> SDoc
text String
"pattern binding guards"
matchContextErrString HsMatchContext (GhcPass p)
RecUpd                        = String -> SDoc
text String
"record update"
matchContextErrString HsMatchContext (GhcPass p)
LambdaExpr                    = String -> SDoc
text String
"lambda"
matchContextErrString (ArrowMatchCtxt HsArrowMatchContext
c)            = HsArrowMatchContext -> SDoc
matchArrowContextErrString HsArrowMatchContext
c
matchContextErrString HsMatchContext (GhcPass p)
ThPatSplice                   = String -> SDoc
forall a. String -> a
panic String
"matchContextErrString"  -- Not used at runtime
matchContextErrString HsMatchContext (GhcPass p)
ThPatQuote                    = String -> SDoc
forall a. String -> a
panic String
"matchContextErrString"  -- Not used at runtime
matchContextErrString HsMatchContext (GhcPass p)
PatSyn                        = String -> SDoc
forall a. String -> a
panic String
"matchContextErrString"  -- Not used at runtime
matchContextErrString (StmtCtxt (ParStmtCtxt HsStmtContext (GhcPass p)
c))    = HsMatchContext (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsMatchContext (GhcPass p) -> SDoc
matchContextErrString (HsStmtContext (GhcPass p) -> HsMatchContext (GhcPass p)
forall p. HsStmtContext p -> HsMatchContext p
StmtCtxt HsStmtContext (GhcPass p)
c)
matchContextErrString (StmtCtxt (TransStmtCtxt HsStmtContext (GhcPass p)
c))  = HsMatchContext (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsMatchContext (GhcPass p) -> SDoc
matchContextErrString (HsStmtContext (GhcPass p) -> HsMatchContext (GhcPass p)
forall p. HsStmtContext p -> HsMatchContext p
StmtCtxt HsStmtContext (GhcPass p)
c)
matchContextErrString (StmtCtxt (PatGuard HsMatchContext (GhcPass p)
_))       = String -> SDoc
text String
"pattern guard"
matchContextErrString (StmtCtxt (HsStmtContext (GhcPass p)
ArrowExpr))        = String -> SDoc
text String
"'do' block"
matchContextErrString (StmtCtxt (HsDoStmt HsDoFlavour
flavour)) = HsDoFlavour -> SDoc
matchDoContextErrString HsDoFlavour
flavour

matchArrowContextErrString :: HsArrowMatchContext -> SDoc
matchArrowContextErrString :: HsArrowMatchContext -> SDoc
matchArrowContextErrString HsArrowMatchContext
ProcExpr                     = String -> SDoc
text String
"proc"
matchArrowContextErrString HsArrowMatchContext
ArrowCaseAlt                 = String -> SDoc
text String
"case"
matchArrowContextErrString (ArrowLamCaseAlt LamCaseVariant
lc_variant) = LamCaseVariant -> SDoc
lamCaseKeyword LamCaseVariant
lc_variant
matchArrowContextErrString HsArrowMatchContext
KappaExpr                    = String -> SDoc
text String
"kappa"

matchDoContextErrString :: HsDoFlavour -> SDoc
matchDoContextErrString :: HsDoFlavour -> SDoc
matchDoContextErrString HsDoFlavour
GhciStmtCtxt = String -> SDoc
text String
"interactive GHCi command"
matchDoContextErrString (DoExpr Maybe ModuleName
m)   = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
text String
"'do' block")
matchDoContextErrString (MDoExpr Maybe ModuleName
m)  = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
text String
"'mdo' block")
matchDoContextErrString HsDoFlavour
ListComp     = String -> SDoc
text String
"list comprehension"
matchDoContextErrString HsDoFlavour
MonadComp    = String -> SDoc
text String
"monad comprehension"

pprMatchInCtxt :: (OutputableBndrId idR, Outputable body)
               => Match (GhcPass idR) body -> SDoc
pprMatchInCtxt :: forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatchInCtxt Match (GhcPass idR) body
match  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"In" SDoc -> SDoc -> SDoc
<+> HsMatchContext (GhcPass idR) -> SDoc
forall p.
(Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) =>
HsMatchContext p -> SDoc
pprMatchContext (Match (GhcPass idR) body -> HsMatchContext (GhcPass idR)
forall p body. Match p body -> HsMatchContext p
m_ctxt Match (GhcPass idR) body
match)
                                        SDoc -> SDoc -> SDoc
<> SDoc
colon)
                             Int
4 (Match (GhcPass idR) body -> SDoc
forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatch Match (GhcPass idR) body
match)

pprStmtInCtxt :: (OutputableBndrId idL,
                  OutputableBndrId idR,
                  OutputableBndrId ctx,
                  Outputable body,
                 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA)
              => HsStmtContext (GhcPass ctx)
              -> StmtLR (GhcPass idL) (GhcPass idR) body
              -> SDoc
pprStmtInCtxt :: forall (idL :: Pass) (idR :: Pass) (ctx :: Pass) body.
(OutputableBndrId idL, OutputableBndrId idR, OutputableBndrId ctx,
 Outputable body,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA) =>
HsStmtContext (GhcPass ctx)
-> StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
pprStmtInCtxt HsStmtContext (GhcPass ctx)
ctxt (LastStmt XLastStmt (GhcPass idL) (GhcPass idR) body
_ body
e Maybe Bool
_ SyntaxExpr (GhcPass idR)
_)
  | HsStmtContext (GhcPass ctx) -> Bool
forall id. HsStmtContext id -> Bool
isComprehensionContext HsStmtContext (GhcPass ctx)
ctxt      -- For [ e | .. ], do not mutter about "stmts"
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"In the expression:") Int
2 (body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
e)

pprStmtInCtxt HsStmtContext (GhcPass ctx)
ctxt StmtLR (GhcPass idL) (GhcPass idR) body
stmt
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"In a stmt of" SDoc -> SDoc -> SDoc
<+> HsStmtContext (GhcPass ctx) -> SDoc
forall p.
(Outputable (IdP (NoGhcTc p)), UnXRec (NoGhcTc p)) =>
HsStmtContext p -> SDoc
pprAStmtContext HsStmtContext (GhcPass ctx)
ctxt SDoc -> SDoc -> SDoc
<> SDoc
colon)
       Int
2 (StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
forall {idL :: Pass} {idR :: Pass} {body}.
(Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
 OutputableBndr (IdGhcP idR), OutputableBndr (IdGhcP idL),
 OutputableBndr (IdGhcP (NoGhcTcPass idR)),
 OutputableBndr (IdGhcP (NoGhcTcPass idL)), IsPass idR, IsPass idL,
 Outputable body,
 Outputable (GenLocated (Anno (IdGhcP idR)) (IdGhcP idR)),
 Outputable (GenLocated (Anno (IdGhcP idL)) (IdGhcP idL)),
 Outputable
   (GenLocated
      (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR))),
 Outputable
   (GenLocated
      (Anno (IdGhcP (NoGhcTcPass idL))) (IdGhcP (NoGhcTcPass idL)))) =>
StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
ppr_stmt StmtLR (GhcPass idL) (GhcPass idR) body
stmt)
  where
    -- For Group and Transform Stmts, don't print the nested stmts!
    ppr_stmt :: StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
ppr_stmt (TransStmt { trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_by = Maybe (LHsExpr (GhcPass idR))
by, trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_using = LHsExpr (GhcPass idR)
using
                        , trS_form :: forall idL idR body. StmtLR idL idR body -> TransForm
trS_form = TransForm
form }) = Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))
-> TransForm
-> SDoc
forall body.
Outputable body =>
Maybe body -> body -> TransForm -> SDoc
pprTransStmt Maybe (LHsExpr (GhcPass idR))
Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass idR)))
by LHsExpr (GhcPass idR)
GenLocated SrcSpanAnnA (HsExpr (GhcPass idR))
using TransForm
form
    ppr_stmt StmtLR (GhcPass idL) (GhcPass idR) body
stmt = StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
forall (pl :: Pass) (pr :: Pass) body.
(OutputableBndrId pl, OutputableBndrId pr,
 Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA,
 Outputable body) =>
StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
pprStmt StmtLR (GhcPass idL) (GhcPass idR) body
stmt

{-
************************************************************************
*                                                                      *
\subsection{Anno instances}
*                                                                      *
************************************************************************
-}

type instance Anno (HsExpr (GhcPass p)) = SrcSpanAnnA
type instance Anno [LocatedA ((StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsExpr (GhcPass pr)))))] = SrcSpanAnnL
type instance Anno [LocatedA ((StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd (GhcPass pr)))))] = SrcSpanAnnL

type instance Anno (HsCmd (GhcPass p)) = SrcSpanAnnA

type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd (GhcPass pr))))]
  = SrcSpanAnnL
type instance Anno (HsCmdTop (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno [LocatedA (Match (GhcPass p) (LocatedA (HsExpr (GhcPass p))))] = SrcSpanAnnL
type instance Anno [LocatedA (Match (GhcPass p) (LocatedA (HsCmd  (GhcPass p))))] = SrcSpanAnnL
type instance Anno (Match (GhcPass p) (LocatedA (HsExpr (GhcPass p)))) = SrcSpanAnnA
type instance Anno (Match (GhcPass p) (LocatedA (HsCmd  (GhcPass p)))) = SrcSpanAnnA
type instance Anno (GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p)))) = SrcAnn NoEpAnns
type instance Anno (GRHS (GhcPass p) (LocatedA (HsCmd  (GhcPass p)))) = SrcAnn NoEpAnns
type instance Anno (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsExpr (GhcPass pr)))) = SrcSpanAnnA
type instance Anno (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd  (GhcPass pr)))) = SrcSpanAnnA

type instance Anno (HsSplice (GhcPass p)) = SrcSpanAnnA

type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsExpr (GhcPass pr))))] = SrcSpanAnnL
type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd  (GhcPass pr))))] = SrcSpanAnnL

type instance Anno (FieldLabelStrings (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno (FieldLabelString) = SrcSpanAnnN
type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns

instance (Anno a ~ SrcSpanAnn' (EpAnn an))
   => WrapXRec (GhcPass p) a where
  wrapXRec :: a -> XRec (GhcPass p) a
wrapXRec = a -> XRec (GhcPass p) a
a -> LocatedAn an a
forall a an. a -> LocatedAn an a
noLocA