{-# 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.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.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.Core.ConLike
import GHC.Unit.Module (ModuleName)
import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Core.Type
import GHC.Builtin.Types (mkTupleStr)
import GHC.Tc.Utils.TcType (TcType, TcTyVar)
import {-# SOURCE #-} GHC.Tc.Types (TcLclEnv)

import GHCi.RemoteTypes ( ForeignRef )
import qualified Language.Haskell.TH 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 (uncons)
import Data.Bifunctor (first)

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

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

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

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

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

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

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

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

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

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

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

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

instance Outputable SyntaxExprRn where
  ppr :: SyntaxExprRn -> SDoc
ppr (SyntaxExprRn HsExpr GhcRn
expr) = HsExpr GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr GhcRn
expr
  ppr SyntaxExprRn
NoSyntaxExprRn      = String -> SDoc
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 = EpAnn [AddEpAnn]
type instance XTypedBracket GhcRn = NoExtField
type instance XTypedBracket GhcTc = HsBracketTc
type instance XUntypedBracket GhcPs = EpAnn [AddEpAnn]
type instance XUntypedBracket GhcRn = [PendingRnSplice] -- See Note [Pending Splices]
                                                        -- Output of the renamer is the *original* renamed expression,
                                                        -- plus _renamed_ splices to be type checked
type instance XUntypedBracket GhcTc = HsBracketTc

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

-- API Annotations types

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

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

type instance XVar           (GhcPass _) = NoExtField

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

type instance XLam           (GhcPass _) = NoExtField

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

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

type instance XVar           (GhcPass _) = NoExtField

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

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

type instance XLam           (GhcPass _) = NoExtField

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

type instance XApp           (GhcPass _) = EpAnnCO

type instance XAppTypeE      GhcPs = NoExtField
type instance XAppTypeE      GhcRn = NoExtField
type instance XAppTypeE      GhcTc = Type

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

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


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

type instance XPar           (GhcPass _) = EpAnnCO

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

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

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

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

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

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

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

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

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

type instance XRecordUpd     GhcPs = EpAnn [AddEpAnn]
type instance XRecordUpd     GhcRn = NoExtField
type instance XRecordUpd     GhcTc = DataConCantHappen
  -- We desugar record updates in the typechecker.
  -- See [Handling overloaded and rebindable constructs],
  -- and [Record Updates] in GHC.Tc.Gen.Expr.

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

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

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

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

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

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

type instance XPragE         (GhcPass _) = NoExtField

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

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

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

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

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

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

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

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

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

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

type instance XXTupArg         (GhcPass _) = DataConCantHappen

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


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

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


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

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

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

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

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

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


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

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

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

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

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

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

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

ppr_expr :: forall p. (OutputableBndrId p)
         => HsExpr (GhcPass p) -> SDoc
ppr_expr :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
ppr_expr (HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v))   = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
v
ppr_expr (HsUnboundVar XUnboundVar (GhcPass p)
_ RdrName
uv) = RdrName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc RdrName
uv
ppr_expr (HsRecSel XRecSel (GhcPass p)
_ FieldOcc (GhcPass p)
f)      = FieldOcc (GhcPass p) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc FieldOcc (GhcPass p)
f
ppr_expr (HsIPVar XIPVar (GhcPass p)
_ HsIPName
v)       = HsIPName -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsIPName
v
ppr_expr (HsOverLabel XOverLabel (GhcPass p)
_ SourceText
s FastString
l) = 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 String
src -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
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)
_ LHsToken "(" (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
e LHsToken ")" (GhcPass p)
_)     = 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)
_ MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches)
  = MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
