{-# 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-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.Basic() -- import instances
import GHC.Hs.Decls() -- import instances
import GHC.Hs.Pat
import GHC.Hs.Lit
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Basic (FieldLabelString(..))
import GHC.Hs.Extension
import GHC.Hs.Type
import GHC.Hs.Binds
import GHC.Parser.Annotation

-- others:
import GHC.Tc.Types.Evidence
import GHC.Types.Id.Info ( RecSelParent )
import GHC.Types.Name
import GHC.Types.Name.Reader
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.Types.Unique.Set (UniqSet)
import GHC.Core.ConLike ( conLikeName, ConLike )
import GHC.Unit.Module (ModuleName)
import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
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.LclEnv (TcLclEnv)

import GHCi.RemoteTypes ( ForeignRef )
import qualified GHC.Internal.TH.Syntax as TH (Q)

-- 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.NonEmpty (NonEmpty)
import Data.Void (Void)

{- *********************************************************************
*                                                                      *
                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)
NoExtField
noExtField (XHsString (GhcPass p) -> FastString -> HsLit (GhcPass p)
forall x. XHsString x -> FastString -> HsLit x
HsString (FastString -> SourceText
SourceText (FastString -> SourceText) -> FastString -> SourceText
forall a b. (a -> b) -> a -> b
$ String -> FastString
fsLit 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

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
forall doc. IsLine doc => String -> doc
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
forall doc. IsOutput doc => (Bool -> doc) -> doc
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
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => String -> doc
text String
"<no syntax expr>"

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

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

data HsBracketTc = HsBracketTc
  { HsBracketTc -> HsQuote GhcRn
hsb_quote   :: HsQuote GhcRn        -- See Note [The life cycle of a TH quotation]
  , HsBracketTc -> Type
hsb_ty      :: Type
  , HsBracketTc -> Maybe QuoteWrapper
hsb_wrap    :: Maybe QuoteWrapper   -- The wrapper to apply type and dictionary argument to the quote.
  , HsBracketTc -> [PendingTcSplice]
hsb_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 = (BracketAnn (EpToken "[||") (EpToken "[e||"), EpToken "||]")
type instance XTypedBracket GhcRn = NoExtField
type instance XTypedBracket GhcTc = HsBracketTc
type instance XUntypedBracket GhcPs = NoExtField
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

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

instance (NoAnn n, NoAnn h) => NoAnn (BracketAnn n h) where
  noAnn :: BracketAnn n h
noAnn = n -> BracketAnn n h
forall noE hasE. noE -> BracketAnn noE hasE
BracketNoE n
forall a. NoAnn a => a
noAnn

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

-- API Annotations types

data EpAnnHsCase = EpAnnHsCase
      { EpAnnHsCase -> EpToken "case"
hsCaseAnnCase :: EpToken "case"
      , EpAnnHsCase -> EpToken "of"
hsCaseAnnOf   :: EpToken "of"
      } 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

instance NoAnn EpAnnHsCase where
  noAnn :: EpAnnHsCase
noAnn = EpToken "case" -> EpToken "of" -> EpAnnHsCase
EpAnnHsCase EpToken "case"
forall a. NoAnn a => a
noAnn EpToken "of"
forall a. NoAnn a => a
noAnn

data EpAnnLam = EpAnnLam
      { EpAnnLam -> EpToken "\\"
epl_lambda :: EpToken "\\"      -- ^ Location of '\' keyword
      , EpAnnLam -> Maybe EpaLocation
epl_case   :: Maybe EpaLocation -- ^ Location of 'case' or
                                        -- 'cases' keyword, depending
                                        -- on related 'HsLamVariant'.
      } deriving Typeable EpAnnLam
Typeable EpAnnLam =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> EpAnnLam -> c EpAnnLam)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EpAnnLam)
-> (EpAnnLam -> Constr)
-> (EpAnnLam -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EpAnnLam))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpAnnLam))
-> ((forall b. Data b => b -> b) -> EpAnnLam -> EpAnnLam)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r)
-> (forall u. (forall d. Data d => d -> u) -> EpAnnLam -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> EpAnnLam -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam)
-> Data EpAnnLam
EpAnnLam -> Constr
EpAnnLam -> DataType
(forall b. Data b => b -> b) -> EpAnnLam -> EpAnnLam
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) -> EpAnnLam -> u
forall u. (forall d. Data d => d -> u) -> EpAnnLam -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnLam
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnLam -> c EpAnnLam
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnLam)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpAnnLam)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnLam -> c EpAnnLam
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnLam -> c EpAnnLam
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnLam
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnLam
$ctoConstr :: EpAnnLam -> Constr
toConstr :: EpAnnLam -> Constr
$cdataTypeOf :: EpAnnLam -> DataType
dataTypeOf :: EpAnnLam -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnLam)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnLam)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpAnnLam)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EpAnnLam)
$cgmapT :: (forall b. Data b => b -> b) -> EpAnnLam -> EpAnnLam
gmapT :: (forall b. Data b => b -> b) -> EpAnnLam -> EpAnnLam
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnLam -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnLam -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnLam -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpAnnLam -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EpAnnLam -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EpAnnLam -> m EpAnnLam
Data

instance NoAnn EpAnnLam where
  noAnn :: EpAnnLam
noAnn = EpToken "\\" -> Maybe EpaLocation -> EpAnnLam
EpAnnLam EpToken "\\"
forall a. NoAnn a => a
noAnn Maybe EpaLocation
forall a. NoAnn a => a
noAnn

data EpAnnUnboundVar = EpAnnUnboundVar
     { EpAnnUnboundVar -> (EpToken "`", EpToken "`")
hsUnboundBackquotes :: (EpToken "`", EpToken "`")
     , EpAnnUnboundVar -> EpToken "_"
hsUnboundHole       :: EpToken "_"
     } 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

-- 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

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

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

type instance XVar           (GhcPass _) = NoExtField

type instance XUnboundVar    GhcPs = Maybe 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 = NoExtField
type instance XIPVar         GhcRn = NoExtField
type instance XIPVar         GhcTc = DataConCantHappen
type instance XOverLitE      (GhcPass _) = NoExtField
type instance XLitE          (GhcPass _) = NoExtField
type instance XLam           (GhcPass _) = EpAnnLam
type instance XApp           (GhcPass _) = NoExtField

type instance XAppTypeE      GhcPs = EpToken "@"
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 = NoExtField
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 = NoExtField
type instance XSectionR      GhcPs = NoExtField
type instance XSectionL      GhcRn = NoExtField
type instance XSectionR      GhcRn = NoExtField
type instance XSectionL      GhcTc = DataConCantHappen
type instance XSectionR      GhcTc = DataConCantHappen


type instance XNegApp        GhcPs = EpToken "-"
type instance XNegApp        GhcRn = NoExtField
type instance XNegApp        GhcTc = NoExtField

type instance XPar           GhcPs = (EpToken "(", EpToken ")")
type instance XPar           GhcRn = NoExtField
type instance XPar           GhcTc = NoExtField

type instance XExplicitTuple GhcPs = (EpaLocation, EpaLocation)
type instance XExplicitTuple GhcRn = NoExtField
type instance XExplicitTuple GhcTc = NoExtField

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

type instance XCase          GhcPs = EpAnnHsCase
type instance XCase          GhcRn = HsMatchContextRn
type instance XCase          GhcTc = HsMatchContextRn

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

type instance XMultiIf       GhcPs = (EpToken "if", EpToken "{", EpToken "}")
type instance XMultiIf       GhcRn = NoExtField
type instance XMultiIf       GhcTc = Type

type instance XLet           GhcPs = (EpToken "let", EpToken "in")
type instance XLet           GhcRn = NoExtField
type instance XLet           GhcTc = NoExtField

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

type instance XExplicitList  GhcPs = 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 = (Maybe (EpToken "{"), Maybe (EpToken "}"))
type instance XRecordCon     GhcRn = NoExtField
type instance XRecordCon     GhcTc = PostTcExpr   -- Instantiated constructor function

type instance XRecordUpd     GhcPs = (Maybe (EpToken "{"), Maybe (EpToken "}"))
type instance XRecordUpd     GhcRn = NoExtField
type instance XRecordUpd     GhcTc = DataConCantHappen
  -- We desugar record updates in the typechecker.
  -- See [Handling overloaded and rebindable constructs],
  -- and [Record Updates] in GHC.Tc.Gen.Expr.

-- | Information about the parent of a record update:
--
--  - the parent type constructor or pattern synonym,
--  - the relevant con-likes,
--  - the field labels.
data family HsRecUpdParent x

data instance HsRecUpdParent GhcPs
data instance HsRecUpdParent GhcRn
  = RnRecUpdParent
  { HsRecUpdParent GhcRn -> NonEmpty FieldGlobalRdrElt
rnRecUpdLabels :: NonEmpty FieldGlobalRdrElt
  , HsRecUpdParent GhcRn -> UniqSet ConLikeName
rnRecUpdCons   :: UniqSet ConLikeName }
data instance HsRecUpdParent GhcTc
  = TcRecUpdParent
  { HsRecUpdParent GhcTc -> RecSelParent
tcRecUpdParent :: RecSelParent
  , HsRecUpdParent GhcTc -> NonEmpty FieldGlobalRdrElt
tcRecUpdLabels :: NonEmpty FieldGlobalRdrElt
  , HsRecUpdParent GhcTc -> UniqSet ConLike
tcRecUpdCons   :: UniqSet ConLike }

type instance XLHsRecUpdLabels GhcPs = NoExtField
type instance XLHsRecUpdLabels GhcRn = NonEmpty (HsRecUpdParent GhcRn)
                                      -- Possible parents for the record update.
type instance XLHsRecUpdLabels GhcTc = DataConCantHappen

type instance XLHsOLRecUpdLabels p = NoExtField

type instance XGetField     GhcPs = NoExtField
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 = 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 = TokDcolon
type instance XExprWithTySig GhcRn = NoExtField
type instance XExprWithTySig GhcTc = NoExtField

type instance XArithSeq      GhcPs = AnnArithSeq
type instance XArithSeq      GhcRn = NoExtField
type instance XArithSeq      GhcTc = PostTcExpr

type instance XProc          (GhcPass _) = (EpToken "proc", TokRarrow)

type instance XStatic        GhcPs = EpToken "static"
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 XEmbTy         GhcPs = EpToken "type"
type instance XEmbTy         GhcRn = NoExtField
type instance XEmbTy         GhcTc = DataConCantHappen
  -- A free-standing HsEmbTy is an error.
  -- Valid usages are immediately desugared into Type.

type instance XForAll        GhcPs = NoExtField
type instance XForAll        GhcRn = NoExtField
type instance XForAll        GhcTc = DataConCantHappen

type instance XQual          GhcPs = NoExtField
type instance XQual          GhcRn = NoExtField
type instance XQual          GhcTc = DataConCantHappen

type instance XFunArr        GhcPs = NoExtField
type instance XFunArr        GhcRn = NoExtField
type instance XFunArr        GhcTc = DataConCantHappen

type instance XPragE         (GhcPass _) = NoExtField

type instance XFunRhs  = AnnFunRhs

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

arrowToHsExpr :: HsArrowOf (LocatedA (HsExpr GhcRn)) GhcRn -> LocatedA (HsExpr GhcRn)
arrowToHsExpr :: HsArrowOf (LocatedA (HsExpr GhcRn)) GhcRn
-> LocatedA (HsExpr GhcRn)
arrowToHsExpr = (GenLocated SrcSpanAnnN Name -> HsExpr GhcRn)
-> HsArrowOf (LocatedA (HsExpr GhcRn)) GhcRn
-> LocatedA (HsExpr GhcRn)
forall (t :: * -> *).
(GenLocated SrcSpanAnnN Name -> t GhcRn)
-> HsArrowOf (LocatedA (t GhcRn)) GhcRn -> LocatedA (t GhcRn)
expandHsArrow (XVar GhcRn -> LIdP GhcRn -> HsExpr GhcRn
forall p. XVar p -> LIdP p -> HsExpr p
HsVar XVar GhcRn
NoExtField
noExtField)