MatchGroup
  (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
matches

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

ppr_expr (HsCase XCase (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr matches :: MatchGroup (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))
matches@(MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = L SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (Match (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts }))
  = [SDoc] -> SDoc
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
   (SrcAnn NoEpAnns)
   (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      (SrcAnn NoEpAnns)
      (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  (SrcAnn NoEpAnns)
  (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall {a} {p} {l}.
(Outputable a,
 Outputable (XRec p (StmtLR p p (XRec p (HsExpr p)))),
 Outputable (XXGRHS p a)) =>
GenLocated l (GRHS p a) -> SDoc
ppr_alt [LGRHS (GhcPass p) (XRec (GhcPass p) (HsExpr (GhcPass p)))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
alts))
  where ppr_alt :: GenLocated l (GRHS p a) -> SDoc
ppr_alt (L l
_ (GRHS XCGRHS p a
_ [XRec p (StmtLR p p (XRec p (HsExpr p)))]
guards a
expr)) =
          SDoc -> Int -> SDoc -> SDoc
hang SDoc
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)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ expr :: XRec (GhcPass p) (HsExpr (GhcPass p))
expr@(L SrcSpanAnnA
_ (HsLet XLet (GhcPass p)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
_ LHsToken "in" (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
_)))
  = [SDoc] -> SDoc
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)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ 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 SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts)) = HsDoFlavour
-> [LStmt
      (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))]
-> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
HsDoFlavour -> [LStmt (GhcPass p) body] -> SDoc
pprDo HsDoFlavour
do_or_list_comp [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
stmts

ppr_expr (ExplicitList XExplicitList (GhcPass p)
_ [XRec (GhcPass p) (HsExpr (GhcPass p))]
exprs)
  = SDoc -> SDoc
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 -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
rupd_flds = Either [LHsRecUpdField (GhcPass p)] [LHsRecUpdProj (GhcPass p)]
flds })
  = case Either [LHsRecUpdField (GhcPass p)] [LHsRecUpdProj (GhcPass p)]
flds of
      Left [LHsRecUpdField (GhcPass p)]
rbinds -> SDoc -> Int -> SDoc -> SDoc
hang (HsExpr (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr (GhcPass p)
aexp) Int
2 (SDoc -> SDoc
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 (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdField (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
rbinds))))
      Right [LHsRecUpdProj (GhcPass p)]
pbinds -> SDoc -> Int -> SDoc -> SDoc
hang (HsExpr (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsExpr (GhcPass p)
aexp) Int
2 (SDoc -> SDoc
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 (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (HsFieldBind
         (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
         (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated
  SrcSpanAnnA
  (HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr [LHsRecUpdProj (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind
      (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))))]
pbinds))))

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

ppr_expr (HsProjection { proj_flds :: forall p. HsExpr p -> NonEmpty (XRec p (DotFieldOcc p))
proj_flds = NonEmpty (XRec (GhcPass p) (DotFieldOcc (GhcPass p)))
flds }) = SDoc -> SDoc
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 ((GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)) -> SDoc)
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ([GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
 -> [SDoc])
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> a -> b
$ NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)))
-> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p))]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (XRec (GhcPass p) (DotFieldOcc (GhcPass p)))
NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc (GhcPass p)))
flds))))

ppr_expr (ExprWithTySig XExprWithTySig (GhcPass p)
_ XRec (GhcPass p) (HsExpr (GhcPass p))
expr LHsSigWcType (NoGhcTc (GhcPass p))
sig)
  = SDoc -> Int -> SDoc -> SDoc
hang (Int -> SDoc -> SDoc
nest Int
2 (XRec (GhcPass p) (HsExpr (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
LHsExpr (GhcPass p) -> SDoc
ppr_lexpr XRec (GhcPass p) (HsExpr (GhcPass p))
expr) SDoc -> SDoc -> SDoc
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 (GenLocated SrcSpanAnnA (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr GhcRn)
e)
    GhcPass p
GhcTc | HsBracketTc HsQuote GhcRn
_  Type
_ty Maybe QuoteWrapper
_wrap [PendingTcSplice]
ps <- XTypedBracket (GhcPass p)
b ->
      SDoc -> SDoc
thTyBrackets (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated SrcSpanAnnA (HsExpr GhcTc)
e) SDoc -> [PendingTcSplice] -> SDoc
`ppr_with_pending_tc_splices` [PendingTcSplice]
ps
ppr_expr (HsUntypedBracket XUntypedBracket (GhcPass p)
b HsQuote (GhcPass p)
q)
  = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
    GhcPass p
GhcPs -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q
    GhcPass p
GhcRn -> case XUntypedBracket (GhcPass p)
b of
      [] -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q
      XUntypedBracket (GhcPass p)
ps -> HsQuote (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsQuote (GhcPass p)
q SDoc -> SDoc -> SDoc
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 SrcAnn NoEpAnns
_ (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 (XExpr XXExpr (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
  GhcPs -> ppr x
#endif
  GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
  GhcPass p
GhcTc -> XXExprGhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr XXExpr (GhcPass p)
XXExprGhcTc
x

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

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

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

  ppr (HsTick CoreTickish
tickish LHsExpr GhcTc
exp) =
    SDoc -> SDoc -> SDoc
pprTicks (GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
exp) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
      CoreTickish -> SDoc
forall a. Outputable a => a -> SDoc
ppr CoreTickish
tickish SDoc -> SDoc -> SDoc
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_infix_expr :: forall p. (OutputableBndrId p) => HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v))    = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP p
v)
ppr_infix_expr (HsRecSel XRecSel (GhcPass p)
_ FieldOcc (GhcPass p)
f)       = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (FieldOcc (GhcPass p) -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc FieldOcc (GhcPass p)
f)
ppr_infix_expr (HsUnboundVar XUnboundVar (GhcPass p)
_ 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
#if __GLASGOW_HASKELL__ < 901
                                        GhcPs -> Nothing
#endif
                                        GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Maybe SDoc
ppr_infix_expr_rn XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
                                        GhcPass p
GhcTc -> XXExprGhcTc -> Maybe SDoc
ppr_infix_expr_tc XXExpr (GhcPass p)
XXExprGhcTc
x
ppr_infix_expr HsExpr (GhcPass p)
_ = Maybe SDoc
forall a. Maybe a
Nothing

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

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

ppr_apps :: (OutputableBndrId p)
         => HsExpr (GhcPass p)
         -> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
         -> SDoc
ppr_apps :: forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps (HsApp XApp (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
fun) LHsExpr (GhcPass p)
arg)        [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
args
  = HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p)
-> [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
-> SDoc
ppr_apps HsExpr (GhcPass p)
fun (GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
-> Either
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
     (HsWildCardBndrs
        (GhcPass (NoGhcTcPass p))
        (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
forall a b. a -> Either a b
Left LHsExpr (GhcPass p)
GenLocated SrcSpanAnnA (HsExpr (GhcPass p))
arg Either
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
  (HsWildCardBndrs
     (GhcPass (NoGhcTcPass p))
     (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
-> [Either
      (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
      (HsWildCardBndrs
         (GhcPass (NoGhcTcPass p))
         (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
forall a. a -> [a] -> [a]
: [Either (LHsExpr (GhcPass p)) (LHsWcType (NoGhcTc (GhcPass p)))]
[Either
   (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
   (HsWildCardBndrs
      (GhcPass (NoGhcTcPass p))
      (GenLocated SrcSpanAnnA (HsType (GhcPass (NoGhcTcPass p)))))]
args)
ppr_apps (HsAppType XAppTypeE (GhcPass p)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
fun) LHsToken "@" (GhcPass p)
_ 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. PprPrec -> HsLit x -> Bool
hsLitNeedsParens PprPrec
prec HsLit (GhcPass p)
l
    go (HsOverLit XOverLitE (GhcPass p)
_ HsOverLit (GhcPass p)
ol)               = PprPrec -> HsOverLit (GhcPass p) -> Bool
forall x. PprPrec -> HsOverLit x -> Bool
hsOverLitNeedsParens PprPrec
prec HsOverLit (GhcPass p)
ol
    go (HsPar{})                      = Bool
False
    go (HsApp{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (HsAppType {})                 = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (OpApp{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
opPrec
    go (NegApp{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (SectionL{})                   = Bool
True
    go (SectionR{})                   = Bool
True
    -- Special-case unary boxed tuple applications so that they are
    -- parenthesized as `Identity (Solo x)`, not `Identity Solo x` (#18612)
    -- See Note [One-tuples] in GHC.Builtin.Types
    go (ExplicitTuple XExplicitTuple (GhcPass p)
_ [Present{}] Boxity
Boxed)
                                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (ExplicitTuple{})              = Bool
False
    go (ExplicitSum{})                = Bool
False
    go (HsLam{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsLamCase{})                  = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsCase{})                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsIf{})                       = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsMultiIf{})                  = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsLet{})                      = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (HsDo XDo (GhcPass p)
_ HsDoFlavour
sc XRec (GhcPass p) [ExprLStmt (GhcPass p)]
_)
      | HsDoFlavour -> Bool
isDoComprehensionContext HsDoFlavour
sc   = Bool
False
      | Bool
otherwise                     = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
> PprPrec
topPrec
    go (ExplicitList{})               = Bool
False
    go (RecordUpd{})                  = Bool
False
    go (ExprWithTySig{})              = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
sigPrec
    go (ArithSeq{})                   = Bool
False
    go (HsPragE{})                    = PprPrec
prec PprPrec -> PprPrec -> Bool
forall a. Ord a => a -> a -> Bool
>= PprPrec
appPrec
    go (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 (HsRecSel{})                   = Bool
False
    go (HsProjection{})               = Bool
True
    go (HsGetField{})                 = Bool
False
    go (XExpr XXExpr (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
                     GhcPass p
GhcTc -> XXExprGhcTc -> Bool
go_x_tc XXExpr (GhcPass p)
XXExprGhcTc
x
                     GhcPass p
GhcRn -> HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
go_x_rn XXExpr (GhcPass p)
HsExpansion (HsExpr GhcRn) (HsExpr GhcRn)
x
#if __GLASGOW_HASKELL__ <= 900
                     GhcPs -> True
#endif

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

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


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

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

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

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

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

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

isAtomicHsExpr HsExpr (GhcPass p)
_ = Bool
False

instance Outputable (HsPragE (GhcPass p)) where
  ppr :: HsPragE (GhcPass p) -> SDoc
ppr (HsPragSCC (EpAnn AnnPragma
_, SourceText
st) (StringLiteral SourceText
stl FastString
lbl Maybe RealSrcSpan
_)) =
    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
"#-}"


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

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

Let us consider a piece of code like:

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

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

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

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

    ifThenElse 'a' () True

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

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

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

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

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

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

---

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

type instance XCmdWrap    (GhcPass _) = NoExtField

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

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

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

-- | 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)
_ LHsToken "(" (GhcPass p)
_ XRec (GhcPass p) (HsCmd (GhcPass p))
c LHsToken ")" (GhcPass p)
_) = 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 XCmdLam (GhcPass p)
_ MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
matches

ppr_cmd (HsCmdCase XCmdCase (GhcPass p)
_ LHsExpr (GhcPass p)
expr MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
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 (HsCmdLamCase XCmdLamCase (GhcPass p)
_ LamCaseVariant
lc_variant MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
matches)
  = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ LamCaseVariant -> SDoc
lamCaseKeyword LamCaseVariant
lc_variant, Int -> SDoc -> SDoc
nest Int
2 (MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
-> SDoc
forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MatchGroup (GhcPass p) (XRec (GhcPass p) (HsCmd (GhcPass p)))
MatchGroup (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))
matches) ]

ppr_cmd (HsCmdIf XCmdIf (GhcPass p)
_ SyntaxExpr (GhcPass p)
_ LHsExpr (GhcPass p)
e XRec (GhcPass p) (HsCmd (GhcPass p))
ct XRec (GhcPass p) (HsCmd (GhcPass p))
ce)
  = [SDoc] -> SDoc
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)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ cmd :: XRec (GhcPass p) (HsCmd (GhcPass p))
cmd@(L SrcSpanAnnA
_ (HsCmdLet {})))
  = [SDoc] -> SDoc
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)
_ LHsToken "let" (GhcPass p)
_ HsLocalBinds (GhcPass p)
binds LHsToken "in" (GhcPass p)
_ 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 SrcSpanAnnL
_ [GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsCmd (GhcPass p))))]
stmts))  = [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))]
-> SDoc
forall (p :: Pass) body.
(OutputableBndrId p, Outputable body,
 Anno (StmtLR (GhcPass p) (GhcPass p) body) ~ SrcSpanAnnA) =>
[LStmt (GhcPass p) body] -> SDoc
pprArrowExpr [LStmt (GhcPass p) (GenLocated SrcSpanAnnA (HsCmd (GhcPass p)))]
[GenLocated
   SrcSpanAnnA
   (StmtLR
      (GhcPass p)
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsCmd (GhcPass p))))]
stmts

ppr_cmd (HsCmdArrApp XCmdArrApp (GhcPass p)
_ LHsExpr (GhcPass p)
arrow LHsExpr (GhcPass p)
arg HsArrAppType
HsFirstOrderApp Bool
True)
  = [SDoc] -> SDoc
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)
_ (L SrcSpanAnnA
_ HsExpr (GhcPass p)
op) LexicalFixity
ps_fix Maybe Fixity
rn_fix [LHsCmdTop (GhcPass p)]
args)
  | HsVar XVar (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
v) <- HsExpr (GhcPass p)
op
  = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
ppr_cmd_infix IdGhcP p
v
  | GhcPass p
GhcTc <- forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p
  , XExpr (ConLikeTc ConLike
c [Id]
_ [Scaled Type]
_) <- HsExpr (GhcPass p)
op
  = Name -> SDoc
forall a. OutputableBndr a => a -> SDoc
ppr_cmd_infix (ConLike -> Name
conLikeName ConLike
c)
  | Bool
otherwise
  = SDoc
fall_through
  where
    fall_through :: SDoc
fall_through = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
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 (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p)) -> SDoc)
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg(HsCmdTop (GhcPass p) -> SDoc)
-> (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
    -> HsCmdTop (GhcPass p))
-> GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LHsCmdTop (GhcPass p)]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))]
args) SDoc -> SDoc -> SDoc
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
      , Maybe Fixity -> Bool