data AnnExplicitSum
  = AnnExplicitSum {
      AnnExplicitSum -> EpaLocation
aesOpen       :: EpaLocation,
      AnnExplicitSum -> [EpToken "|"]
aesBarsBefore :: [EpToken "|"],
      AnnExplicitSum -> [EpToken "|"]
aesBarsAfter  :: [EpToken "|"],
      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

instance NoAnn AnnExplicitSum where
  noAnn :: AnnExplicitSum
noAnn = EpaLocation
-> [EpToken "|"] -> [EpToken "|"] -> EpaLocation -> AnnExplicitSum
AnnExplicitSum EpaLocation
forall a. NoAnn a => a
noAnn [EpToken "|"]
forall a. NoAnn a => a
noAnn [EpToken "|"]
forall a. NoAnn a => a
noAnn EpaLocation
forall a. NoAnn a => a
noAnn

data AnnFieldLabel
  = AnnFieldLabel {
      AnnFieldLabel -> Maybe (EpToken ".")
afDot :: Maybe (EpToken ".")
      } 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

instance NoAnn AnnFieldLabel where
  noAnn :: AnnFieldLabel
noAnn = Maybe (EpToken ".") -> AnnFieldLabel
AnnFieldLabel Maybe (EpToken ".")
forall a. Maybe a
Nothing

data AnnProjection
  = AnnProjection {
      AnnProjection -> EpToken "("
apOpen  :: EpToken "(",
      AnnProjection -> EpToken ")"
apClose :: EpToken ")"
      } 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

instance NoAnn AnnProjection where
  noAnn :: AnnProjection
noAnn = EpToken "(" -> EpToken ")" -> AnnProjection
AnnProjection EpToken "("
forall a. NoAnn a => a
noAnn EpToken ")"
forall a. NoAnn a => a
noAnn

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

instance NoAnn AnnArithSeq where
  noAnn :: AnnArithSeq
noAnn = EpToken "["
-> Maybe (EpToken ",")
-> EpToken ".."
-> EpToken "]"
-> AnnArithSeq
AnnArithSeq EpToken "["
forall a. NoAnn a => a
noAnn Maybe (EpToken ",")
forall a. NoAnn a => a
noAnn EpToken ".."
forall a. NoAnn a => a
noAnn EpToken "]"
forall a. NoAnn a => a
noAnn

data AnnsIf
  = AnnsIf {
      AnnsIf -> EpToken "if"
aiIf       :: EpToken "if",
      AnnsIf -> EpToken "then"
aiThen     :: EpToken "then",
      AnnsIf -> EpToken "else"
aiElse     :: EpToken "else",
      AnnsIf -> Maybe (EpToken ";")
aiThenSemi :: Maybe (EpToken ";"),
      AnnsIf -> Maybe (EpToken ";")
aiElseSemi :: Maybe (EpToken ";")
      } 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

instance NoAnn AnnsIf where
  noAnn :: AnnsIf
noAnn = EpToken "if"
-> EpToken "then"
-> EpToken "else"
-> Maybe (EpToken ";")
-> Maybe (EpToken ";")
-> AnnsIf
AnnsIf EpToken "if"
forall a. NoAnn a => a
noAnn EpToken "then"
forall a. NoAnn a => a
noAnn EpToken "else"
forall a. NoAnn a => a
noAnn Maybe (EpToken ";")
forall a. Maybe a
Nothing Maybe (EpToken ";")
forall a. Maybe a
Nothing

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

instance NoAnn AnnFunRhs where
  noAnn :: AnnFunRhs
noAnn = EpToken "!" -> [EpToken "("] -> [EpToken ")"] -> AnnFunRhs
AnnFunRhs EpToken "!"
forall a. NoAnn a => a
noAnn [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn

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

type instance XSCC           (GhcPass _) = (AnnPragma, SourceText)
type instance XXPragE        (GhcPass _) = DataConCantHappen

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

type instance XPresent         (GhcPass _) = NoExtField

type instance XMissing         GhcPs = EpAnn Bool -- True for empty last comma
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

tupArgPresent_maybe :: HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p))
tupArgPresent_maybe :: forall (p :: Pass).
HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p))
tupArgPresent_maybe (Present XPresent (GhcPass p)
_ LHsExpr (GhcPass p)
e) = GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
-> Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
forall a. a -> Maybe a
Just LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e
tupArgPresent_maybe (Missing {})  = Maybe (LHsExpr (GhcPass p))
Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
forall a. Maybe a
Nothing