forall a. Maybe a -> Bool
isJust Maybe Fixity
rn_fix Bool -> Bool -> Bool
|| LexicalFixity
ps_fix LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
      = SDoc -> Int -> SDoc -> SDoc
hang (HsCmdTop (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsCmdTop (GhcPass p) -> SDoc
pprCmdArg (GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
arg1))
           Int
4 ([SDoc] -> SDoc
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 (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
-> HsCmdTop (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsCmdTop (GhcPass p)
GenLocated (SrcAnn NoEpAnns) (HsCmdTop (GhcPass p))
arg2)])
      | Bool
otherwise
      = SDoc
fall_through

ppr_cmd (XCmd XXCmd (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
#if __GLASGOW_HASKELL__ < 811
  GhcPs -> ppr x
  GhcRn -> ppr x
#endif
  GhcPass p
GhcTc -> case XXCmd (GhcPass p)
x of
    HsWrap HsWrapper
w HsCmd GhcTc
cmd -> HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper HsWrapper
w (\Bool
_ -> SDoc -> SDoc
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
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 = EpAnn [AddEpAnn]
type instance XXMatch (GhcPass _) b = DataConCantHappen

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

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

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

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

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

type instance XXGRHSs (GhcPass _) _ = DataConCantHappen

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

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

type instance XXGRHS (GhcPass _) b = DataConCantHappen

pprMatches :: (OutputableBndrId idR, Outputable body)
           => MatchGroup (GhcPass idR) body -> SDoc
pprMatches :: forall (idR :: Pass) body.
(OutputableBndrId idR, Outputable body) =>
MatchGroup (GhcPass idR) body -> SDoc
pprMatches MG { mg_alts :: forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts = XRec (GhcPass idR) [LMatch (GhcPass idR) body]
matches }
    = [SDoc] -> SDoc
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 (GhcPass p)
-> GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
-> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs (HsMatchContext (GhcPass p)
forall p. HsMatchContext p
PatBindRhs :: HsMatchContext (GhcPass p)) GRHSs (GhcPass p) (LHsExpr (GhcPass p))
GRHSs (GhcPass p) (GenLocated SrcSpanAnnA (HsExpr (GhcPass p)))
grhss)]

pprMatch :: (OutputableBndrId idR, Outputable body)
         => Match (GhcPass idR) body -> SDoc
pprMatch :: forall (pr :: Pass) body.
(OutputableBndrId pr, Outputable body) =>
Match (GhcPass pr) body -> SDoc
pprMatch (Match { m_pats :: forall p body. Match p body -> [LPat p]
m_pats = [LPat (GhcPass idR)]
pats, m_ctxt :: forall p body. Match p body -> HsMatchContext p
m_ctxt = HsMatchContext (GhcPass idR)
ctxt, m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs (GhcPass idR) body
grhss })
  = [SDoc] -> SDoc
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 (GhcPass idR) -> GRHSs (GhcPass idR) body -> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext (GhcPass idR)
ctxt GRHSs (GhcPass idR) body
grhss) ]
  where
    (SDoc
herald, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
other_pats)
        = case HsMatchContext (GhcPass idR)
ctxt of
            FunRhs {mc_fun :: forall p. HsMatchContext p -> LIdP (NoGhcTc p)
mc_fun=L Anno (IdGhcP (NoGhcTcPass idR))
_ IdGhcP (NoGhcTcPass idR)
fun, mc_fixity :: forall p. HsMatchContext p -> LexicalFixity
mc_fixity=LexicalFixity
fixity, mc_strictness :: forall p. HsMatchContext p -> SrcStrictness
mc_strictness=SrcStrictness
strictness}
                | SrcStrictness
SrcStrict <- SrcStrictness
strictness
                -> Bool
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
-> (SDoc, [GenLocated SrcSpanAnnA (Pat (GhcPass idR))])
forall a. HasCallStack => Bool -> a -> a
assert ([GenLocated SrcSpanAnnA (Pat (GhcPass idR))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)     -- A strict variable binding
                   (Char -> SDoc
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, [LPat (GhcPass idR)]
[GenLocated SrcSpanAnnA (Pat (GhcPass idR))]
pats)

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

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

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

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

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

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

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

pprGRHSs :: (OutputableBndrId idR, Outputable body)
         => HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs :: forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHSs (GhcPass idR) body -> SDoc
pprGRHSs HsMatchContext passL
ctxt (GRHSs XCGRHSs (GhcPass idR) body
_ [LGRHS (GhcPass idR) body]
grhss HsLocalBinds (GhcPass idR)
binds)
  = [SDoc] -> SDoc
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 passL -> GRHS (GhcPass idR) body -> SDoc
forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext passL
ctxt (GRHS (GhcPass idR) body -> SDoc)
-> (GenLocated
      (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
    -> GRHS (GhcPass idR) body)
-> GenLocated
     (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated
  (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)
-> GRHS (GhcPass idR) body
forall l e. GenLocated l e -> e
unLoc) [LGRHS (GhcPass idR) body]
[GenLocated
   (Anno (GRHS (GhcPass idR) body)) (GRHS (GhcPass idR) body)]
grhss)
  -- Print the "where" even if the contents of the binds is empty. Only
  -- EmptyLocalBinds means no "where" keyword
 SDoc -> SDoc -> SDoc
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 passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS :: forall (idR :: Pass) body passL.
(OutputableBndrId idR, Outputable body) =>
HsMatchContext passL -> GRHS (GhcPass idR) body -> SDoc
pprGRHS HsMatchContext passL
ctxt (GRHS XCGRHS (GhcPass idR) body
_ [] body
body)
 =  HsMatchContext passL -> body -> SDoc
forall body passL.
Outputable body =>
HsMatchContext passL -> body -> SDoc
pp_rhs HsMatchContext passL
ctxt body
body

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pprStmt :: forall idL idR body . (OutputableBndrId idL,
                                  OutputableBndrId idR,
                 Anno (StmtLR (GhcPass idL) (GhcPass idR) body) ~ SrcSpanAnnA,
                                  Outputable body)
        => (StmtLR (GhcPass idL) (GhcPass idR) body) -> SDoc
pprStmt :: forall (pl :: Pass) (pr :: Pass) body.
(OutputableBndrId pl, OutputableBndrId pr,
 Anno (StmtLR (GhcPass pl) (GhcPass pr) body) ~ SrcSpanAnnA,
 Outputable body) =>
StmtLR (GhcPass pl) (GhcPass pr) body -> SDoc
pprStmt (LastStmt XLastStmt (GhcPass idL) (GhcPass idR) body
_ body
expr Maybe Bool
m_dollar_stripped SyntaxExpr (GhcPass idR)
_)
  = SDoc -> SDoc
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 (ApplicativeStmt XApplicativeStmt (GhcPass idL) (GhcPass idR) body
_ [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
args Maybe (SyntaxExpr (GhcPass idR))
mb_join)
  = (PprStyle -> SDoc) -> SDoc
getPprStyle ((PprStyle -> SDoc) -> SDoc) -> (PprStyle -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \PprStyle
style ->
      if PprStyle -> Bool
userStyle PprStyle
style
         then SDoc
pp_for_user
         else SDoc
pp_debug
  where
  -- make all the Applicative stuff invisible in error messages by
  -- flattening the whole ApplicativeStmt nest back to a sequence
  -- of statements.
   pp_for_user :: SDoc
pp_for_user = [SDoc] -> SDoc
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
_ (ApplicativeStmt XApplicativeStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
_ [(SyntaxExpr (GhcPass idL), ApplicativeArg (GhcPass idL))]
args Maybe (SyntaxExpr (GhcPass idL))
_)) = ((SyntaxExprGhc idL, ApplicativeArg (GhcPass idL)) -> [SDoc])
-> [(SyntaxExprGhc idL, ApplicativeArg (GhcPass idL))] -> [SDoc]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprGhc idL, ApplicativeArg (GhcPass idL)) -> [SDoc]
forall a. (a, ApplicativeArg (GhcPass idL)) -> [SDoc]
flattenArg [(SyntaxExpr (GhcPass idL), ApplicativeArg (GhcPass idL))]
[(SyntaxExprGhc idL, ApplicativeArg (GhcPass idL))]
args
   flattenStmt ExprLStmt (GhcPass idL)
stmt = [GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr ExprLStmt (GhcPass idL)
GenLocated
  SrcSpanAnnA
  (StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
stmt]

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

   pp_debug :: SDoc
pp_debug =
     let
         ap_expr :: SDoc
ap_expr = [SDoc] -> SDoc
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 a an. a -> LocatedAn an a
noLocA (XLastStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
-> Maybe Bool
-> SyntaxExpr (GhcPass idL)
-> StmtLR
     (GhcPass idL)
     (GhcPass idL)
     (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt XLastStmt
  (GhcPass idL)
  (GhcPass idL)
  (GenLocated SrcSpanAnnA (HsExpr (GhcPass idL)))
NoExtField
noExtField (HsExpr (GhcPass idL)
-> GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))
forall a an. a -> LocatedAn an a
noLocA HsExpr (GhcPass idL)
return) Maybe Bool
forall a. Maybe a
Nothing SyntaxExpr (GhcPass idL)
forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr)])

pprTransformStmt :: (OutputableBndrId p)
                 => [IdP (GhcPass p)] -> LHsExpr (GhcPass p)
                 -> Maybe (LHsExpr (GhcPass p)) -> SDoc
pprTransformStmt :: forall (p :: Pass).
OutputableBndrId p =>
[IdP (GhcPass p)]
-> LHsExpr (GhcPass p) -> Maybe (LHsExpr (GhcPass p)) -> SDoc
pprTransformStmt [IdP (GhcPass p)]
bndrs LHsExpr (GhcPass p)
using Maybe (LHsExpr (GhcPass p))
by
  = [SDoc] -> SDoc
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