tupArgsPresent_maybe :: [HsTupArg (GhcPass p)] -> Maybe [LHsExpr (GhcPass p)]
tupArgsPresent_maybe :: forall (p :: Pass).
[HsTupArg (GhcPass p)] -> Maybe [LHsExpr (GhcPass p)]
tupArgsPresent_maybe = (HsTupArg (GhcPass p)
 -> Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> [HsTupArg (GhcPass p)]
-> Maybe [GenLocated SrcSpanAnnA (HsExpr (GhcPass p))]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HsTupArg (GhcPass p)
-> Maybe (XRec (GhcPass p) (HsExpr (GhcPass p)))
HsTupArg (GhcPass p)
-> Maybe (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
forall (p :: Pass).
HsTupArg (GhcPass p) -> Maybe (LHsExpr (GhcPass p))
tupArgPresent_maybe


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

type instance XXExpr GhcPs = DataConCantHappen
type instance XXExpr GhcRn = XXExprGhcRn
type instance XXExpr GhcTc = XXExprGhcTc
-- XXExprGhcRn: see Note [Rebindable syntax and XXExprGhcRn] below


{- *********************************************************************
*                                                                      *
              Generating code for ExpandedThingRn
      See Note [Handling overloaded and rebindable constructs]
*                                                                      *
********************************************************************* -}

-- | The different source constructs that we use to instantiate the "original" field
--   in an `XXExprGhcRn original expansion`
data HsThingRn = OrigExpr (HsExpr GhcRn)
               | OrigStmt (ExprLStmt GhcRn)
               | OrigPat  (LPat GhcRn)

isHsThingRnExpr, isHsThingRnStmt, isHsThingRnPat :: HsThingRn -> Bool
isHsThingRnExpr :: HsThingRn -> Bool
isHsThingRnExpr (OrigExpr{}) = Bool
True
isHsThingRnExpr HsThingRn
_ = Bool
False

isHsThingRnStmt :: HsThingRn -> Bool
isHsThingRnStmt (OrigStmt{}) = Bool
True
isHsThingRnStmt HsThingRn
_ = Bool
False

isHsThingRnPat :: HsThingRn -> Bool
isHsThingRnPat (OrigPat{}) = Bool
True
isHsThingRnPat HsThingRn
_ = Bool
False

data XXExprGhcRn
  = ExpandedThingRn { XXExprGhcRn -> HsThingRn
xrn_orig     :: HsThingRn       -- The original source thing
                    , XXExprGhcRn -> HsExpr GhcRn
xrn_expanded :: HsExpr GhcRn }  -- The compiler generated expanded thing

  | PopErrCtxt                                     -- A hint for typechecker to pop
    {-# UNPACK #-} !(LHsExpr GhcRn)                -- the top of the error context stack
                                                   -- Does not presist post renaming phase
                                                   -- See Part 3. of Note [Expanding HsDo with XXExprGhcRn]
                                                   -- in `GHC.Tc.Gen.Do`
  | HsRecSelRn  (FieldOcc GhcRn)   -- ^ Variable pointing to record selector
                           -- See Note [Non-overloaded record field selectors] and
                           -- Note [Record selectors in the AST]



-- | Wrap a located expression with a `PopErrCtxt`
mkPopErrCtxtExpr :: LHsExpr GhcRn -> HsExpr GhcRn
mkPopErrCtxtExpr :: LHsExpr GhcRn -> HsExpr GhcRn
mkPopErrCtxtExpr LHsExpr GhcRn
a = XXExpr GhcRn -> HsExpr GhcRn
forall p. XXExpr p -> HsExpr p
XExpr (LHsExpr GhcRn -> XXExprGhcRn
PopErrCtxt LHsExpr GhcRn
a)

-- | Wrap a located expression with a PopSrcExpr with an appropriate location
mkPopErrCtxtExprAt :: SrcSpanAnnA ->  LHsExpr GhcRn -> LHsExpr GhcRn
mkPopErrCtxtExprAt :: SrcSpanAnnA -> LHsExpr GhcRn -> LHsExpr GhcRn
mkPopErrCtxtExprAt SrcSpanAnnA
loc LHsExpr GhcRn
a = SrcSpanAnnA -> HsExpr GhcRn -> LocatedA (HsExpr GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (HsExpr GhcRn -> LocatedA (HsExpr GhcRn))
-> HsExpr GhcRn -> LocatedA (HsExpr GhcRn)
forall a b. (a -> b) -> a -> b
$ LHsExpr GhcRn -> HsExpr GhcRn
mkPopErrCtxtExpr LHsExpr GhcRn
a

-- | Build an expression using the extension constructor `XExpr`,
--   and the two components of the expansion: original expression and
--   expanded expressions.
mkExpandedExpr
  :: HsExpr GhcRn         -- ^ source expression
  -> HsExpr GhcRn         -- ^ expanded expression
  -> HsExpr GhcRn         -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedExpr :: HsExpr GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
mkExpandedExpr HsExpr GhcRn
oExpr HsExpr GhcRn
eExpr = XXExpr GhcRn -> HsExpr GhcRn
forall p. XXExpr p -> HsExpr p
XExpr (HsThingRn -> HsExpr GhcRn -> XXExprGhcRn
ExpandedThingRn (HsExpr GhcRn -> HsThingRn
OrigExpr HsExpr GhcRn
oExpr) HsExpr GhcRn
eExpr)

-- | Build an expression using the extension constructor `XExpr`,
--   and the two components of the expansion: original do stmt and
--   expanded expression
mkExpandedStmt
  :: ExprLStmt GhcRn      -- ^ source statement
  -> HsExpr GhcRn         -- ^ expanded expression
  -> HsExpr GhcRn         -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedStmt :: ExprLStmt GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
mkExpandedStmt ExprLStmt GhcRn
oStmt HsExpr GhcRn
eExpr = XXExpr GhcRn -> HsExpr GhcRn
forall p. XXExpr p -> HsExpr p
XExpr (HsThingRn -> HsExpr GhcRn -> XXExprGhcRn
ExpandedThingRn (ExprLStmt GhcRn -> HsThingRn
OrigStmt ExprLStmt GhcRn
oStmt) HsExpr GhcRn
eExpr)

mkExpandedPatRn
  :: LPat   GhcRn      -- ^ source pattern
  -> HsExpr GhcRn      -- ^ expanded expression
  -> HsExpr GhcRn      -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedPatRn :: LPat GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
mkExpandedPatRn LPat GhcRn
oPat HsExpr GhcRn
eExpr = XXExpr GhcRn -> HsExpr GhcRn
forall p. XXExpr p -> HsExpr p
XExpr (HsThingRn -> HsExpr GhcRn -> XXExprGhcRn
ExpandedThingRn (LPat GhcRn -> HsThingRn
OrigPat LPat GhcRn
oPat) HsExpr GhcRn
eExpr)

-- | Build an expression using the extension constructor `XExpr`,
--   and the two components of the expansion: original do stmt and
--   expanded expression an associate with a provided location
mkExpandedStmtAt
  :: SrcSpanAnnA          -- ^ Location for the expansion expression
  -> ExprLStmt GhcRn      -- ^ source statement
  -> HsExpr GhcRn         -- ^ expanded expression
  -> LHsExpr GhcRn        -- ^ suitably wrapped located 'XXExprGhcRn'
mkExpandedStmtAt :: SrcSpanAnnA -> ExprLStmt GhcRn -> HsExpr GhcRn -> LHsExpr GhcRn
mkExpandedStmtAt SrcSpanAnnA
loc ExprLStmt GhcRn
oStmt HsExpr GhcRn
eExpr = SrcSpanAnnA -> HsExpr GhcRn -> LocatedA (HsExpr GhcRn)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (HsExpr GhcRn -> LocatedA (HsExpr GhcRn))
-> HsExpr GhcRn -> LocatedA (HsExpr GhcRn)
forall a b. (a -> b) -> a -> b
$ ExprLStmt GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
mkExpandedStmt ExprLStmt GhcRn
oStmt HsExpr GhcRn
eExpr

-- | Wrap the expanded version of the expression with a pop.
mkExpandedStmtPopAt
  :: SrcSpanAnnA          -- ^ Location for the expansion statement
  -> ExprLStmt GhcRn      -- ^ source statement
  -> HsExpr GhcRn         -- ^ expanded expression
  -> LHsExpr GhcRn        -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedStmtPopAt :: SrcSpanAnnA -> ExprLStmt GhcRn -> HsExpr GhcRn -> LHsExpr GhcRn
mkExpandedStmtPopAt SrcSpanAnnA
loc ExprLStmt GhcRn
oStmt HsExpr GhcRn
eExpr = SrcSpanAnnA -> LHsExpr GhcRn -> LHsExpr GhcRn
mkPopErrCtxtExprAt SrcSpanAnnA
loc (LHsExpr GhcRn -> LHsExpr GhcRn) -> LHsExpr GhcRn -> LHsExpr GhcRn
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> ExprLStmt GhcRn -> HsExpr GhcRn -> LHsExpr GhcRn
mkExpandedStmtAt SrcSpanAnnA
loc ExprLStmt GhcRn
oStmt HsExpr GhcRn
eExpr


data XXExprGhcTc
  = WrapExpr        -- Type and evidence application and abstractions
      HsWrapper (HsExpr GhcTc)

  | ExpandedThingTc                         -- See Note [Rebindable syntax and XXExprGhcRn]
                                            -- See Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`
         { XXExprGhcTc -> HsThingRn
xtc_orig     :: HsThingRn        -- The original user written thing
         , XXExprGhcTc -> HsExpr GhcTc
xtc_expanded :: HsExpr GhcTc }   -- The expanded typechecked expression

  | 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

  | HsRecSelTc  (FieldOcc GhcTc) -- ^ Variable pointing to record selector
                             -- See Note [Non-overloaded record field selectors] and
                             -- Note [Record selectors in the AST]


-- | Build a 'XXExprGhcRn' out of an extension constructor,
--   and the two components of the expansion: original and
--   expanded typechecked expressions.
mkExpandedExprTc
  :: HsExpr GhcRn           -- ^ source expression
  -> HsExpr GhcTc           -- ^ expanded typechecked expression
  -> HsExpr GhcTc           -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedExprTc :: HsExpr GhcRn -> HsExpr GhcTc -> HsExpr GhcTc
mkExpandedExprTc HsExpr GhcRn
oExpr HsExpr GhcTc
eExpr = XXExpr GhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (HsThingRn -> HsExpr GhcTc -> XXExprGhcTc
ExpandedThingTc (HsExpr GhcRn -> HsThingRn
OrigExpr HsExpr GhcRn
oExpr) HsExpr GhcTc
eExpr)

-- | Build a 'XXExprGhcRn' out of an extension constructor.
--   The two components of the expansion are: original statement and
--   expanded typechecked expression.
mkExpandedStmtTc
  :: ExprLStmt GhcRn        -- ^ source do statement
  -> HsExpr GhcTc           -- ^ expanded typechecked expression
  -> HsExpr GhcTc           -- ^ suitably wrapped 'XXExprGhcRn'
mkExpandedStmtTc :: ExprLStmt GhcRn -> HsExpr GhcTc -> HsExpr GhcTc
mkExpandedStmtTc ExprLStmt GhcRn
oStmt HsExpr GhcTc
eExpr = XXExpr GhcTc -> HsExpr GhcTc
forall p. XXExpr p -> HsExpr p
XExpr (HsThingRn -> HsExpr GhcTc -> XXExprGhcTc
ExpandedThingTc (ExprLStmt GhcRn -> HsThingRn
OrigStmt ExprLStmt GhcRn
oStmt) HsExpr GhcTc
eExpr)

{- *********************************************************************
*                                                                      *
            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)
_ RdrName
uv) = RdrName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc RdrName
uv
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)
s FastString
l) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
               GhcPass p
GhcPs -> SourceText -> SDoc
helper XOverLabel (GhcPass p)
SourceText
s
               GhcPass p
GhcRn -> SourceText -> SDoc
helper XOverLabel (GhcPass p)
SourceText
s
               GhcPass p
GhcTc -> DataConCantHappen -> SDoc
forall a. DataConCantHappen -> a
dataConCantHappen XOverLabel (GhcPass p)
DataConCantHappen
s
    where helper :: SourceText -> SDoc
helper SourceText
s =
            Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'#' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> case SourceText
s of
                          SourceText
NoSourceText -> FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
l
                          SourceText FastString
src -> FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
src
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)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e)         = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => Char -> doc
char Char
'-' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
hsep [SDoc
pp_expr, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"x_ )"])

    pp_infixly :: SDoc -> SDoc
pp_infixly SDoc
v = ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
text String
"x_"])
                       Int
4 (SDoc
pp_expr SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
rparen)

    pp_infixly :: SDoc -> SDoc
pp_infixly SDoc
v = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
    -- `MkSolo x`, not `(x)`
  | [Present XPresent (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr] <- [HsTupArg (GhcPass p)]
exprs
  , Boxity
Boxed <- Boxity
boxity
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
text (Boxity -> NameSpace -> Int -> String
mkTupleStr Boxity
Boxed NameSpace
dataName 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
forall doc. IsLine doc => doc -> doc -> doc
<> [HsTupArg (GhcPass p)] -> SDoc
forall {doc} {id}. IsLine doc => [HsTupArg id] -> doc
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 {doc} {id}. IsLine doc => [HsTupArg id] -> doc
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] -> doc
punc (Present {} : [HsTupArg id]
_) = doc
forall doc. IsLine doc => doc
comma doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<> doc
forall doc. IsLine doc => doc
space
    punc (Missing {} : [HsTupArg id]
_) = doc
forall doc. IsLine doc => doc
comma
    punc (XTupArg {} : [HsTupArg id]
_) = doc
forall doc. IsLine doc => doc
comma doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<> doc
forall doc. IsLine doc => doc
space
    punc []               = doc
forall doc. IsOutput doc => doc
empty

ppr_expr (ExplicitSum XExplicitSum (GhcPass p)
_ Int
alt Int
arity XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"(#" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall {doc}. IsLine doc => Int -> doc
ppr_bars (Int
alt Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall {doc}. IsLine doc => Int -> doc
ppr_bars (Int
arity Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
alt) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"#)"
  where
    ppr_bars :: Int -> doc
ppr_bars Int
n = [doc] -> doc
forall doc. IsLine doc => [doc] -> doc
hsep (Int -> doc -> [doc]
forall a. Int -> a -> [a]
replicate Int
n (Char -> doc
forall doc. IsLine doc => Char -> doc
char Char
'|'))

ppr_expr (HsLam XLam (GhcPass p)
_ HsLamVariant
lam_variant MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches)
  = case HsLamVariant
lam_variant of
       HsLamVariant
LamSingle -> 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
       HsLamVariant
_         -> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_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 SrcSpanAnnLW
_ [GenLocated
   SrcSpanAnnA
   (Match (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts }))
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
sep [[SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
text String
"if") Int
3  ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((GenLocated
   EpAnnCO
   (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      EpAnnCO
      (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  EpAnnCO
  (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
   EpAnnCO
   (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
forall doc. IsLine doc => doc
vbar Int
2 ([SDoc] -> SDoc
ppr_one [SDoc]
one_alt)
          where
            ppr_one :: [SDoc] -> SDoc
ppr_one [] = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"ppr_exp HsMultiIf"
            ppr_one (SDoc
h:[SDoc]
t) = SDoc -> Int -> SDoc -> SDoc
hang SDoc
h Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => String -> doc
text String
"->" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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)
_ HsLocalBinds (GhcPass p)
binds expr :: XRec (GhcPass p) (HsExpr (GhcPass p))
expr@(L SrcSpanAnnA
_ (HsLet XLet (GhcPass p)
_ HsLocalBinds (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
_)))
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"let") Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => String -> doc
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)
_ HsLocalBinds (GhcPass p)
binds XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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 SrcSpanAnnLW
_ [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
forall doc. IsLine doc => doc -> doc
brackets (([SDoc] -> SDoc) -> [SDoc] -> SDoc
pprDeeperList [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
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 -> LHsRecUpdFields p
rupd_flds = LHsRecUpdFields (GhcPass p)
flds })
  = case LHsRecUpdFields (GhcPass p)
flds of
      RegularRecUpdFields { recUpdFields :: forall p. LHsRecUpdFields p -> [LHsRecUpdField p p]
recUpdFields= [LHsRecUpdField (GhcPass p) (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
forall doc. IsLine doc => doc -> doc
braces ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ((GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated SrcSpanAnnA (FieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated SrcSpanAnnA (FieldOcc (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated SrcSpanAnnA (FieldOcc (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdField (GhcPass p) (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated SrcSpanAnnA (FieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
rbinds))))
      OverloadedRecUpdFields { olRecUpdFields :: forall p. LHsRecUpdFields p -> [LHsRecUpdProj p]
olRecUpdFields = [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
forall doc. IsLine doc => doc -> doc
braces ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ((GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated EpAnnCO (FieldLabelStrings (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated EpAnnCO (FieldLabelStrings (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated EpAnnCO (FieldLabelStrings (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdProj (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated EpAnnCO (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
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
dot SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> GenLocated EpAnnCO (DotFieldOcc (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (DotFieldOcc (GhcPass p))
GenLocated EpAnnCO (DotFieldOcc (GhcPass p))
field

ppr_expr (HsProjection { proj_flds :: forall p. HsExpr p -> NonEmpty (DotFieldOcc p)
proj_flds = NonEmpty (DotFieldOcc (GhcPass p))
flds }) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat (SDoc
forall doc. IsLine doc => doc
dot SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
dot ((DotFieldOcc (GhcPass p) -> SDoc)
-> [DotFieldOcc (GhcPass p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map DotFieldOcc (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ([DotFieldOcc (GhcPass p)] -> [SDoc])
-> [DotFieldOcc (GhcPass p)] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ NonEmpty (DotFieldOcc (GhcPass p)) -> [DotFieldOcc (GhcPass p)]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (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
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsLine doc => doc -> doc
brackets (ArithSeqInfo (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ArithSeqInfo (GhcPass p)
info)

ppr_expr (HsTypedSplice XTypedSplice (GhcPass p)
ext XRec (GhcPass p) (HsExpr (GhcPass p))
e)   =
    case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
      GhcPass p
GhcPs -> Maybe Name -> LHsExpr (GhcPass 'Parsed) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe Name -> LHsExpr (GhcPass p) -> SDoc
pprTypedSplice Maybe Name
forall a. Maybe a
Nothing XRec (GhcPass p) (HsExpr (GhcPass p))
LHsExpr (GhcPass 'Parsed)
e
      GhcPass p
GhcRn -> Maybe Name -> LHsExpr GhcRn -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe Name -> LHsExpr (GhcPass p) -> SDoc
pprTypedSplice (Name -> Maybe Name
forall a. a -> Maybe a
Just XTypedSplice (GhcPass p)
Name
ext) XRec (GhcPass p) (HsExpr (GhcPass p))
LHsExpr GhcRn
e
      GhcPass p
GhcTc -> Maybe Name -> LHsExpr GhcTc -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe Name -> LHsExpr (GhcPass p) -> SDoc
pprTypedSplice Maybe Name
forall a. Maybe a
Nothing XRec (GhcPass p) (HsExpr (GhcPass p))
LHsExpr GhcTc
e
ppr_expr (HsUntypedSplice XUntypedSplice (GhcPass p)
ext HsUntypedSplice (GhcPass p)
s) =
    case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
      GhcPass p
GhcPs -> Bool -> Maybe Name -> HsUntypedSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Bool -> Maybe Name -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
True Maybe Name
forall a. Maybe a
Nothing HsUntypedSplice (GhcPass p)
s
      GhcPass p
GhcRn | HsUntypedSpliceNested Name
n <- XUntypedSplice (GhcPass p)
ext -> Bool -> Maybe Name -> HsUntypedSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Bool -> Maybe Name -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
True (Name -> Maybe Name
forall a. a -> Maybe a
Just Name
n) HsUntypedSplice (GhcPass p)
s
      GhcPass p
GhcRn | HsUntypedSpliceTop ThModFinalizers
_ HsExpr GhcRn
e  <- XUntypedSplice (GhcPass p)
ext -> HsExpr GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcRn
e
      GhcPass p
GhcTc -> DataConCantHappen -> SDoc
forall a. DataConCantHappen -> a
dataConCantHappen XUntypedSplice (GhcPass p)
DataConCantHappen
ext

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 (LocatedA (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
LocatedA (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
forall doc. IsDoc doc => doc -> doc -> doc
$$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pending(rn)" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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 EpAnnCO
_ (HsCmdTop XCmdTop (GhcPass p)
_ LHsCmd (GhcPass p)
cmd)))
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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 (HsEmbTy XEmbTy (GhcPass p)
_ LHsWcType (NoGhcTc (GhcPass p))
ty)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type", HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsWcType (NoGhcTc (GhcPass p))
HsWildCardBndrs
  (GhcPass (NoGhcTcPass p))
  (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p))))
ty]

ppr_expr (HsQual XQual (GhcPass p)
_ XRec (GhcPass p) [XRec (GhcPass p) (HsExpr (GhcPass p))]
ctxt XRec (GhcPass p) (HsExpr (GhcPass p))
ty)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [GenLocated
  SrcSpanAnnC [GenLocated SrcSpanAnnA (HsExpr (GhcPass p))]
-> SDoc
forall {p :: Pass} {l} {l}.
(OutputableBndr (IdGhcP p),
 OutputableBndr (IdGhcP (NoGhcTcPass p)), IsPass p,
 Outputable (GenLocated l (HsExpr (GhcPass p))),
 Outputable (GenLocated (Anno (IdGhcP p)) (IdGhcP p)),
 Outputable
   (GenLocated
      (Anno (IdGhcP (NoGhcTcPass p))) (IdGhcP (NoGhcTcPass p)))) =>
GenLocated l [GenLocated l (HsExpr (GhcPass p))] -> SDoc
ppr_context XRec (GhcPass p) [XRec (GhcPass p) (HsExpr (GhcPass p))]
GenLocated
  SrcSpanAnnC [GenLocated SrcSpanAnnA (HsExpr (GhcPass p))]
ctxt, XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
ty]
  where
    ppr_context :: GenLocated l [GenLocated l (HsExpr (GhcPass p))] -> SDoc
ppr_context (L l
_ [GenLocated l (HsExpr (GhcPass p))]
ctxt) =
      case [GenLocated l (HsExpr (GhcPass p))]
ctxt of
        []       -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens SDoc
forall doc. IsOutput doc => doc
empty             SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
darrow
        [L l
_ HsExpr (GhcPass p)
ty] -> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
ty              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
darrow
        [GenLocated l (HsExpr (GhcPass p))]
_        -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([GenLocated l (HsExpr (GhcPass p))] -> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [GenLocated l (HsExpr (GhcPass p))]
ctxt) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
darrow

ppr_expr (HsForAll XForAll (GhcPass p)
_ HsForAllTelescope (GhcPass p)
tele XRec (GhcPass p) (HsExpr (GhcPass p))
ty)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [HsForAllTelescope (GhcPass p)
-> Maybe (LHsContext (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsForAllTelescope (GhcPass p)
-> Maybe (LHsContext (GhcPass p)) -> SDoc
pprHsForAll HsForAllTelescope (GhcPass p)
tele Maybe (LHsContext (GhcPass p))
Maybe
  (GenLocated
     SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
forall a. Maybe a
Nothing, XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
ty]

ppr_expr (HsFunArr XFunArr (GhcPass p)
_ HsArrowOf (XRec (GhcPass p) (HsExpr (GhcPass p))) (GhcPass p)
arr XRec (GhcPass p) (HsExpr (GhcPass p))
arg XRec (GhcPass p) (HsExpr (GhcPass p))
res)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
arg, HsArrowOf (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))) (GhcPass p)
-> SDoc
forall mult (pass :: Pass).
(Outputable mult, OutputableBndrId pass) =>
HsArrowOf mult (GhcPass pass) -> SDoc
pprHsArrow HsArrowOf (XRec (GhcPass p) (HsExpr (GhcPass p))) (GhcPass p)
HsArrowOf (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))) (GhcPass p)
arr SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
res]

ppr_expr (XExpr XXExpr (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
  GhcPass p
GhcRn -> XXExprGhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
XXExprGhcRn
x
  GhcPass p
GhcTc -> XXExprGhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
XXExprGhcTc
x

instance Outputable HsThingRn where
  ppr :: HsThingRn -> SDoc
ppr HsThingRn
thing
    = case HsThingRn
thing of
        OrigExpr HsExpr GhcRn
x -> String -> HsExpr GhcRn -> SDoc
forall {a}. Outputable a => String -> a -> SDoc
ppr_builder String
"<OrigExpr>:" HsExpr GhcRn
x
        OrigStmt ExprLStmt GhcRn
x -> String
-> GenLocated
     SrcSpanAnnA (StmtLR GhcRn GhcRn (LocatedA (HsExpr GhcRn)))
-> SDoc
forall {a}. Outputable a => String -> a -> SDoc
ppr_builder String
"<OrigStmt>:" ExprLStmt GhcRn
GenLocated
  SrcSpanAnnA (StmtLR GhcRn GhcRn (LocatedA (HsExpr GhcRn)))
x
        OrigPat LPat GhcRn
x  -> String -> GenLocated SrcSpanAnnA (Pat GhcRn) -> SDoc
forall {a}. Outputable a => String -> a -> SDoc
ppr_builder String
"<OrigPat>:" LPat GhcRn
GenLocated SrcSpanAnnA (Pat GhcRn)
x

    where ppr_builder :: String -> a -> SDoc
ppr_builder String
prefix a
x = SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
prefix SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
x))) (a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
x)

instance Outputable XXExprGhcRn where
  ppr :: XXExprGhcRn -> SDoc
ppr (ExpandedThingRn HsThingRn
o HsExpr GhcRn
e) = SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [HsThingRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsThingRn
o, HsExpr GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcRn
e]) (HsThingRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsThingRn
o)
  ppr (PopErrCtxt LHsExpr GhcRn
e)        = SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<PopErrCtxt>" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> LocatedA (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
e)) (LocatedA (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcRn
LocatedA (HsExpr GhcRn)
e)
  ppr (HsRecSelRn FieldOcc GhcRn
f)        = FieldOcc GhcRn -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc FieldOcc GhcRn
f

instance Outputable XXExprGhcTc where
  ppr :: XXExprGhcTc -> SDoc
ppr (WrapExpr 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 (ExpandedThingTc HsThingRn
o HsExpr GhcTc
e)
    = SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [HsThingRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsThingRn
o, HsExpr GhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcTc
e]) (HsThingRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsThingRn
o)
            -- e is the expanded expression, we print the original
            -- expression (HsExpr GhcRn), not the
            -- expanded typechecked one (HsExpr GhcTc),
            -- unless we are in ppr's debug mode printed both

  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
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsLine doc => [doc] -> doc
hcat [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"bintick<",
            Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
tickIdTrue,
            String -> SDoc
forall doc. IsLine doc => String -> doc
text String
",",
            Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
tickIdFalse,
            String -> SDoc
forall doc. IsLine doc => String -> doc
text String
">(",
            GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
exp, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
")"]
  ppr (HsRecSelTc FieldOcc GhcTc
f)      = FieldOcc GhcTc -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc FieldOcc GhcTc
f


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 (HsUnboundVar XUnboundVar (GhcPass p)
_ RdrName
occ) = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (RdrName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc RdrName
occ)
ppr_infix_expr (XExpr XXExpr (GhcPass p)
x)            = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
                                        GhcPass p
GhcRn -> XXExprGhcRn -> Maybe SDoc
ppr_infix_expr_rn XXExpr (GhcPass p)
XXExprGhcRn
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 :: XXExprGhcRn -> Maybe SDoc
ppr_infix_expr_rn :: XXExprGhcRn -> Maybe SDoc
ppr_infix_expr_rn (ExpandedThingRn HsThingRn
thing HsExpr GhcRn
_) = HsThingRn -> Maybe SDoc
ppr_infix_hs_expansion HsThingRn
thing
ppr_infix_expr_rn (PopErrCtxt (L SrcSpanAnnA
_ HsExpr GhcRn
a))      = HsExpr GhcRn -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr HsExpr GhcRn
a
ppr_infix_expr_rn (HsRecSelRn FieldOcc GhcRn
f)            = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (FieldOcc GhcRn -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc FieldOcc GhcRn
f)

ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc (WrapExpr 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 (ExpandedThingTc HsThingRn
thing HsExpr GhcTc
_)  = HsThingRn -> Maybe SDoc
ppr_infix_hs_expansion HsThingRn
thing
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_infix_expr_tc (HsRecSelTc FieldOcc GhcTc
f)            = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (FieldOcc GhcTc -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc FieldOcc GhcTc
f)


ppr_infix_hs_expansion :: HsThingRn -> Maybe SDoc
ppr_infix_hs_expansion :: HsThingRn -> Maybe SDoc
ppr_infix_hs_expansion (OrigExpr HsExpr GhcRn
e) = HsExpr GhcRn -> Maybe SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr HsExpr GhcRn
e
ppr_infix_hs_expansion HsThingRn
_            = 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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => String -> doc
text String
"@" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> 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
forall doc. IsOutput doc => (Bool -> doc) -> doc
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
forall doc. IsLine doc => doc -> doc
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 :: Pass).
IsPass x =>
PprPrec -> HsLit (GhcPass 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 (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 (HsTypedSplice{})              = Bool
False
    go (HsUntypedSplice{})            = 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 (HsProjection{})               = Bool
True
    go (HsGetField{})                 = Bool
False
    go (HsEmbTy{})                    = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsForAll{})                   = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
funPrec
    go (HsQual{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
funPrec
    go (HsFunArr{})                   = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
funPrec
    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 -> XXExprGhcRn -> Bool
go_x_rn XXExpr (GhcPass p)
XXExprGhcRn
x

    go_x_tc :: XXExprGhcTc -> Bool
    go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr 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 (ExpandedThingTc HsThingRn
thing HsExpr GhcTc
_)        = HsThingRn -> Bool
hsExpandedNeedsParens HsThingRn
thing
    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_tc (HsRecSelTc{})                   = Bool
False

    go_x_rn :: XXExprGhcRn -> Bool
    go_x_rn :: XXExprGhcRn -> Bool
go_x_rn (ExpandedThingRn HsThingRn
thing HsExpr GhcRn
_)    = HsThingRn -> Bool
hsExpandedNeedsParens HsThingRn
thing
    go_x_rn (PopErrCtxt (L SrcSpanAnnA
_ HsExpr GhcRn
a))         = PprPrec -> HsExpr GhcRn -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcRn
a
    go_x_rn (HsRecSelRn{})               = Bool
False

    hsExpandedNeedsParens :: HsThingRn -> Bool
    hsExpandedNeedsParens :: HsThingRn -> Bool
hsExpandedNeedsParens (OrigExpr HsExpr GhcRn
e) = PprPrec -> HsExpr GhcRn -> Bool
forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
prec HsExpr GhcRn
e
    hsExpandedNeedsParens HsThingRn
_            = Bool
False

-- | Parenthesize an expression without token information
gHsPar :: forall p. IsPass p => LHsExpr (GhcPass p) -> HsExpr (GhcPass p)
gHsPar :: forall (p :: Pass).
IsPass p =>
LHsExpr (GhcPass p) -> HsExpr (GhcPass p)
gHsPar LHsExpr (GhcPass p)
e = XPar (GhcPass p) -> LHsExpr (GhcPass p) -> HsExpr (GhcPass p)
forall p. XPar p -> LHsExpr p -> HsExpr p
HsPar XPar (GhcPass p)
x LHsExpr (GhcPass p)
e
  where
    x :: XPar (GhcPass p)
x = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
      GhcPass p
GhcPs -> (EpToken "(", EpToken ")")
XPar (GhcPass p)
forall a. NoAnn a => a
noAnn
      GhcPass p
GhcRn -> XPar (GhcPass p)
NoExtField
noExtField
      GhcPass p
GhcTc -> XPar (GhcPass p)
NoExtField
noExtField

-- | @'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 (p :: Pass).
IsPass p =>
LHsExpr (GhcPass p) -> HsExpr (GhcPass p)
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)
_ LHsExpr (GhcPass p)
e)) = 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)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
e)) = 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 (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          = XXExprGhcRn -> Bool
go_x_rn XXExpr (GhcPass p)
XXExprGhcRn
x
  where
    go_x_tc :: XXExprGhcTc -> Bool
    go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr HsWrapper
_ HsExpr GhcTc
e)            = HsExpr GhcTc -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr GhcTc
e
    go_x_tc (ExpandedThingTc HsThingRn
thing HsExpr GhcTc
_) = HsThingRn -> Bool
isAtomicExpandedThingRn HsThingRn
thing
    go_x_tc (ConLikeTc {})            = Bool
True
    go_x_tc (HsTick {})               = Bool
False
    go_x_tc (HsBinTick {})            = Bool
False
    go_x_tc (HsRecSelTc{})            = Bool
True

    go_x_rn :: XXExprGhcRn -> Bool
    go_x_rn :: XXExprGhcRn -> Bool
go_x_rn (ExpandedThingRn HsThingRn
thing HsExpr GhcRn
_) = HsThingRn -> Bool
isAtomicExpandedThingRn HsThingRn
thing
    go_x_rn (PopErrCtxt (L SrcSpanAnnA
_ HsExpr GhcRn
a))      = HsExpr GhcRn -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr GhcRn
a
    go_x_rn (HsRecSelRn{})            = Bool
True

    isAtomicExpandedThingRn :: HsThingRn -> Bool
    isAtomicExpandedThingRn :: HsThingRn -> Bool
isAtomicExpandedThingRn (OrigExpr HsExpr GhcRn
e) = HsExpr GhcRn -> Bool
forall (p :: Pass). IsPass p => HsExpr (GhcPass p) -> Bool
isAtomicHsExpr HsExpr GhcRn
e
    isAtomicExpandedThingRn HsThingRn
_            = Bool
False

isAtomicHsExpr HsExpr (GhcPass p)
_ = Bool
False

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


{- *********************************************************************
*                                                                      *
             XXExprGhcRn and rebindable syntax
*                                                                      *
********************************************************************* -}

{- Note [Rebindable syntax and XXExprGhcRn]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
'XXExprGhcRn' 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
      (ExpandedThingRn
        (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 (XXExprGhcRn 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 (ExpandedThingRn <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 (ExpandedThingRn ... ...) 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
XXExprGhcRn].

When OverloadedRecordDot is enabled:
- Field selection expressions
  - e.g. foo.bar.baz
  - Have abstract syntax HsGetField
  - After renaming are XExpr (ExpandedThingRn (HsGetField ...) (getField @"..."...)) expressions
- Field selector expressions e.g. (.x.y)
  - Have abstract syntax HsProjection
  - After renaming are XExpr (ExpandedThingRn (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 (ExpandedThingRn (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.
-}


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

type instance XCmdArrApp  GhcPs = (IsUnicodeSyntax, EpaLocation)
type instance XCmdArrApp  GhcRn = NoExtField
type instance XCmdArrApp  GhcTc = Type

type instance XCmdArrForm GhcPs = AnnList ()
-- | fixity (filled in by the renamer), for forms that were converted from
-- OpApp's by the renamer
type instance XCmdArrForm GhcRn = Maybe Fixity
type instance XCmdArrForm GhcTc = Maybe Fixity

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

type instance XCmdPar     GhcPs = (EpToken "(", EpToken ")")
type instance XCmdPar     GhcRn = NoExtField
type instance XCmdPar     GhcTc = NoExtField

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

type instance XCmdLamCase (GhcPass _) = EpAnnLam

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

type instance XCmdLet     GhcPs = (EpToken "let", EpToken "in")
type instance XCmdLet     GhcRn = NoExtField
type instance XCmdLet     GhcTc = NoExtField

type instance XCmdDo      GhcPs = AnnList EpaLocation
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

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

-- | Command Syntax Table (for Arrow syntax)
type CmdSyntaxTable p = [(Name, HsExpr p)]
-- See Note [CmdSyntaxTable]

{-
Note [CmdSyntaxTable]
~~~~~~~~~~~~~~~~~~~~~
Used only for arrow-syntax stuff (HsCmdTop), the CmdSyntaxTable keeps
track of the methods needed for a Cmd.

* Before the renamer, this list is an empty list

* After the renamer, it takes the form @[(std_name, HsVar actual_name)]@
  For example, for the 'arr' method
   * normal case:            (GHC.Control.Arrow.arr, HsVar GHC.Control.Arrow.arr)
   * with rebindable syntax: (GHC.Control.Arrow.arr, arr_22)
             where @arr_22@ is whatever 'arr' is in scope

* After the type checker, it takes the form [(std_name, <expression>)]
  where <expression> is the evidence for the method.  This evidence is
  instantiated with the class, but is still polymorphic in everything
  else.  For example, in the case of 'arr', the evidence has type
         forall b c. (b->c) -> a b c
  where 'a' is the ambient type of the arrow.  This polymorphism is
  important because the desugarer uses the same evidence at multiple
  different types.

This is Less Cool than what we normally do for rebindable syntax, which is to
make fully-instantiated piece of evidence at every use site.  The Cmd way
is Less Cool because
  * The renamer has to predict which methods are needed.
    See the tedious GHC.Rename.Expr.methodNamesCmd.

  * The desugarer has to know the polymorphic type of the instantiated
    method. This is checked by Inst.tcSyntaxName, but is less flexible
    than the rest of rebindable syntax, where the type is less
    pre-ordained.  (And this flexibility is useful; for example we can
    typecheck do-notation with (>>=) :: m1 a -> (a -> m2 b) -> m2 b.)
-}

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)
_ XRec (GhcPass p) (HsCmd (GhcPass p))
c) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => [doc] -> doc
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 XCmdLamCase (GhcPass p)
_ HsLamVariant
LamSingle 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 (HsCmdLam XCmdLamCase (GhcPass p)
_ HsLamVariant
lam_variant MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_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 (HsCmdCase XCmdCase (GhcPass p)
_ LHsExpr (GhcPass p)
expr MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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 (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
forall doc. IsLine doc => [doc] -> doc
sep [[SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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)
_ HsLocalBinds (GhcPass p)
binds cmd :: XRec (GhcPass p) (HsCmd (GhcPass p))
cmd@(L SrcSpanAnnA
_ (HsCmdLet {})))
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"let") Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => String -> doc
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)
_ HsLocalBinds (GhcPass p)
binds XRec (GhcPass p) (HsCmd (GhcPass p))
cmd)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
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 SrcSpanAnnLW
_ [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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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)
rn_fix (L SrcSpanAnnA
_ HsExpr (GhcPass p)
op) LexicalFixity
ps_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
forall doc. IsLine doc => String -> doc
text String
"(|" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr HsExpr (GhcPass p)
op)
                      Int
4 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((GenLocated EpAnnCO (HsCmdTop (GhcPass p)) -> SDoc)
-> [GenLocated EpAnnCO (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 EpAnnCO (HsCmdTop (GhcPass p))
    -> HsCmdTop (GhcPass p))
-> GenLocated EpAnnCO (HsCmdTop (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated EpAnnCO (HsCmdTop (GhcPass p)) -> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LHsCmdTop (GhcPass p)]
[GenLocated EpAnnCO (HsCmdTop (GhcPass p))]
args) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
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
      , case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
          GhcPass p
GhcPs -> LexicalFixity
ps_fix LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
          GhcPass p
GhcRn -> Maybe Fixity -> Bool
forall a. Maybe a -> Bool
isJust Maybe Fixity
XCmdArrForm (GhcPass p)
rn_fix Bool -> Bool -> Bool
|| LexicalFixity
ps_fix LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
          GhcPass p
GhcTc -> Maybe Fixity -> Bool
forall a. Maybe a -> Bool
isJust Maybe Fixity
XCmdArrForm (GhcPass p)
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 EpAnnCO (HsCmdTop (GhcPass p)) -> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated EpAnnCO (HsCmdTop (GhcPass p))
arg1))
           Int
4 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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 EpAnnCO (HsCmdTop (GhcPass p)) -> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated EpAnnCO (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
  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
forall doc. IsLine doc => doc -> doc
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 = Origin
type instance XMG         GhcRn b = Origin -- See Note [Generated code and pattern-match checking]
type instance XMG         GhcTc b = MatchGroupTc

data MatchGroupTc
  = MatchGroupTc
       { MatchGroupTc -> [Scaled Type]
mg_arg_tys :: [Scaled Type]  -- Types of the arguments, t1..tn
       , MatchGroupTc -> Type
mg_res_ty  :: Type    -- Type of the result, tr
       , MatchGroupTc -> Origin
mg_origin  :: Origin  -- Origin (Generated vs FromSource)
       } deriving Typeable MatchGroupTc
Typeable MatchGroupTc =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> MatchGroupTc -> c MatchGroupTc)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MatchGroupTc)
-> (MatchGroupTc -> Constr)
-> (MatchGroupTc -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MatchGroupTc))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c MatchGroupTc))
-> ((forall b. Data b => b -> b) -> MatchGroupTc -> MatchGroupTc)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r)
-> (forall u. (forall d. Data d => d -> u) -> MatchGroupTc -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> MatchGroupTc -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc)
-> Data MatchGroupTc
MatchGroupTc -> Constr
MatchGroupTc -> DataType
(forall b. Data b => b -> b) -> MatchGroupTc -> MatchGroupTc
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) -> MatchGroupTc -> u
forall u. (forall d. Data d => d -> u) -> MatchGroupTc -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MatchGroupTc
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MatchGroupTc -> c MatchGroupTc
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MatchGroupTc)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MatchGroupTc)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MatchGroupTc -> c MatchGroupTc
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MatchGroupTc -> c MatchGroupTc
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MatchGroupTc
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MatchGroupTc
$ctoConstr :: MatchGroupTc -> Constr
toConstr :: MatchGroupTc -> Constr
$cdataTypeOf :: MatchGroupTc -> DataType
dataTypeOf :: MatchGroupTc -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MatchGroupTc)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MatchGroupTc)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MatchGroupTc)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c MatchGroupTc)
$cgmapT :: (forall b. Data b => b -> b) -> MatchGroupTc -> MatchGroupTc
gmapT :: (forall b. Data b => b -> b) -> MatchGroupTc -> MatchGroupTc
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MatchGroupTc -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MatchGroupTc -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> MatchGroupTc -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MatchGroupTc -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MatchGroupTc -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MatchGroupTc -> m MatchGroupTc
Data

type instance XXMatchGroup (GhcPass _) b = DataConCantHappen

type instance XCMatch (GhcPass _) b = NoExtField
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)) -> Bool)
-> [GenLocated SrcSpanAnnA (Pat (GhcPass id))] -> Int
forall a. (a -> Bool) -> [a] -> Int
count (Pat (GhcPass id) -> Bool
forall p. Pat p -> Bool
isVisArgPat (Pat (GhcPass id) -> Bool)
-> (GenLocated SrcSpanAnnA (Pat (GhcPass id)) -> Pat (GhcPass id))
-> GenLocated SrcSpanAnnA (Pat (GhcPass id))
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (Pat (GhcPass id)) -> Pat (GhcPass id)
forall l e. GenLocated l e -> e
unLoc) (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. HasCallStack => 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 -> XRec p [LPat p]
m_pats = L EpaLocation
_ [GenLocated SrcSpanAnnA (Pat (GhcPass id))]
pats })) = [LPat (GhcPass id)]
[GenLocated SrcSpanAnnA (Pat (GhcPass id))]
pats

isInfixMatch :: Match (GhcPass p) body -> Bool
isInfixMatch :: forall (p :: Pass) body. Match (GhcPass p) body -> Bool
isInfixMatch Match (GhcPass p) body
match = case Match (GhcPass p) body
-> HsMatchContext (LIdP (NoGhcTc (GhcPass p)))
forall p body. Match p body -> HsMatchContext (LIdP (NoGhcTc p))
m_ctxt Match (GhcPass p) body
match of
  FunRhs {mc_fixity :: forall fn. HsMatchContext fn -> LexicalFixity
mc_fixity = LexicalFixity
Infix} -> Bool
True
  HsMatchContext (LIdP (NoGhcTc (GhcPass p)))
_                          -> Bool
False

-- 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 (EpToken "|")
ga_vbar :: Maybe (EpToken "|"),
      GrhsAnn -> Either (EpToken "=") TokRarrow
ga_sep  :: Either (EpToken "=") TokRarrow -- ^ Match separator location, `=` or `->`
      } 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)

instance NoAnn GrhsAnn where
  noAnn :: GrhsAnn
noAnn = Maybe (EpToken "|") -> Either (EpToken "=") TokRarrow -> GrhsAnn
GrhsAnn Maybe (EpToken "|")
forall a. Maybe a
Nothing Either (EpToken "=") TokRarrow
forall a. NoAnn a => a
noAnn

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
forall doc. IsDoc doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
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 Void
-> GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body fn.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext fn -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs (HsMatchContext Void
forall fn. HsMatchContext fn
PatBindRhs :: HsMatchContext Void) 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 -> XRec p [LPat p]
m_pats = L EpaLocation
_ [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats, m_ctxt :: forall p body. Match p body -> HsMatchContext (LIdP (NoGhcTc p))
m_ctxt = HsMatchContext (LIdP (NoGhcTc (GhcPass idR)))
ctxt, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs (GhcPass idR) body
grhss })
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
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
  (GenLocated
     (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))
-> GRHSs (GhcPass idR) body -> SDoc
forall (idR :: Pass) body fn.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext fn -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext (LIdP (NoGhcTc (GhcPass idR)))
HsMatchContext
  (GenLocated
     (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))
ctxt GRHSs (GhcPass idR) body
grhss) ]
  where
    -- lam_cases_result: we don't simply return (empty, pats) to avoid
    -- introducing an additional `nest 2` via the empty herald
    lam_cases_result :: (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
lam_cases_result = case [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats of
                          []     -> (SDoc
forall doc. IsOutput doc => doc
empty, [])
                          (GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p:[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
ps) -> (PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
appPrec LPat (GhcPass idR)
GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
ps)

    (SDoc
herald, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
other_pats)
        = case HsMatchContext (LIdP (NoGhcTc (GhcPass idR)))
ctxt of
            FunRhs {mc_fun :: forall fn. HsMatchContext fn -> fn
mc_fun=L Anno (IdGhcP (NoGhcTcPass idR))
_ IdGhcP (NoGhcTcPass idR)
fun, mc_fixity :: forall fn. HsMatchContext fn -> LexicalFixity
mc_fixity=LexicalFixity
fixity, mc_strictness :: forall fn. HsMatchContext fn -> 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 [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)     -- A strict variable binding
                   (Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'!'SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>IdGhcP (NoGhcTcPass idR) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP (NoGhcTcPass idR)
fun, [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, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats) -- f x y z = e
                                            -- Not pprBndr; the AbsBinds will
                                            -- have printed the signature
                | Bool
otherwise
                -> case [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats of
                     (GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p1:GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p2:[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
rest)
                        | [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
rest -> (SDoc
pp_infix, [])           -- x &&& y = e
                        | Bool
otherwise -> (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens SDoc
pp_infix, [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)
GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p1
                                     SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdGhcP (NoGhcTcPass idR) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP (NoGhcTcPass idR)
fun
                                     SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> PprPrec -> LPat (GhcPass idR) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
PprPrec -> LPat (GhcPass p) -> SDoc
pprParendLPat PprPrec
opPrec LPat (GhcPass idR)
GenLocated SrcSpanAnnA (Pat (GhcPass idR))
p2
                     [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
_ -> String
-> SDoc -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprMatch" (HsMatchContext
  (GenLocated
     (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr HsMatchContext (LIdP (NoGhcTc (GhcPass idR)))
HsMatchContext
  (GenLocated
     (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))
ctxt SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ [GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

            LamAlt HsLamVariant
LamSingle                       -> (Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'\\', [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)
            ArrowMatchCtxt (ArrowLamAlt HsLamVariant
LamSingle) -> (Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'\\', [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)
            LamAlt HsLamVariant
LamCases                        -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
lam_cases_result
            ArrowMatchCtxt (ArrowLamAlt HsLamVariant
LamCases)  -> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
lam_cases_result

            ArrowMatchCtxt HsArrowMatchContext
ProcExpr -> (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"proc", [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

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

pprGRHSs :: (OutputableBndrId idR, Outputable body)
         => HsMatchContext fn -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs :: forall (idR :: Pass) body fn.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext fn -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext fn
ctxt (GRHSs XCGRHSs (GhcPass idR) body
_ [LGRHS (GhcPass idR) body]
grhss HsLocalBinds (GhcPass idR)
binds)
  = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
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 fn -> GRHS (GhcPass idR) body -> SDoc
forall (idR :: Pass) body fn.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext fn -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext fn
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
forall doc. IsDoc doc => doc -> doc -> doc
$$ Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless (HsLocalBinds (GhcPass idR) -> Bool
forall a b. HsLocalBindsLR a b -> Bool
eqEmptyLocalBinds HsLocalBinds (GhcPass idR)
binds)
      (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where" SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ 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 fn -> GRHS (GhcPass idR) body -> SDoc
pprGRHS :: forall (idR :: Pass) body fn.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext fn -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext fn
ctxt (GRHS XCGRHS (GhcPass idR) body
_ [] body
body)
 =  HsMatchContext fn -> body -> SDoc
forall body fn.
Outputable body =>
HsMatchContext fn -> body -> SDoc
pp_rhs HsMatchContext fn
ctxt body
body

pprGRHS HsMatchContext fn
ctxt (GRHS XCGRHS (GhcPass idR) body
_ [GuardLStmt (GhcPass idR)]
guards body
body)
 = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc
forall doc. IsLine doc => doc
vbar SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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 fn -> body -> SDoc
forall body fn.
Outputable body =>
HsMatchContext fn -> body -> SDoc
pp_rhs HsMatchContext fn
ctxt body
body]

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

matchSeparator :: HsMatchContext fn -> SDoc
matchSeparator :: forall fn. HsMatchContext fn -> SDoc
matchSeparator FunRhs{}         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"="
matchSeparator HsMatchContext fn
CaseAlt          = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->"
matchSeparator LamAlt{}         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->"
matchSeparator HsMatchContext fn
IfAlt            = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->"
matchSeparator ArrowMatchCtxt{} = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->"
matchSeparator HsMatchContext fn
PatBindRhs       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"="
matchSeparator HsMatchContext fn
PatBindGuards    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"="
matchSeparator StmtCtxt{}       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<-"
matchSeparator HsMatchContext fn
RecUpd           = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"="  -- This can be printed by the pattern
matchSeparator HsMatchContext fn
PatSyn           = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<-" -- match checker trace
matchSeparator HsMatchContext fn
LazyPatCtx       = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"unused"
matchSeparator HsMatchContext fn
ThPatSplice      = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"unused"
matchSeparator HsMatchContext fn
ThPatQuote       = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"unused"

instance Outputable GrhsAnn where
  ppr :: GrhsAnn -> SDoc
ppr (GrhsAnn Maybe (EpToken "|")
v Either (EpToken "=") TokRarrow
s) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"GrhsAnn" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (EpToken "|") -> SDoc
forall a. Outputable a => a -> SDoc
ppr Maybe (EpToken "|")
v SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Either (EpToken "=") TokRarrow -> SDoc
forall a. Outputable a => a -> SDoc
ppr Either (EpToken "=") TokRarrow
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 = EpUniToken "<-" "←"
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 = NoExtField
type instance XApplicativeStmt (GhcPass _) GhcRn = NoExtField
type instance XApplicativeStmt (GhcPass _) GhcTc = 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 = EpToken "let"

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 = AnnTransStmt
type instance XTransStmt       (GhcPass _) GhcRn b = NoExtField
type instance XTransStmt       (GhcPass _) GhcTc b = Type

type instance XRecStmt         (GhcPass _) GhcPs b = AnnList (EpToken "rec")
type instance XRecStmt         (GhcPass _) GhcRn b = NoExtField
type instance XRecStmt         (GhcPass _) GhcTc b = RecStmtTc

type instance XXStmtLR         (GhcPass _) GhcPs b = DataConCantHappen
type instance XXStmtLR         (GhcPass x) GhcRn b = ApplicativeStmt (GhcPass x) GhcRn
type instance XXStmtLR         (GhcPass x) GhcTc b = ApplicativeStmt (GhcPass x) GhcTc

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

instance NoAnn AnnTransStmt where
  noAnn :: AnnTransStmt
noAnn = EpToken "then"
-> Maybe (EpToken "group")
-> Maybe (EpToken "by")
-> Maybe (EpToken "using")
-> AnnTransStmt
AnnTransStmt EpToken "then"
forall a. NoAnn a => a
noAnn Maybe (EpToken "group")
forall a. NoAnn a => a
noAnn Maybe (EpToken "by")
forall a. NoAnn a => a
noAnn Maybe (EpToken "using")
forall a. NoAnn a => a
noAnn


-- | 'ApplicativeStmt' represents an applicative expression built with
-- '<$>' and '<*>'.  It is generated by the renamer, and is desugared into the
-- appropriate applicative expression by the desugarer, but it is intended
-- to be invisible in error messages.
--
-- For full details, see Note [ApplicativeDo] in "GHC.Rename.Expr"
--
data ApplicativeStmt idL idR
  = ApplicativeStmt
             (XApplicativeStmt idL idR) -- Post typecheck, Type of the body
             [ ( SyntaxExpr idR
               , ApplicativeArg idL) ]
                      -- [(<$>, e1), (<*>, e2), ..., (<*>, en)]
             (Maybe (SyntaxExpr idR))  -- 'join', if necessary

-- | Applicative Argument
data ApplicativeArg idL
  = ApplicativeArgOne      -- A single statement (BindStmt or BodyStmt)
    { forall idL. ApplicativeArg idL -> XApplicativeArgOne idL
xarg_app_arg_one  :: XApplicativeArgOne idL
      -- ^ The fail operator, after renaming
      --
      -- The fail operator is needed if this is a BindStmt
      -- where the pattern can fail. E.g.:
      -- (Just a) <- stmt
      -- The fail operator will be invoked if the pattern
      -- match fails.
      -- It is also used for guards in MonadComprehensions.
      -- The fail operator is Nothing
      -- if the pattern match can't fail
    , forall idL. ApplicativeArg idL -> LPat idL
app_arg_pattern   :: LPat idL -- WildPat if it was a BodyStmt (see below)
    , forall idL. ApplicativeArg idL -> LHsExpr idL
arg_expr          :: LHsExpr idL
    , forall idL. ApplicativeArg idL -> Bool
is_body_stmt      :: Bool
      -- ^ True <=> was a BodyStmt,
      -- False <=> was a BindStmt.
      -- See Note [Applicative BodyStmt]
    }
  | ApplicativeArgMany     -- do { stmts; return vars }
    { forall idL. ApplicativeArg idL -> XApplicativeArgMany idL
xarg_app_arg_many :: XApplicativeArgMany idL
    , forall idL. ApplicativeArg idL -> [ExprLStmt idL]
app_stmts         :: [ExprLStmt idL] -- stmts
    , forall idL. ApplicativeArg idL -> HsExpr idL
final_expr        :: HsExpr idL    -- return (v1,..,vn), or just (v1,..,vn)
    , forall idL. ApplicativeArg idL -> LPat idL
bv_pattern        :: LPat idL      -- (v1,...,vn)
    , forall idL. ApplicativeArg idL -> HsDoFlavour
stmt_context      :: HsDoFlavour
      -- ^ context of the do expression, used in pprArg
    }
  | XApplicativeArg !(XXApplicativeArg idL)

type family XApplicativeStmt x x'

-- ApplicativeArg type families
type family XApplicativeArgOne   x
type family XApplicativeArgMany  x
type family XXApplicativeArg     x

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
forall doc. IsOutput doc => doc -> doc
whenPprDebug (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[last]") SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
      (case Maybe Bool
m_dollar_stripped of
        Just Bool
True -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"return $"
        Just Bool
False -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"return"
        Maybe Bool
Nothing -> SDoc
forall doc. IsOutput doc => doc
empty) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
      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
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
sep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate (String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
sep ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
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
forall doc. IsLine doc => String -> doc
text String
"rec" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
    [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
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
forall doc. IsOutput doc => doc -> doc
whenPprDebug ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"rec_ids=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> [IdGhcP idR] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IdP (GhcPass idR)]
[IdGhcP idR]
rec_ids
                            , String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"later_ids=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> [IdGhcP idR] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IdP (GhcPass idR)]
[IdGhcP idR]
later_ids])]

pprStmt (XStmtLR XXStmtLR (GhcPass idL) (GhcPass idR) body
x) = case GhcPass idR
forall (p :: Pass). IsPass p => GhcPass p
ghcPass :: GhcPass idR of
    GhcPass idR
GhcRn -> (OutputableBndrId idL, OutputableBndrId idR) =>
ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
pprApplicativeStmt XXStmtLR (GhcPass idL) (GhcPass idR) body
ApplicativeStmt (GhcPass idL) (GhcPass idR)
x
    GhcPass idR
GhcTc -> (OutputableBndrId idL, OutputableBndrId idR) =>
ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
pprApplicativeStmt XXStmtLR (GhcPass idL) (GhcPass idR) body
ApplicativeStmt (GhcPass idL) (GhcPass idR)
x

  where
    pprApplicativeStmt :: (OutputableBndrId idL, OutputableBndrId idR) => ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
    pprApplicativeStmt :: (OutputableBndrId idL, OutputableBndrId idR) =>
ApplicativeStmt (GhcPass idL) (GhcPass idR) -> SDoc
pprApplicativeStmt (ApplicativeStmt XApplicativeStmt (GhcPass idL) (GhcPass idR)
_ [(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
forall doc. IsDoc doc => [doc] -> doc
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
_ (XStmtLR XXStmtLR
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
x)) = case GhcPass idL
forall (p :: Pass). IsPass p => GhcPass p
ghcPass :: GhcPass idL of
            GhcPass idL
GhcRn | (ApplicativeStmt XApplicativeStmt (GhcPass idL) GhcRn
_ [(SyntaxExpr GhcRn, ApplicativeArg (GhcPass idL))]
args FailOperator GhcRn
_) <- XXStmtLR
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
x -> ((SyntaxExprRn, ApplicativeArg (GhcPass idL)) -> [SDoc])
-> [(SyntaxExprRn, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprRn, ApplicativeArg (GhcPass idL)) -> [SDoc]
forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg [(SyntaxExpr GhcRn, ApplicativeArg (GhcPass idL))]
[(SyntaxExprRn, ApplicativeArg (GhcPass idL))]
args
            GhcPass idL
GhcTc | (ApplicativeStmt XApplicativeStmt (GhcPass idL) GhcTc
_ [(SyntaxExpr GhcTc, ApplicativeArg (GhcPass idL))]
args FailOperator GhcTc
_) <- XXStmtLR
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
x -> ((SyntaxExprTc, ApplicativeArg (GhcPass idL)) -> [SDoc])
-> [(SyntaxExprTc, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprTc, ApplicativeArg (GhcPass idL)) -> [SDoc]
forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg [(SyntaxExpr GhcTc, ApplicativeArg (GhcPass idL))]
[(SyntaxExprTc, 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 :: (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
forall doc. IsLine doc => [doc] -> doc
sep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate (String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsOutput doc => doc -> doc
whenPprDebug (if Maybe (SyntaxExprGhc idR) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (SyntaxExpr (GhcPass idR))
Maybe (SyntaxExprGhc idR)
mb_join then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[join]" else SDoc
forall doc. IsOutput doc => doc
empty) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
            (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
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => doc -> doc -> doc
<+>
     String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<-" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
     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 e a. HasAnnotation e => a -> GenLocated e 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 e a. HasAnnotation e => a -> GenLocated e 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
forall doc. IsLine doc => [doc] -> doc
sep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"then" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => [doc] -> doc
sep [ String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => [doc] -> doc
sep [ String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
text String
"using" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsOutput doc => doc
empty
pprBy (Just body
e) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"by" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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
forall doc. IsLine doc => doc -> doc -> doc
<> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"do"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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
forall doc. IsLine doc => String -> doc
text String
"do"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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
forall doc. IsLine doc => doc -> doc -> doc
<> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"mdo"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => doc -> doc
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
forall doc. IsLine doc => String -> doc
text String
"do"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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
forall doc. IsOutput doc => doc
empty
  Just ModuleName
module_name -> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
module_name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Char -> SDoc
forall doc. IsLine doc => Char -> doc
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
forall doc. IsDoc doc => [doc] -> doc
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
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
forall doc. IsLine doc => doc
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
*                                                                      *
************************************************************************
-}

-- | Finalizers produced by a splice with
-- 'Language.Haskell.TH.Syntax.addModFinalizer'
--
-- See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice. For how
-- this is used.
--
newtype ThModFinalizers = ThModFinalizers [ForeignRef (TH.Q ())]

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

-- See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice.
-- This is the result of splicing a splice. It is produced by
-- the renamer and consumed by the typechecker. It lives only between the two.
data HsUntypedSpliceResult thing  -- 'thing' can be HsExpr or HsType
  = HsUntypedSpliceTop
      { forall thing. HsUntypedSpliceResult thing -> ThModFinalizers
utsplice_result_finalizers :: ThModFinalizers -- ^ TH finalizers produced by the splice.
      , forall thing. HsUntypedSpliceResult thing -> thing
utsplice_result            :: thing           -- ^ The result of splicing; See Note [Lifecycle of a splice]
      }
  | HsUntypedSpliceNested SplicePointName -- A unique name to identify this splice point

type instance XTypedSplice   GhcPs = EpToken "$$"
type instance XTypedSplice   GhcRn = SplicePointName
type instance XTypedSplice   GhcTc = DelayedSplice

type instance XUntypedSplice GhcPs = NoExtField
type instance XUntypedSplice GhcRn = HsUntypedSpliceResult (HsExpr GhcRn)
type instance XUntypedSplice GhcTc = DataConCantHappen

-- HsUntypedSplice
type instance XUntypedSpliceExpr GhcPs = EpToken "$"
type instance XUntypedSpliceExpr GhcRn = EpToken "$"
type instance XUntypedSpliceExpr GhcTc = DataConCantHappen

type instance XQuasiQuote        p = NoExtField

type instance XXUntypedSplice    p = DataConCantHappen

-- 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. HasCallStack => 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

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

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

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


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
forall doc. IsLine doc => doc -> doc
angleBrackets (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
n SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
comma SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> 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))

pprTypedSplice :: (OutputableBndrId p) => Maybe SplicePointName -> LHsExpr (GhcPass p) -> SDoc
pprTypedSplice :: forall (p :: Pass).
OutputableBndrId p =>
Maybe Name -> LHsExpr (GhcPass p) -> SDoc
pprTypedSplice Maybe Name
n LHsExpr (GhcPass p)
e = SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
ppr_splice (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"$$") Maybe Name
n LHsExpr (GhcPass p)
e

pprUntypedSplice :: forall p. (OutputableBndrId p)
                 => Bool -- Whether to precede the splice with "$"
                 -> Maybe SplicePointName -- Used for pretty printing when exists
                 -> HsUntypedSplice (GhcPass p)
                 -> SDoc
pprUntypedSplice :: forall (p :: Pass).
OutputableBndrId p =>
Bool -> Maybe Name -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
True  Maybe Name
n (HsUntypedSpliceExpr XUntypedSpliceExpr (GhcPass p)
_ LHsExpr (GhcPass p)
e) = SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
ppr_splice (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"$") Maybe Name
n LHsExpr (GhcPass p)
e
pprUntypedSplice Bool
False Maybe Name
n (HsUntypedSpliceExpr XUntypedSpliceExpr (GhcPass p)
_ LHsExpr (GhcPass p)
e) = SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
ppr_splice SDoc
forall doc. IsOutput doc => doc
empty Maybe Name
n LHsExpr (GhcPass p)
e
pprUntypedSplice Bool
_     Maybe Name
_ (HsQuasiQuote XQuasiQuote (GhcPass p)
_ IdP (GhcPass p)
q XRec (GhcPass p) FastString
s)      = IdGhcP p -> FastString -> SDoc
forall p. OutputableBndr p => p -> FastString -> SDoc
ppr_quasi IdP (GhcPass p)
IdGhcP p
q (GenLocated EpAnnCO FastString -> FastString
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) FastString
GenLocated EpAnnCO FastString
s)

ppr_quasi :: OutputableBndr p => p -> FastString -> SDoc
ppr_quasi :: forall p. OutputableBndr p => p -> FastString -> SDoc
ppr_quasi p
quoter FastString
quote = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'[' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> p -> SDoc
forall a. Outputable a => a -> SDoc
ppr p
quoter SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
vbar SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>
                           FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
quote SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"|]"

ppr_splice :: (OutputableBndrId p)
           => SDoc
           -> Maybe SplicePointName
           -> LHsExpr (GhcPass p)
           -> SDoc
ppr_splice :: forall (p :: Pass).
OutputableBndrId p =>
SDoc -> Maybe Name -> LHsExpr (GhcPass p) -> SDoc
ppr_splice SDoc
herald Maybe Name
mn LHsExpr (GhcPass p)
e
    = SDoc
herald
    SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> (case Maybe Name
mn of
         Maybe Name
Nothing -> SDoc
forall doc. IsOutput doc => doc
empty
         Just Name
splice_name -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
splice_name)))
    SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e


type instance XExpBr  GhcPs       = (BracketAnn (EpUniToken "[|" "⟦") (EpToken "[e|"), EpUniToken "|]" "⟧")
type instance XPatBr  GhcPs       = (EpToken "[p|", EpUniToken "|]" "⟧")
type instance XDecBrL GhcPs       = (EpToken "[d|", EpUniToken "|]" "⟧", (EpToken "{", EpToken "}"))
type instance XDecBrG GhcPs       = NoExtField
type instance XTypBr  GhcPs       = (EpToken "[t|", EpUniToken "|]" "⟧")
type instance XVarBr  GhcPs       = EpaLocation
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
forall doc. IsOutput doc => doc
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
forall doc. IsLine doc => Char -> doc
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
forall doc. IsLine doc => Char -> doc
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
forall doc. IsLine doc => Char -> doc
char Char
'd') ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
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
forall doc. IsLine doc => Char -> doc
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
forall doc. IsLine doc => Char -> doc
char Char
'\'' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> 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
forall doc. IsLine doc => String -> doc
text String
"''" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> 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
          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
forall doc. IsLine doc => Char -> doc
char Char
'[' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
pp_kind SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
vbar SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
                             SDoc
pp_body SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"|]"

thTyBrackets :: SDoc -> SDoc
thTyBrackets :: SDoc -> SDoc
thTyBrackets SDoc
pp_body = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[||" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_body SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsDoc doc => doc -> doc -> doc
$$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pending(tc)" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
forall doc. IsLine doc => doc
comma, SDoc
forall doc. IsLine doc => doc
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
forall doc. IsLine doc => [doc] -> doc
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
forall doc. IsLine doc => [doc] -> doc
hcat [GenLocated SrcSpanAnnA (HsExpr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
e1, SDoc
forall doc. IsLine doc => doc
comma, SDoc
forall doc. IsLine doc => doc
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
forall doc. IsLine doc => String -> doc
text String
" .. "

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

type HsMatchContextPs = HsMatchContext (LIdP GhcPs)
type HsMatchContextRn = HsMatchContext (LIdP GhcRn)

type HsStmtContextRn = HsStmtContext (LIdP GhcRn)

instance Outputable fn => Outputable (HsMatchContext fn) where
  ppr :: HsMatchContext fn -> SDoc
ppr m :: HsMatchContext fn
m@(FunRhs{})            = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"FunRhs" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> fn -> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsMatchContext fn -> fn
forall fn. HsMatchContext fn -> fn
mc_fun HsMatchContext fn
m) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> LexicalFixity -> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsMatchContext fn -> LexicalFixity
forall fn. HsMatchContext fn -> LexicalFixity
mc_fixity HsMatchContext fn
m)
  ppr HsMatchContext fn
CaseAlt                 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"CaseAlt"
  ppr (LamAlt HsLamVariant
lam_variant)    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LamAlt" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsLamVariant -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsLamVariant
lam_variant
  ppr HsMatchContext fn
IfAlt                   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"IfAlt"
  ppr (ArrowMatchCtxt HsArrowMatchContext
c)      = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ArrowMatchCtxt" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsArrowMatchContext -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsArrowMatchContext
c
  ppr HsMatchContext fn
PatBindRhs              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"PatBindRhs"
  ppr HsMatchContext fn
PatBindGuards           = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"PatBindGuards"
  ppr HsMatchContext fn
RecUpd                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"RecUpd"
  ppr (StmtCtxt HsStmtContext fn
_)            = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"StmtCtxt _"
  ppr HsMatchContext fn
ThPatSplice             = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ThPatSplice"
  ppr HsMatchContext fn
ThPatQuote              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ThPatQuote"
  ppr HsMatchContext fn
PatSyn                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"PatSyn"
  ppr HsMatchContext fn
LazyPatCtx              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LazyPatCtx"

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

lamCaseKeyword :: HsLamVariant -> SDoc
lamCaseKeyword :: HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
LamSingle = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"lambda"
lamCaseKeyword HsLamVariant
LamCase   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"\\case"
lamCaseKeyword HsLamVariant
LamCases  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"\\cases"

pprExternalSrcLoc :: (StringLiteral,(Int,Int),(Int,Int)) -> SDoc
pprExternalSrcLoc :: (StringLiteral, (Int, Int), (Int, Int)) -> SDoc
pprExternalSrcLoc (StringLiteral SourceText
_ FastString
src Maybe (EpaLocation' NoComments)
_,(Int
n1,Int
n2),(Int
n3,Int
n4))
  = (FastString, (Int, Int), (Int, Int)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (FastString
src,(Int
n1,Int
n2),(Int
n3,Int
n4))

instance Outputable HsArrowMatchContext where
  ppr :: HsArrowMatchContext -> SDoc
ppr HsArrowMatchContext
ProcExpr                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ProcExpr"
  ppr HsArrowMatchContext
ArrowCaseAlt              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ArrowCaseAlt"
  ppr (ArrowLamAlt HsLamVariant
lam_variant) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ArrowLamCaseAlt" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsLamVariant -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsLamVariant
lam_variant

pprHsArrType :: HsArrAppType -> SDoc
pprHsArrType :: HsArrAppType -> SDoc
pprHsArrType HsArrAppType
HsHigherOrderApp = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"higher order arrow application"
pprHsArrType HsArrAppType
HsFirstOrderApp  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"first order arrow application"

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

instance Outputable fn => Outputable (HsStmtContext fn) where
    ppr :: HsStmtContext fn -> SDoc
ppr = HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprStmtContext

-- Used to generate the string for a *runtime* error message
matchContextErrString :: Outputable fn => HsMatchContext fn -> SDoc
matchContextErrString :: forall fn. Outputable fn => HsMatchContext fn -> SDoc
matchContextErrString (FunRhs{mc_fun :: forall fn. HsMatchContext fn -> fn
mc_fun=fn
fun})          = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"function" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> fn -> SDoc
forall a. Outputable a => a -> SDoc
ppr fn
fun
matchContextErrString HsMatchContext fn
CaseAlt                       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case"
matchContextErrString (LamAlt HsLamVariant
lam_variant)          = HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_variant
matchContextErrString HsMatchContext fn
IfAlt                         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"multi-way if"
matchContextErrString HsMatchContext fn
PatBindRhs                    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding"
matchContextErrString HsMatchContext fn
PatBindGuards                 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding guards"
matchContextErrString HsMatchContext fn
RecUpd                        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"record update"
matchContextErrString (ArrowMatchCtxt HsArrowMatchContext
c)            = HsArrowMatchContext -> SDoc
matchArrowContextErrString HsArrowMatchContext
c
matchContextErrString HsMatchContext fn
ThPatSplice                   = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"matchContextErrString"  -- Not used at runtime
matchContextErrString HsMatchContext fn
ThPatQuote                    = String -> SDoc
forall a. HasCallStack => String -> a
panic String
"matchContextErrString"  -- Not used at runtime
matchContextErrString HsMatchContext fn
PatSyn                        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern synonym"
matchContextErrString (StmtCtxt (ParStmtCtxt HsStmtContext fn
c))    = HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
matchContextErrString (HsStmtContext fn -> HsMatchContext fn
forall fn. HsStmtContext fn -> HsMatchContext fn
StmtCtxt HsStmtContext fn
c)
matchContextErrString (StmtCtxt (TransStmtCtxt HsStmtContext fn
c))  = HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
matchContextErrString (HsStmtContext fn -> HsMatchContext fn
forall fn. HsStmtContext fn -> HsMatchContext fn
StmtCtxt HsStmtContext fn
c)
matchContextErrString (StmtCtxt (PatGuard HsMatchContext fn
_))       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern guard"
matchContextErrString (StmtCtxt (HsStmtContext fn
ArrowExpr))        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'do' block"
matchContextErrString (StmtCtxt (HsDoStmt HsDoFlavour
flavour)) = HsDoFlavour -> SDoc
matchDoContextErrString HsDoFlavour
flavour
matchContextErrString HsMatchContext fn
LazyPatCtx                    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"irrefutable pattern"

matchArrowContextErrString :: HsArrowMatchContext -> SDoc
matchArrowContextErrString :: HsArrowMatchContext -> SDoc
matchArrowContextErrString HsArrowMatchContext
ProcExpr                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"proc"
matchArrowContextErrString HsArrowMatchContext
ArrowCaseAlt              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case"
matchArrowContextErrString (ArrowLamAlt HsLamVariant
LamSingle)   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"kappa"
matchArrowContextErrString (ArrowLamAlt HsLamVariant
lam_variant) = HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_variant

matchDoContextErrString :: HsDoFlavour -> SDoc
matchDoContextErrString :: HsDoFlavour -> SDoc
matchDoContextErrString HsDoFlavour
GhciStmtCtxt = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"interactive GHCi command"
matchDoContextErrString (DoExpr Maybe ModuleName
m)   = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'do' block")
matchDoContextErrString (MDoExpr Maybe ModuleName
m)  = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'mdo' block")
matchDoContextErrString HsDoFlavour
ListComp     = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"list comprehension"
matchDoContextErrString HsDoFlavour
MonadComp    = String -> SDoc
forall doc. IsLine doc => String -> doc
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
forall doc. IsLine doc => String -> doc
text String
"In" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsMatchContext
  (GenLocated
     (Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))
-> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContext (Match (GhcPass idR) body
-> HsMatchContext (LIdP (NoGhcTc (GhcPass idR)))
forall p body. Match p body -> HsMatchContext (LIdP (NoGhcTc p))
m_ctxt Match (GhcPass idR) body
match)
                                        SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
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,
                  Outputable fn,
                  Outputable body,
                 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA)
              => HsStmtContext fn
              -> StmtLR (GhcPass idL) (GhcPass idR) body
              -> SDoc
pprStmtInCtxt :: forall (idL :: Pass) (idR :: Pass) fn body.
(OutputableBndrId idL, OutputableBndrId idR, Outputable fn,
 Outputable body,
 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA) =>
HsStmtContext fn -> StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc
pprStmtInCtxt HsStmtContext fn
ctxt (LastStmt XLastStmt (GhcPass idL) (GhcPass idR) body
_ body
e Maybe Bool
_ SyntaxExpr (GhcPass idR)
_)
  | HsStmtContext fn -> Bool
forall fn. HsStmtContext fn -> Bool
isComprehensionContext HsStmtContext fn
ctxt      -- For [ e | .. ], do not mutter about "stmts"
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"In the expression:") Int
2 (body -> SDoc
forall a. Outputable a => a -> SDoc
ppr body
e)

pprStmtInCtxt HsStmtContext fn
ctxt StmtLR (GhcPass idL) (GhcPass idR) body
stmt
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"In a stmt of" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext HsStmtContext fn
ctxt SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
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

pprMatchContext :: Outputable fn => HsMatchContext fn -> SDoc
pprMatchContext :: forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContext HsMatchContext fn
ctxt
  | HsMatchContext fn -> Bool
forall {fn}. HsMatchContext fn -> Bool
want_an HsMatchContext fn
ctxt = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"an" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNoun HsMatchContext fn
ctxt
  | Bool
otherwise    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"a"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNoun HsMatchContext fn
ctxt
  where
    want_an :: HsMatchContext fn -> Bool
want_an (FunRhs {})                              = Bool
True  -- Use "an" in front
    want_an (ArrowMatchCtxt HsArrowMatchContext
ProcExpr)                = Bool
True
    want_an (ArrowMatchCtxt (ArrowLamAlt HsLamVariant
LamSingle)) = Bool
True
    want_an HsMatchContext fn
LazyPatCtx                               = Bool
True
    want_an HsMatchContext fn
_                                        = Bool
False

pprMatchContextNoun :: Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNoun :: forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNoun (FunRhs {mc_fun :: forall fn. HsMatchContext fn -> fn
mc_fun=fn
fun})   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"equation for" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
quotes (fn -> SDoc
forall a. Outputable a => a -> SDoc
ppr fn
fun)
pprMatchContextNoun HsMatchContext fn
CaseAlt                 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case alternative"
pprMatchContextNoun (LamAlt HsLamVariant
LamSingle)      = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"lambda abstraction"
pprMatchContextNoun (LamAlt HsLamVariant
lam_variant)    = HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_variant
                                              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"alternative"
pprMatchContextNoun HsMatchContext fn
IfAlt                   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"multi-way if alternative"
pprMatchContextNoun HsMatchContext fn
RecUpd                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"record update"
pprMatchContextNoun HsMatchContext fn
ThPatSplice             = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Template Haskell pattern splice"
pprMatchContextNoun HsMatchContext fn
ThPatQuote              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Template Haskell pattern quotation"
pprMatchContextNoun HsMatchContext fn
PatBindRhs              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding"
pprMatchContextNoun HsMatchContext fn
PatBindGuards           = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding guards"
pprMatchContextNoun (ArrowMatchCtxt HsArrowMatchContext
c)      = HsArrowMatchContext -> SDoc
pprArrowMatchContextNoun HsArrowMatchContext
c
pprMatchContextNoun (StmtCtxt HsStmtContext fn
ctxt)         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding in"
                                              SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext HsStmtContext fn
ctxt
pprMatchContextNoun HsMatchContext fn
PatSyn                  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern synonym declaration"
pprMatchContextNoun HsMatchContext fn
LazyPatCtx              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"irrefutable pattern"

pprMatchContextNouns :: Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNouns :: forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNouns (FunRhs {mc_fun :: forall fn. HsMatchContext fn -> fn
mc_fun=fn
fun})   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"equations for" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
quotes (fn -> SDoc
forall a. Outputable a => a -> SDoc
ppr fn
fun)
pprMatchContextNouns HsMatchContext fn
PatBindGuards           = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern binding guards"
pprMatchContextNouns (ArrowMatchCtxt HsArrowMatchContext
c)      = HsArrowMatchContext -> SDoc
pprArrowMatchContextNouns HsArrowMatchContext
c
pprMatchContextNouns (StmtCtxt HsStmtContext fn
ctxt)         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern bindings in"
                                               SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext HsStmtContext fn
ctxt
pprMatchContextNouns HsMatchContext fn
ctxt                    = HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContextNoun HsMatchContext fn
ctxt SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
's'

pprArrowMatchContextNoun :: HsArrowMatchContext -> SDoc
pprArrowMatchContextNoun :: HsArrowMatchContext -> SDoc
pprArrowMatchContextNoun HsArrowMatchContext
ProcExpr                     = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"arrow proc pattern"
pprArrowMatchContextNoun HsArrowMatchContext
ArrowCaseAlt                 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case alternative within arrow notation"
pprArrowMatchContextNoun (ArrowLamAlt HsLamVariant
LamSingle)   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"arrow kappa abstraction"
pprArrowMatchContextNoun (ArrowLamAlt HsLamVariant
lam_variant) = HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_variant
                                                     SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"alternative within arrow notation"

pprArrowMatchContextNouns :: HsArrowMatchContext -> SDoc
pprArrowMatchContextNouns :: HsArrowMatchContext -> SDoc
pprArrowMatchContextNouns HsArrowMatchContext
ArrowCaseAlt              = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case alternatives within arrow notation"
pprArrowMatchContextNouns (ArrowLamAlt HsLamVariant
LamSingle)   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"arrow kappa abstractions"
pprArrowMatchContextNouns (ArrowLamAlt HsLamVariant
lam_variant) = HsLamVariant -> SDoc
lamCaseKeyword HsLamVariant
lam_variant
                                                      SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"alternatives within arrow notation"
pprArrowMatchContextNouns HsArrowMatchContext
ctxt                      = HsArrowMatchContext -> SDoc
pprArrowMatchContextNoun HsArrowMatchContext
ctxt SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
's'

-----------------
pprAStmtContext, pprStmtContext :: Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext :: forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext (HsDoStmt HsDoFlavour
flavour) = HsDoFlavour -> SDoc
pprAHsDoFlavour HsDoFlavour
flavour
pprAStmtContext HsStmtContext fn
ctxt = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"a" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprStmtContext HsStmtContext fn
ctxt

-----------------
pprStmtContext :: forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprStmtContext (HsDoStmt HsDoFlavour
flavour) = HsDoFlavour -> SDoc
pprHsDoFlavour HsDoFlavour
flavour
pprStmtContext (PatGuard HsMatchContext fn
ctxt) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern guard for" SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ HsMatchContext fn -> SDoc
forall fn. Outputable fn => HsMatchContext fn -> SDoc
pprMatchContext HsMatchContext fn
ctxt
pprStmtContext HsStmtContext fn
ArrowExpr       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'do' block in an arrow command"

-- Drop the inner contexts when reporting errors, else we get
--     Unexpected transform statement
--     in a transformed branch of
--          transformed branch of
--          transformed branch of monad comprehension
pprStmtContext (ParStmtCtxt HsStmtContext fn
c) =
  SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"parallel branch of", HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext HsStmtContext fn
c])
             (HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprStmtContext HsStmtContext fn
c)
pprStmtContext (TransStmtCtxt HsStmtContext fn
c) =
  SDoc -> SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc -> doc
ifPprDebug ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"transformed branch of", HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprAStmtContext HsStmtContext fn
c])
             (HsStmtContext fn -> SDoc
forall fn. Outputable fn => HsStmtContext fn -> SDoc
pprStmtContext HsStmtContext fn
c)

pprStmtCat :: forall p body . IsPass p => Stmt (GhcPass p) body -> SDoc
pprStmtCat :: forall (p :: Pass) body. IsPass p => Stmt (GhcPass p) body -> SDoc
pprStmtCat (TransStmt {})       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"transform"
pprStmtCat (LastStmt {})        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"return expression"
pprStmtCat (BodyStmt {})        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"body"
pprStmtCat (BindStmt {})        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"binding"
pprStmtCat (LetStmt {})         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"let"
pprStmtCat (RecStmt {})         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"rec"
pprStmtCat (ParStmt {})         = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"parallel"
pprStmtCat (XStmtLR XXStmtLR (GhcPass p) (GhcPass p) body
_)          = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"applicative"

pprAHsDoFlavour, pprHsDoFlavour :: HsDoFlavour -> SDoc
pprAHsDoFlavour :: HsDoFlavour -> SDoc
pprAHsDoFlavour HsDoFlavour
flavour = SDoc
article SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsDoFlavour -> SDoc
pprHsDoFlavour HsDoFlavour
flavour
  where
    pp_an :: SDoc
pp_an = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"an"
    pp_a :: SDoc
pp_a  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"a"
    article :: SDoc
article = case HsDoFlavour
flavour of
                  MDoExpr Maybe ModuleName
Nothing -> SDoc
pp_an
                  HsDoFlavour
GhciStmtCtxt  -> SDoc
pp_an
                  HsDoFlavour
_             -> SDoc
pp_a
pprHsDoFlavour :: HsDoFlavour -> SDoc
pprHsDoFlavour (DoExpr Maybe ModuleName
m)      = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'do' block")
pprHsDoFlavour (MDoExpr Maybe ModuleName
m)     = Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
m (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"'mdo' block")
pprHsDoFlavour HsDoFlavour
ListComp        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"list comprehension"
pprHsDoFlavour HsDoFlavour
MonadComp       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"monad comprehension"
pprHsDoFlavour HsDoFlavour
GhciStmtCtxt    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"interactive GHCi command"

prependQualified :: Maybe ModuleName -> SDoc -> SDoc
prependQualified :: Maybe ModuleName -> SDoc -> SDoc
prependQualified Maybe ModuleName
Nothing  SDoc
t = SDoc
t
prependQualified (Just ModuleName
_) SDoc
t = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"qualified" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
t

{-
************************************************************************
*                                                                      *
FieldLabelStrings
*                                                                      *
************************************************************************
-}

instance (UnXRec p, Outputable (XRec p FieldLabelString)) => Outputable (FieldLabelStrings p) where
  ppr :: FieldLabelStrings p -> SDoc
ppr (FieldLabelStrings [XRec p (DotFieldOcc p)]
flds) =
    [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
dot ((XRec p (DotFieldOcc p) -> SDoc)
-> [XRec p (DotFieldOcc p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (DotFieldOcc p -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DotFieldOcc p -> SDoc)
-> (XRec p (DotFieldOcc p) -> DotFieldOcc p)
-> XRec p (DotFieldOcc p)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @p) [XRec p (DotFieldOcc p)]
flds))

instance (UnXRec p, Outputable (XRec p FieldLabelString)) => OutputableBndr (FieldLabelStrings p) where
  pprInfixOcc :: FieldLabelStrings p -> SDoc
pprInfixOcc = FieldLabelStrings p -> SDoc
forall p.
(UnXRec p, Outputable (XRec p FieldLabelString)) =>
FieldLabelStrings p -> SDoc
pprFieldLabelStrings
  pprPrefixOcc :: FieldLabelStrings p -> SDoc
pprPrefixOcc = FieldLabelStrings p -> SDoc
forall p.
(UnXRec p, Outputable (XRec p FieldLabelString)) =>
FieldLabelStrings p -> SDoc
pprFieldLabelStrings

instance (UnXRec p,  Outputable (XRec p FieldLabelString)) => OutputableBndr (Located (FieldLabelStrings p)) where
  pprInfixOcc :: Located (FieldLabelStrings p) -> SDoc
pprInfixOcc = FieldLabelStrings p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (FieldLabelStrings p -> SDoc)
-> (Located (FieldLabelStrings p) -> FieldLabelStrings p)
-> Located (FieldLabelStrings p)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located (FieldLabelStrings p) -> FieldLabelStrings p
forall l e. GenLocated l e -> e
unLoc
  pprPrefixOcc :: Located (FieldLabelStrings p) -> SDoc
pprPrefixOcc = FieldLabelStrings p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (FieldLabelStrings p -> SDoc)
-> (Located (FieldLabelStrings p) -> FieldLabelStrings p)
-> Located (FieldLabelStrings p)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Located (FieldLabelStrings p) -> FieldLabelStrings p
forall l e. GenLocated l e -> e
unLoc

pprFieldLabelStrings :: forall p. (UnXRec p, Outputable (XRec p FieldLabelString)) => FieldLabelStrings p -> SDoc
pprFieldLabelStrings :: forall p.
(UnXRec p, Outputable (XRec p FieldLabelString)) =>
FieldLabelStrings p -> SDoc
pprFieldLabelStrings (FieldLabelStrings [XRec p (DotFieldOcc p)]
flds) =
    [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hcat (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
dot ((XRec p (DotFieldOcc p) -> SDoc)
-> [XRec p (DotFieldOcc p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (DotFieldOcc p -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DotFieldOcc p -> SDoc)
-> (XRec p (DotFieldOcc p) -> DotFieldOcc p)
-> XRec p (DotFieldOcc p)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @p) [XRec p (DotFieldOcc p)]
flds))

pprPrefixFastString :: FastString -> SDoc
pprPrefixFastString :: FastString -> SDoc
pprPrefixFastString FastString
fs = RdrName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (FastString -> RdrName
mkVarUnqual FastString
fs)

instance UnXRec p => Outputable (DotFieldOcc p) where
  ppr :: DotFieldOcc p -> SDoc
ppr (DotFieldOcc XCDotFieldOcc p
_ XRec p FieldLabelString
s) = (FastString -> SDoc
pprPrefixFastString (FastString -> SDoc)
-> (XRec p FieldLabelString -> FastString)
-> XRec p FieldLabelString
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FieldLabelString -> FastString
field_label (FieldLabelString -> FastString)
-> (XRec p FieldLabelString -> FieldLabelString)
-> XRec p FieldLabelString
-> FastString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @p) XRec p FieldLabelString
s
  ppr XDotFieldOcc{} = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"XDotFieldOcc"

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

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

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

type instance Anno (HsCmdTop (GhcPass p)) = EpAnnCO
type instance Anno [LocatedA (Match (GhcPass p) (LocatedA (HsExpr (GhcPass p))))] = SrcSpanAnnLW
type instance Anno [LocatedA (Match (GhcPass p) (LocatedA (HsCmd  (GhcPass p))))] = SrcSpanAnnLW
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 [LocatedA (Pat (GhcPass p))] = EpaLocation
type instance Anno (GRHS (GhcPass p) (LocatedA (HsExpr (GhcPass p)))) = EpAnnCO
type instance Anno (GRHS (GhcPass p) (LocatedA (HsCmd  (GhcPass p)))) = EpAnnCO
type instance Anno (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr)))) = SrcSpanAnnA

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

type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr))))] = SrcSpanAnnLW

type instance Anno (FieldLabelStrings (GhcPass p)) = EpAnnCO
type instance Anno FieldLabelString                = SrcSpanAnnN

type instance Anno FastString                      = EpAnnCO
  -- Used in HsQuasiQuote and perhaps elsewhere

type instance Anno (DotFieldOcc (GhcPass p))       = EpAnnCO

instance (HasAnnotation (Anno a))
   => WrapXRec (GhcPass p) a where
  wrapXRec :: a -> XRec (GhcPass p) a
wrapXRec = a -> XRec (GhcPass p) a
a -> GenLocated (Anno a) a
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA