{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE GADTs #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Hs.Utils(
mkHsPar, mkHsApp, mkHsAppWith, mkHsApps, mkHsAppsWith,
mkHsAppType, mkHsAppTypes, mkHsCaseAlt,
mkSimpleMatch, unguardedGRHSs, unguardedRHS,
mkMatchGroup, mkMatch, mkPrefixFunRhs, mkHsLam, mkHsIf,
mkHsWrap, mkLHsWrap, mkHsWrapCo, mkHsWrapCoR, mkLHsWrapCo,
mkHsDictLet, mkHsLams,
mkHsOpApp, mkHsDo, mkHsDoAnns, mkHsComp, mkHsCompAnns, mkHsWrapPat, mkHsWrapPatCo,
mkLHsPar, mkHsCmdWrap, mkLHsCmdWrap,
mkHsCmdIf,
nlHsTyApp, nlHsTyApps, nlHsVar, nl_HsVar, nlHsDataCon,
nlHsLit, nlHsApp, nlHsApps, nlHsSyntaxApps,
nlHsIntLit, nlHsVarApps,
nlHsDo, nlHsOpApp, nlHsLam, nlHsPar, nlHsIf, nlHsCase, nlList,
mkLHsTupleExpr, mkLHsVarTuple, missingTupArg,
mkLocatedList,
mkChunkified, chunkify,
mkFunBind, mkVarBind, mkHsVarBind, mkSimpleGeneratedFunBind, mkTopFunBind,
mkPatSynBind,
isInfixFunBind,
spanHsLocaLBinds,
mkHsIntegral, mkHsFractional, mkHsIsString, mkHsString, mkHsStringPrimLit,
mkHsCharPrimLit,
mkNPat, mkNPlusKPat, nlVarPat, nlLitPat, nlConVarPat, nlConVarPatName, nlConPat,
nlConPatName, nlInfixConPat, nlNullaryConPat, nlWildConPat, nlWildPat,
nlWildPatName, nlTuplePat, mkParPat, nlParPat,
mkBigLHsVarTup, mkBigLHsTup, mkBigLHsVarPatTup, mkBigLHsPatTup,
mkHsAppTy, mkHsAppKindTy,
hsTypeToHsSigType, hsTypeToHsSigWcType, mkClassOpSigs, mkHsSigEnv,
nlHsAppTy, nlHsAppKindTy, nlHsTyVar, nlHsFunTy, nlHsParTy, nlHsTyConApp,
mkTransformStmt, mkTransformByStmt, mkBodyStmt,
mkPsBindStmt, mkRnBindStmt, mkTcBindStmt,
mkLastStmt,
emptyTransStmt, mkGroupUsingStmt, mkGroupByUsingStmt,
emptyRecStmt, emptyRecStmtName, emptyRecStmtId, mkRecStmt,
unitRecStmtTc,
mkLetStmt,
mkUntypedSplice, mkTypedSplice,
mkHsQuasiQuote,
isUnliftedHsBind, isBangedHsBind,
collectLocalBinders, collectHsValBinders, collectHsBindListBinders,
collectHsIdBinders,
collectHsBindsBinders, collectHsBindBinders, collectMethodBinders,
collectPatBinders, collectPatsBinders,
collectLStmtsBinders, collectStmtsBinders,
collectLStmtBinders, collectStmtBinders,
CollectPass(..), CollectFlag(..),
hsLTyClDeclBinders, hsTyClForeignBinders,
hsPatSynSelectors, getPatSynBinds,
hsForeignDeclsBinders, hsGroupBinders, hsDataFamInstBinders,
lStmtsImplicits, hsValBindsImplicits, lPatImplicits
) where
#include "HsVersions.h"
import GHC.Prelude
import GHC.Hs.Decls
import GHC.Hs.Binds
import GHC.Hs.Expr
import GHC.Hs.Pat
import GHC.Hs.Type
import GHC.Hs.Lit
import Language.Haskell.Syntax.Extension
import GHC.Hs.Extension
import GHC.Parser.Annotation
import GHC.Tc.Types.Evidence
import GHC.Core.TyCo.Rep
import GHC.Core.Multiplicity ( pattern Many )
import GHC.Builtin.Types ( unitTy )
import GHC.Tc.Utils.TcType
import GHC.Core.DataCon
import GHC.Core.ConLike
import GHC.Types.Id
import GHC.Types.Name
import GHC.Types.Name.Set hiding ( unitFV )
import GHC.Types.Name.Env
import GHC.Types.Name.Reader
import GHC.Types.Var
import GHC.Types.Basic
import GHC.Types.SrcLoc
import GHC.Types.Fixity
import GHC.Types.SourceText
import GHC.Data.FastString
import GHC.Data.Bag
import GHC.Settings.Constants
import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
import Data.Either
import Data.Function
import Data.List ( partition, deleteBy )
import Data.Proxy
import Data.Data (Data)
mkHsPar :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsPar :: forall (id :: Pass). LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsPar LHsExpr (GhcPass id)
e = forall l e. l -> e -> GenLocated l e
L (forall l e. GenLocated l e -> l
getLoc LHsExpr (GhcPass id)
e) (forall p. XPar p -> LHsExpr p -> HsExpr p
HsPar forall a. EpAnn a
noAnn LHsExpr (GhcPass id)
e)
mkSimpleMatch :: (Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA,
Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan)
=> HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)] -> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkSimpleMatch :: forall (p :: Pass) (body :: * -> *).
(Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA,
Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan) =>
HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkSimpleMatch HsMatchContext (NoGhcTc (GhcPass p))
ctxt [LPat (GhcPass p)]
pats LocatedA (body (GhcPass p))
rhs
= forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc forall a b. (a -> b) -> a -> b
$
Match { m_ext :: XCMatch (GhcPass p) (LocatedA (body (GhcPass p)))
m_ext = forall a. EpAnn a
noAnn, m_ctxt :: HsMatchContext (NoGhcTc (GhcPass p))
m_ctxt = HsMatchContext (NoGhcTc (GhcPass p))
ctxt, m_pats :: [LPat (GhcPass p)]
m_pats = [LPat (GhcPass p)]
pats
, m_grhss :: GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
m_grhss = forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan) =>
SrcSpan
-> LocatedA (body (GhcPass p))
-> EpAnn GrhsAnn
-> GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
unguardedGRHSs (forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
loc) LocatedA (body (GhcPass p))
rhs forall a. EpAnn a
noAnn }
where
loc :: SrcSpanAnnA
loc = case [LPat (GhcPass p)]
pats of
[] -> forall l e. GenLocated l e -> l
getLoc LocatedA (body (GhcPass p))
rhs
(LPat (GhcPass p)
pat:[LPat (GhcPass p)]
_) -> forall a. Semigroup a => SrcAnn a -> SrcAnn a -> SrcAnn a
combineSrcSpansA (forall l e. GenLocated l e -> l
getLoc LPat (GhcPass p)
pat) (forall l e. GenLocated l e -> l
getLoc LocatedA (body (GhcPass p))
rhs)
unguardedGRHSs :: Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan
=> SrcSpan -> LocatedA (body (GhcPass p)) -> EpAnn GrhsAnn
-> GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
unguardedGRHSs :: forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan) =>
SrcSpan
-> LocatedA (body (GhcPass p))
-> EpAnn GrhsAnn
-> GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
unguardedGRHSs SrcSpan
loc LocatedA (body (GhcPass p))
rhs EpAnn GrhsAnn
an
= forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs EpAnnComments
emptyComments (forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan) =>
EpAnn GrhsAnn
-> SrcSpan
-> LocatedA (body (GhcPass p))
-> [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
unguardedRHS EpAnn GrhsAnn
an SrcSpan
loc LocatedA (body (GhcPass p))
rhs) forall (a :: Pass) (b :: Pass).
HsLocalBindsLR (GhcPass a) (GhcPass b)
emptyLocalBinds
unguardedRHS :: Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan
=> EpAnn GrhsAnn -> SrcSpan -> LocatedA (body (GhcPass p))
-> [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
unguardedRHS :: forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan) =>
EpAnn GrhsAnn
-> SrcSpan
-> LocatedA (body (GhcPass p))
-> [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
unguardedRHS EpAnn GrhsAnn
an SrcSpan
loc LocatedA (body (GhcPass p))
rhs = [forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS EpAnn GrhsAnn
an [] LocatedA (body (GhcPass p))
rhs)]
type AnnoBody p body
= ( XMG (GhcPass p) (LocatedA (body (GhcPass p))) ~ NoExtField
, Anno [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))] ~ SrcSpanAnnL
, Anno (Match (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA
)
mkMatchGroup :: AnnoBody p body
=> Origin
-> LocatedL [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup :: forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
origin LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
matches = MG { mg_ext :: XMG (GhcPass p) (LocatedA (body (GhcPass p)))
mg_ext = NoExtField
noExtField
, mg_alts :: XRec (GhcPass p) [LMatch (GhcPass p) (LocatedA (body (GhcPass p)))]
mg_alts = LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
matches
, mg_origin :: Origin
mg_origin = Origin
origin }
mkLocatedList :: Semigroup a
=> [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2]
mkLocatedList :: forall a e2 an.
Semigroup a =>
[GenLocated (SrcAnn a) e2]
-> LocatedAn an [GenLocated (SrcAnn a) e2]
mkLocatedList [] = forall a an. a -> LocatedAn an a
noLocA []
mkLocatedList [GenLocated (SrcAnn a) e2]
ms = forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan forall a b. (a -> b) -> a -> b
$ forall a. SrcSpanAnn' a -> SrcSpan
locA forall a b. (a -> b) -> a -> b
$ forall a e1 e2.
Semigroup a =>
GenLocated (SrcAnn a) e1 -> GenLocated (SrcAnn a) e2 -> SrcAnn a
combineLocsA (forall a. [a] -> a
head [GenLocated (SrcAnn a) e2]
ms) (forall a. [a] -> a
last [GenLocated (SrcAnn a) e2]
ms)) [GenLocated (SrcAnn a) e2]
ms
mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsApp :: forall (id :: Pass).
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsApp LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2 = forall a1 e1 a2 e2 e3 ann.
GenLocated (SrcSpanAnn' a1) e1
-> GenLocated (SrcSpanAnn' a2) e2
-> e3
-> GenLocated (SrcAnn ann) e3
addCLocAA LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2 (forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp EpAnnCO
noComments LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2)
mkHsAppWith
:: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkHsAppWith :: forall (id :: Pass).
(LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkHsAppWith LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkLocated LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2 = LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkLocated LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2 (forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp forall a. EpAnn a
noAnn LHsExpr (GhcPass id)
e1 LHsExpr (GhcPass id)
e2)
mkHsApps
:: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id)
mkHsApps :: forall (id :: Pass).
LHsExpr (GhcPass id)
-> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id)
mkHsApps = forall (id :: Pass).
(LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> [LHsExpr (GhcPass id)]
-> LHsExpr (GhcPass id)
mkHsAppsWith forall a1 e1 a2 e2 e3 ann.
GenLocated (SrcSpanAnn' a1) e1
-> GenLocated (SrcSpanAnn' a2) e2
-> e3
-> GenLocated (SrcAnn ann) e3
addCLocAA
mkHsAppsWith
:: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> [LHsExpr (GhcPass id)]
-> LHsExpr (GhcPass id)
mkHsAppsWith :: forall (id :: Pass).
(LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> [LHsExpr (GhcPass id)]
-> LHsExpr (GhcPass id)
mkHsAppsWith LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkLocated = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (forall (id :: Pass).
(LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id))
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkHsAppWith LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
-> HsExpr (GhcPass id)
-> LHsExpr (GhcPass id)
mkLocated)
mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn
mkHsAppType :: LHsExpr (GhcPass 'Renamed)
-> LHsWcType (GhcPass 'Renamed) -> LHsExpr (GhcPass 'Renamed)
mkHsAppType LHsExpr (GhcPass 'Renamed)
e LHsWcType (GhcPass 'Renamed)
t = forall a1 e1 a2 e2 e3 ann.
GenLocated (SrcSpanAnn' a1) e1
-> GenLocated (SrcSpanAnn' a2) e2
-> e3
-> GenLocated (SrcAnn ann) e3
addCLocAA GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed))
t_body LHsExpr (GhcPass 'Renamed)
e (forall p.
XAppTypeE p -> LHsExpr p -> LHsWcType (NoGhcTc p) -> HsExpr p
HsAppType NoExtField
noExtField LHsExpr (GhcPass 'Renamed)
e HsWildCardBndrs
(GhcPass 'Renamed)
(GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed)))
paren_wct)
where
t_body :: GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed))
t_body = forall pass thing. HsWildCardBndrs pass thing -> thing
hswc_body LHsWcType (GhcPass 'Renamed)
t
paren_wct :: HsWildCardBndrs
(GhcPass 'Renamed)
(GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed)))
paren_wct = LHsWcType (GhcPass 'Renamed)
t { hswc_body :: GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed))
hswc_body = forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
appPrec GenLocated SrcSpanAnnA (HsType (GhcPass 'Renamed))
t_body }
mkHsAppTypes :: LHsExpr GhcRn -> [LHsWcType GhcRn] -> LHsExpr GhcRn
mkHsAppTypes :: LHsExpr (GhcPass 'Renamed)
-> [LHsWcType (GhcPass 'Renamed)] -> LHsExpr (GhcPass 'Renamed)
mkHsAppTypes = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' LHsExpr (GhcPass 'Renamed)
-> LHsWcType (GhcPass 'Renamed) -> LHsExpr (GhcPass 'Renamed)
mkHsAppType
mkHsLam :: (IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ NoExtField)
=> [LPat (GhcPass p)]
-> LHsExpr (GhcPass p)
-> LHsExpr (GhcPass p)
mkHsLam :: forall (p :: Pass).
(IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ NoExtField) =>
[LPat (GhcPass p)] -> LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
mkHsLam [LPat (GhcPass p)]
pats LHsExpr (GhcPass p)
body = forall (id :: Pass). LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsPar (forall l e. l -> e -> GenLocated l e
L (forall l e. GenLocated l e -> l
getLoc LHsExpr (GhcPass p)
body) (forall p. XLam p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLam NoExtField
noExtField MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
matches))
where
matches :: MatchGroup (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
matches = forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
Generated
(forall a an. a -> LocatedAn an a
noLocA [forall (p :: Pass) (body :: * -> *).
(Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA,
Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan) =>
HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkSimpleMatch forall p. HsMatchContext p
LambdaExpr [GenLocated SrcSpanAnnA (Pat (GhcPass p))]
pats' LHsExpr (GhcPass p)
body])
pats' :: [GenLocated SrcSpanAnnA (Pat (GhcPass p))]
pats' = forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
IsPass p =>
PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p)
parenthesizePat PprPrec
appPrec) [LPat (GhcPass p)]
pats
mkHsLams :: [TyVar] -> [EvVar] -> LHsExpr GhcTc -> LHsExpr GhcTc
mkHsLams :: [Id] -> [Id] -> LHsExpr GhcTc -> LHsExpr GhcTc
mkHsLams [Id]
tyvars [Id]
dicts LHsExpr GhcTc
expr = HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap ([Id] -> HsWrapper
mkWpTyLams [Id]
tyvars
HsWrapper -> HsWrapper -> HsWrapper
<.> [Id] -> HsWrapper
mkWpLams [Id]
dicts) LHsExpr GhcTc
expr
mkHsCaseAlt :: (Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan,
Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA)
=> LPat (GhcPass p) -> (LocatedA (body (GhcPass p)))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkHsCaseAlt :: forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan,
Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA) =>
LPat (GhcPass p)
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkHsCaseAlt LPat (GhcPass p)
pat LocatedA (body (GhcPass p))
expr
= forall (p :: Pass) (body :: * -> *).
(Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpanAnnA,
Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan) =>
HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkSimpleMatch forall p. HsMatchContext p
CaseAlt [LPat (GhcPass p)
pat] LocatedA (body (GhcPass p))
expr
nlHsTyApp :: Id -> [Type] -> LHsExpr GhcTc
nlHsTyApp :: Id -> [Type] -> LHsExpr GhcTc
nlHsTyApp Id
fun_id [Type]
tys
= forall a an. a -> LocatedAn an a
noLocA (HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap ([Type] -> HsWrapper
mkWpTyApps [Type]
tys) (forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA Id
fun_id)))
nlHsTyApps :: Id -> [Type] -> [LHsExpr GhcTc] -> LHsExpr GhcTc
nlHsTyApps :: Id -> [Type] -> [LHsExpr GhcTc] -> LHsExpr GhcTc
nlHsTyApps Id
fun_id [Type]
tys [LHsExpr GhcTc]
xs = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsApp (Id -> [Type] -> LHsExpr GhcTc
nlHsTyApp Id
fun_id [Type]
tys) [LHsExpr GhcTc]
xs
mkLHsPar :: IsPass id => LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkLHsPar :: forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkLHsPar le :: LHsExpr (GhcPass id)
le@(L SrcSpanAnnA
loc HsExpr (GhcPass id)
e)
| forall (p :: Pass).
IsPass p =>
PprPrec -> HsExpr (GhcPass p) -> Bool
hsExprNeedsParens PprPrec
appPrec HsExpr (GhcPass id)
e = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (forall p. XPar p -> LHsExpr p -> HsExpr p
HsPar forall a. EpAnn a
noAnn LHsExpr (GhcPass id)
le)
| Bool
otherwise = LHsExpr (GhcPass id)
le
mkParPat :: IsPass p => LPat (GhcPass p) -> LPat (GhcPass p)
mkParPat :: forall (p :: Pass).
IsPass p =>
LPat (GhcPass p) -> LPat (GhcPass p)
mkParPat lp :: LPat (GhcPass p)
lp@(L SrcSpanAnnA
loc Pat (GhcPass p)
p)
| forall (p :: Pass). IsPass p => PprPrec -> Pat (GhcPass p) -> Bool
patNeedsParens PprPrec
appPrec Pat (GhcPass p)
p = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (forall p. XParPat p -> LPat p -> Pat p
ParPat forall a. EpAnn a
noAnn LPat (GhcPass p)
lp)
| Bool
otherwise = LPat (GhcPass p)
lp
nlParPat :: LPat (GhcPass name) -> LPat (GhcPass name)
nlParPat :: forall (name :: Pass). LPat (GhcPass name) -> LPat (GhcPass name)
nlParPat LPat (GhcPass name)
p = forall a an. a -> LocatedAn an a
noLocA (forall p. XParPat p -> LPat p -> Pat p
ParPat forall a. EpAnn a
noAnn LPat (GhcPass name)
p)
mkHsIntegral :: IntegralLit -> HsOverLit GhcPs
mkHsFractional :: FractionalLit -> HsOverLit GhcPs
mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs
mkHsDo :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs
mkHsDoAnns :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> EpAnn AnnList -> HsExpr GhcPs
mkHsComp :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> HsExpr GhcPs
mkHsCompAnns :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> EpAnn AnnList
-> HsExpr GhcPs
mkNPat :: Located (HsOverLit GhcPs) -> Maybe (SyntaxExpr GhcPs) -> EpAnn [AddEpAnn]
-> Pat GhcPs
mkNPlusKPat :: LocatedN RdrName -> Located (HsOverLit GhcPs) -> EpAnn EpaLocation
-> Pat GhcPs
mkLastStmt :: IsPass idR => LocatedA (bodyR (GhcPass idR))
-> StmtLR (GhcPass idL) (GhcPass idR) (LocatedA (bodyR (GhcPass idR)))
mkBodyStmt :: LocatedA (bodyR GhcPs)
-> StmtLR (GhcPass idL) GhcPs (LocatedA (bodyR GhcPs))
mkPsBindStmt :: EpAnn [AddEpAnn] -> LPat GhcPs -> LocatedA (bodyR GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (bodyR GhcPs))
mkRnBindStmt :: LPat GhcRn -> LocatedA (bodyR GhcRn)
-> StmtLR GhcRn GhcRn (LocatedA (bodyR GhcRn))
mkTcBindStmt :: LPat GhcTc -> LocatedA (bodyR GhcTc)
-> StmtLR GhcTc GhcTc (LocatedA (bodyR GhcTc))
emptyRecStmt :: (Anno [GenLocated
(Anno (StmtLR (GhcPass idL) GhcPs bodyR))
(StmtLR (GhcPass idL) GhcPs bodyR)]
~ SrcSpanAnnL)
=> StmtLR (GhcPass idL) GhcPs bodyR
emptyRecStmtName :: (Anno [GenLocated
(Anno (StmtLR GhcRn GhcRn bodyR))
(StmtLR GhcRn GhcRn bodyR)]
~ SrcSpanAnnL)
=> StmtLR GhcRn GhcRn bodyR
emptyRecStmtId :: Stmt GhcTc (LocatedA (HsCmd GhcTc))
mkRecStmt :: (Anno [GenLocated
(Anno (StmtLR (GhcPass idL) GhcPs bodyR))
(StmtLR (GhcPass idL) GhcPs bodyR)]
~ SrcSpanAnnL)
=> EpAnn AnnList
-> LocatedL [LStmtLR (GhcPass idL) GhcPs bodyR]
-> StmtLR (GhcPass idL) GhcPs bodyR
mkHsIntegral :: IntegralLit -> HsOverLit GhcPs
mkHsIntegral IntegralLit
i = forall p. XOverLit p -> OverLitVal -> HsExpr p -> HsOverLit p
OverLit NoExtField
noExtField (IntegralLit -> OverLitVal
HsIntegral IntegralLit
i) forall (p :: Pass). HsExpr (GhcPass p)
noExpr
mkHsFractional :: FractionalLit -> HsOverLit GhcPs
mkHsFractional FractionalLit
f = forall p. XOverLit p -> OverLitVal -> HsExpr p -> HsOverLit p
OverLit NoExtField
noExtField (FractionalLit -> OverLitVal
HsFractional FractionalLit
f) forall (p :: Pass). HsExpr (GhcPass p)
noExpr
mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs
mkHsIsString SourceText
src FastString
s = forall p. XOverLit p -> OverLitVal -> HsExpr p -> HsOverLit p
OverLit NoExtField
noExtField (SourceText -> FastString -> OverLitVal
HsIsString SourceText
src FastString
s) forall (p :: Pass). HsExpr (GhcPass p)
noExpr
mkHsDo :: HsStmtContext (GhcPass 'Renamed)
-> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs
mkHsDo HsStmtContext (GhcPass 'Renamed)
ctxt LocatedL [ExprLStmt GhcPs]
stmts = forall p.
XDo p
-> HsStmtContext (HsDoRn p) -> XRec p [ExprLStmt p] -> HsExpr p
HsDo forall a. EpAnn a
noAnn HsStmtContext (GhcPass 'Renamed)
ctxt LocatedL [ExprLStmt GhcPs]
stmts
mkHsDoAnns :: HsStmtContext (GhcPass 'Renamed)
-> LocatedL [ExprLStmt GhcPs] -> EpAnn AnnList -> HsExpr GhcPs
mkHsDoAnns HsStmtContext (GhcPass 'Renamed)
ctxt LocatedL [ExprLStmt GhcPs]
stmts EpAnn AnnList
anns = forall p.
XDo p
-> HsStmtContext (HsDoRn p) -> XRec p [ExprLStmt p] -> HsExpr p
HsDo EpAnn AnnList
anns HsStmtContext (GhcPass 'Renamed)
ctxt LocatedL [ExprLStmt GhcPs]
stmts
mkHsComp :: HsStmtContext (GhcPass 'Renamed)
-> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsComp HsStmtContext (GhcPass 'Renamed)
ctxt [ExprLStmt GhcPs]
stmts LHsExpr GhcPs
expr = HsStmtContext (GhcPass 'Renamed)
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> EpAnn AnnList
-> HsExpr GhcPs
mkHsCompAnns HsStmtContext (GhcPass 'Renamed)
ctxt [ExprLStmt GhcPs]
stmts LHsExpr GhcPs
expr forall a. EpAnn a
noAnn
mkHsCompAnns :: HsStmtContext (GhcPass 'Renamed)
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> EpAnn AnnList
-> HsExpr GhcPs
mkHsCompAnns HsStmtContext (GhcPass 'Renamed)
ctxt [ExprLStmt GhcPs]
stmts LHsExpr GhcPs
expr EpAnn AnnList
anns = HsStmtContext (GhcPass 'Renamed)
-> LocatedL [ExprLStmt GhcPs] -> EpAnn AnnList -> HsExpr GhcPs
mkHsDoAnns HsStmtContext (GhcPass 'Renamed)
ctxt (forall a e2 an.
Semigroup a =>
[GenLocated (SrcAnn a) e2]
-> LocatedAn an [GenLocated (SrcAnn a) e2]
mkLocatedList ([ExprLStmt GhcPs]
stmts forall a. [a] -> [a] -> [a]
++ [GenLocated
SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
last_stmt])) EpAnn AnnList
anns
where
last_stmt :: GenLocated
SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
last_stmt = forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan forall a b. (a -> b) -> a -> b
$ forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LHsExpr GhcPs
expr) forall a b. (a -> b) -> a -> b
$ forall (idR :: Pass) (bodyR :: * -> *) (idL :: Pass).
IsPass idR =>
LocatedA (bodyR (GhcPass idR))
-> StmtLR
(GhcPass idL) (GhcPass idR) (LocatedA (bodyR (GhcPass idR)))
mkLastStmt LHsExpr GhcPs
expr
mkHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> EpAnn AnnsIf
-> HsExpr GhcPs
mkHsIf :: LHsExpr GhcPs
-> LHsExpr GhcPs -> LHsExpr GhcPs -> EpAnn AnnsIf -> HsExpr GhcPs
mkHsIf LHsExpr GhcPs
c LHsExpr GhcPs
a LHsExpr GhcPs
b EpAnn AnnsIf
anns = forall p. XIf p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsIf EpAnn AnnsIf
anns LHsExpr GhcPs
c LHsExpr GhcPs
a LHsExpr GhcPs
b
mkHsCmdIf :: LHsExpr GhcPs -> LHsCmd GhcPs -> LHsCmd GhcPs -> EpAnn AnnsIf
-> HsCmd GhcPs
mkHsCmdIf :: LHsExpr GhcPs
-> LHsCmd GhcPs -> LHsCmd GhcPs -> EpAnn AnnsIf -> HsCmd GhcPs
mkHsCmdIf LHsExpr GhcPs
c LHsCmd GhcPs
a LHsCmd GhcPs
b EpAnn AnnsIf
anns = forall id.
XCmdIf id
-> SyntaxExpr id
-> LHsExpr id
-> LHsCmd id
-> LHsCmd id
-> HsCmd id
HsCmdIf EpAnn AnnsIf
anns forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr LHsExpr GhcPs
c LHsCmd GhcPs
a LHsCmd GhcPs
b
mkNPat :: Located (HsOverLit GhcPs)
-> Maybe (SyntaxExpr GhcPs) -> EpAnn [AddEpAnn] -> Pat GhcPs
mkNPat Located (HsOverLit GhcPs)
lit Maybe (SyntaxExpr GhcPs)
neg EpAnn [AddEpAnn]
anns = forall p.
XNPat p
-> XRec p (HsOverLit p)
-> Maybe (SyntaxExpr p)
-> SyntaxExpr p
-> Pat p
NPat EpAnn [AddEpAnn]
anns Located (HsOverLit GhcPs)
lit Maybe (SyntaxExpr GhcPs)
neg forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
mkNPlusKPat :: LocatedN RdrName
-> Located (HsOverLit GhcPs) -> EpAnn EpaLocation -> Pat GhcPs
mkNPlusKPat LocatedN RdrName
id Located (HsOverLit GhcPs)
lit EpAnn EpaLocation
anns
= forall p.
XNPlusKPat p
-> LIdP p
-> XRec p (HsOverLit p)
-> HsOverLit p
-> SyntaxExpr p
-> SyntaxExpr p
-> Pat p
NPlusKPat EpAnn EpaLocation
anns LocatedN RdrName
id Located (HsOverLit GhcPs)
lit (forall l e. GenLocated l e -> e
unLoc Located (HsOverLit GhcPs)
lit) forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
mkTransformStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkTransformByStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> LHsExpr GhcPs -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkGroupUsingStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkGroupByUsingStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
-> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt :: EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt :: EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt EpAnn [AddEpAnn]
anns = TransStmt { trS_ext :: XTransStmt GhcPs GhcPs (LocatedA (HsExpr GhcPs))
trS_ext = EpAnn [AddEpAnn]
anns
, trS_form :: TransForm
trS_form = forall a. String -> a
panic String
"emptyTransStmt: form"
, trS_stmts :: [ExprLStmt GhcPs]
trS_stmts = [], trS_bndrs :: [(IdP GhcPs, IdP GhcPs)]
trS_bndrs = []
, trS_by :: Maybe (LHsExpr GhcPs)
trS_by = forall a. Maybe a
Nothing, trS_using :: LHsExpr GhcPs
trS_using = forall a an. a -> LocatedAn an a
noLocA forall (p :: Pass). HsExpr (GhcPass p)
noExpr
, trS_ret :: SyntaxExpr GhcPs
trS_ret = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr, trS_bind :: SyntaxExpr GhcPs
trS_bind = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
, trS_fmap :: HsExpr GhcPs
trS_fmap = forall (p :: Pass). HsExpr (GhcPass p)
noExpr }
mkTransformStmt :: EpAnn [AddEpAnn]
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkTransformStmt EpAnn [AddEpAnn]
a [ExprLStmt GhcPs]
ss LHsExpr GhcPs
u = (EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt EpAnn [AddEpAnn]
a) { trS_form :: TransForm
trS_form = TransForm
ThenForm, trS_stmts :: [ExprLStmt GhcPs]
trS_stmts = [ExprLStmt GhcPs]
ss, trS_using :: LHsExpr GhcPs
trS_using = LHsExpr GhcPs
u }
mkTransformByStmt :: EpAnn [AddEpAnn]
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkTransformByStmt EpAnn [AddEpAnn]
a [ExprLStmt GhcPs]
ss LHsExpr GhcPs
u LHsExpr GhcPs
b = (EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt EpAnn [AddEpAnn]
a) { trS_form :: TransForm
trS_form = TransForm
ThenForm, trS_stmts :: [ExprLStmt GhcPs]
trS_stmts = [ExprLStmt GhcPs]
ss, trS_using :: LHsExpr GhcPs
trS_using = LHsExpr GhcPs
u, trS_by :: Maybe (LHsExpr GhcPs)
trS_by = forall a. a -> Maybe a
Just LHsExpr GhcPs
b }
mkGroupUsingStmt :: EpAnn [AddEpAnn]
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkGroupUsingStmt EpAnn [AddEpAnn]
a [ExprLStmt GhcPs]
ss LHsExpr GhcPs
u = (EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt EpAnn [AddEpAnn]
a) { trS_form :: TransForm
trS_form = TransForm
GroupForm, trS_stmts :: [ExprLStmt GhcPs]
trS_stmts = [ExprLStmt GhcPs]
ss, trS_using :: LHsExpr GhcPs
trS_using = LHsExpr GhcPs
u }
mkGroupByUsingStmt :: EpAnn [AddEpAnn]
-> [ExprLStmt GhcPs]
-> LHsExpr GhcPs
-> LHsExpr GhcPs
-> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
mkGroupByUsingStmt EpAnn [AddEpAnn]
a [ExprLStmt GhcPs]
ss LHsExpr GhcPs
b LHsExpr GhcPs
u = (EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs)
emptyTransStmt EpAnn [AddEpAnn]
a) { trS_form :: TransForm
trS_form = TransForm
GroupForm, trS_stmts :: [ExprLStmt GhcPs]
trS_stmts = [ExprLStmt GhcPs]
ss, trS_using :: LHsExpr GhcPs
trS_using = LHsExpr GhcPs
u, trS_by :: Maybe (LHsExpr GhcPs)
trS_by = forall a. a -> Maybe a
Just LHsExpr GhcPs
b }
mkLastStmt :: forall (idR :: Pass) (bodyR :: * -> *) (idL :: Pass).
IsPass idR =>
LocatedA (bodyR (GhcPass idR))
-> StmtLR
(GhcPass idL) (GhcPass idR) (LocatedA (bodyR (GhcPass idR)))
mkLastStmt LocatedA (bodyR (GhcPass idR))
body = forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt NoExtField
noExtField LocatedA (bodyR (GhcPass idR))
body forall a. Maybe a
Nothing forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
mkBodyStmt :: forall (bodyR :: * -> *) (idL :: Pass).
LocatedA (bodyR GhcPs)
-> StmtLR (GhcPass idL) GhcPs (LocatedA (bodyR GhcPs))
mkBodyStmt LocatedA (bodyR GhcPs)
body
= forall idL idR body.
XBodyStmt idL idR body
-> body -> SyntaxExpr idR -> SyntaxExpr idR -> StmtLR idL idR body
BodyStmt NoExtField
noExtField LocatedA (bodyR GhcPs)
body forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
mkPsBindStmt :: forall (bodyR :: * -> *).
EpAnn [AddEpAnn]
-> LPat GhcPs
-> LocatedA (bodyR GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (bodyR GhcPs))
mkPsBindStmt EpAnn [AddEpAnn]
ann LPat GhcPs
pat LocatedA (bodyR GhcPs)
body = forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt EpAnn [AddEpAnn]
ann LPat GhcPs
pat LocatedA (bodyR GhcPs)
body
mkRnBindStmt :: forall (bodyR :: * -> *).
LPat (GhcPass 'Renamed)
-> LocatedA (bodyR (GhcPass 'Renamed))
-> StmtLR
(GhcPass 'Renamed)
(GhcPass 'Renamed)
(LocatedA (bodyR (GhcPass 'Renamed)))
mkRnBindStmt LPat (GhcPass 'Renamed)
pat LocatedA (bodyR (GhcPass 'Renamed))
body = forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt (XBindStmtRn { xbsrn_bindOp :: SyntaxExpr (GhcPass 'Renamed)
xbsrn_bindOp = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr, xbsrn_failOp :: FailOperator (GhcPass 'Renamed)
xbsrn_failOp = forall a. Maybe a
Nothing }) LPat (GhcPass 'Renamed)
pat LocatedA (bodyR (GhcPass 'Renamed))
body
mkTcBindStmt :: forall (bodyR :: * -> *).
LPat GhcTc
-> LocatedA (bodyR GhcTc)
-> StmtLR GhcTc GhcTc (LocatedA (bodyR GhcTc))
mkTcBindStmt LPat GhcTc
pat LocatedA (bodyR GhcTc)
body = forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt (XBindStmtTc { xbstc_bindOp :: SyntaxExpr GhcTc
xbstc_bindOp = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr,
xbstc_boundResultType :: Type
xbstc_boundResultType = Type
unitTy,
xbstc_boundResultMult :: Type
xbstc_boundResultMult = Type
Many,
xbstc_failOp :: FailOperator GhcTc
xbstc_failOp = forall a. Maybe a
Nothing }) LPat GhcTc
pat LocatedA (bodyR GhcTc)
body
emptyRecStmt' :: forall idL idR body .
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body], IsPass idR)
=> XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' :: forall (idL :: Pass) (idR :: Pass) body.
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body],
IsPass idR) =>
XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' XRecStmt (GhcPass idL) (GhcPass idR) body
tyVal =
RecStmt
{ recS_stmts :: XRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body]
recS_stmts = forall p a. WrapXRec p a => a -> XRec p a
wrapXRec @(GhcPass idR) []
, recS_later_ids :: [IdP (GhcPass idR)]
recS_later_ids = []
, recS_rec_ids :: [IdP (GhcPass idR)]
recS_rec_ids = []
, recS_ret_fn :: SyntaxExpr (GhcPass idR)
recS_ret_fn = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
, recS_mfix_fn :: SyntaxExpr (GhcPass idR)
recS_mfix_fn = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
, recS_bind_fn :: SyntaxExpr (GhcPass idR)
recS_bind_fn = forall (p :: Pass). IsPass p => SyntaxExpr (GhcPass p)
noSyntaxExpr
, recS_ext :: XRecStmt (GhcPass idL) (GhcPass idR) body
recS_ext = XRecStmt (GhcPass idL) (GhcPass idR) body
tyVal }
unitRecStmtTc :: RecStmtTc
unitRecStmtTc :: RecStmtTc
unitRecStmtTc = RecStmtTc { recS_bind_ty :: Type
recS_bind_ty = Type
unitTy
, recS_later_rets :: [HsExpr GhcTc]
recS_later_rets = []
, recS_rec_rets :: [HsExpr GhcTc]
recS_rec_rets = []
, recS_ret_ty :: Type
recS_ret_ty = Type
unitTy }
emptyRecStmt :: forall (idL :: Pass) bodyR.
(Anno
[GenLocated
(Anno (StmtLR (GhcPass idL) GhcPs bodyR))
(StmtLR (GhcPass idL) GhcPs bodyR)]
~ SrcSpanAnn' (EpAnn AnnList)) =>
StmtLR (GhcPass idL) GhcPs bodyR
emptyRecStmt = forall (idL :: Pass) (idR :: Pass) body.
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body],
IsPass idR) =>
XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' forall a. EpAnn a
noAnn
emptyRecStmtName :: forall bodyR.
(Anno
[GenLocated
(Anno (StmtLR (GhcPass 'Renamed) (GhcPass 'Renamed) bodyR))
(StmtLR (GhcPass 'Renamed) (GhcPass 'Renamed) bodyR)]
~ SrcSpanAnn' (EpAnn AnnList)) =>
StmtLR (GhcPass 'Renamed) (GhcPass 'Renamed) bodyR
emptyRecStmtName = forall (idL :: Pass) (idR :: Pass) body.
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body],
IsPass idR) =>
XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' NoExtField
noExtField
emptyRecStmtId :: StmtLR GhcTc GhcTc (LocatedA (HsCmd GhcTc))
emptyRecStmtId = forall (idL :: Pass) (idR :: Pass) body.
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body],
IsPass idR) =>
XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' RecStmtTc
unitRecStmtTc
mkRecStmt :: forall (idL :: Pass) bodyR.
(Anno
[GenLocated
(Anno (StmtLR (GhcPass idL) GhcPs bodyR))
(StmtLR (GhcPass idL) GhcPs bodyR)]
~ SrcSpanAnn' (EpAnn AnnList)) =>
EpAnn AnnList
-> LocatedL [LStmtLR (GhcPass idL) GhcPs bodyR]
-> StmtLR (GhcPass idL) GhcPs bodyR
mkRecStmt EpAnn AnnList
anns LocatedL [LStmtLR (GhcPass idL) GhcPs bodyR]
stmts = (forall (idL :: Pass) (idR :: Pass) body.
(WrapXRec (GhcPass idR) [LStmtLR (GhcPass idL) (GhcPass idR) body],
IsPass idR) =>
XRecStmt (GhcPass idL) (GhcPass idR) body
-> StmtLR (GhcPass idL) (GhcPass idR) body
emptyRecStmt' EpAnn AnnList
anns) { recS_stmts :: XRec GhcPs [LStmtLR (GhcPass idL) GhcPs bodyR]
recS_stmts = LocatedL [LStmtLR (GhcPass idL) GhcPs bodyR]
stmts }
mkLetStmt :: EpAnn [AddEpAnn] -> HsLocalBinds GhcPs -> StmtLR GhcPs GhcPs (LocatedA b)
mkLetStmt :: forall b.
EpAnn [AddEpAnn]
-> HsLocalBinds GhcPs -> StmtLR GhcPs GhcPs (LocatedA b)
mkLetStmt EpAnn [AddEpAnn]
anns HsLocalBinds GhcPs
binds = forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt EpAnn [AddEpAnn]
anns HsLocalBinds GhcPs
binds
mkHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsOpApp LHsExpr GhcPs
e1 IdP GhcPs
op LHsExpr GhcPs
e2 = forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp forall a. EpAnn a
noAnn LHsExpr GhcPs
e1 (forall a an. a -> LocatedAn an a
noLocA (forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA IdP GhcPs
op))) LHsExpr GhcPs
e2
unqualSplice :: RdrName
unqualSplice :: RdrName
unqualSplice = OccName -> RdrName
mkRdrUnqual (FastString -> OccName
mkVarOccFS (String -> FastString
fsLit String
"splice"))
mkUntypedSplice :: EpAnn [AddEpAnn] -> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs
mkUntypedSplice :: EpAnn [AddEpAnn]
-> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs
mkUntypedSplice EpAnn [AddEpAnn]
ann SpliceDecoration
hasParen LHsExpr GhcPs
e = forall id.
XUntypedSplice id
-> SpliceDecoration -> IdP id -> LHsExpr id -> HsSplice id
HsUntypedSplice EpAnn [AddEpAnn]
ann SpliceDecoration
hasParen RdrName
unqualSplice LHsExpr GhcPs
e
mkTypedSplice :: EpAnn [AddEpAnn] -> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs
mkTypedSplice :: EpAnn [AddEpAnn]
-> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs
mkTypedSplice EpAnn [AddEpAnn]
ann SpliceDecoration
hasParen LHsExpr GhcPs
e = forall id.
XTypedSplice id
-> SpliceDecoration -> IdP id -> LHsExpr id -> HsSplice id
HsTypedSplice EpAnn [AddEpAnn]
ann SpliceDecoration
hasParen RdrName
unqualSplice LHsExpr GhcPs
e
mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsSplice GhcPs
mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsSplice GhcPs
mkHsQuasiQuote RdrName
quoter SrcSpan
span FastString
quote
= forall id.
XQuasiQuote id
-> IdP id -> IdP id -> SrcSpan -> FastString -> HsSplice id
HsQuasiQuote NoExtField
noExtField RdrName
unqualSplice RdrName
quoter SrcSpan
span FastString
quote
mkHsString :: String -> HsLit (GhcPass p)
mkHsString :: forall (p :: Pass). String -> HsLit (GhcPass p)
mkHsString String
s = forall x. XHsString x -> FastString -> HsLit x
HsString SourceText
NoSourceText (String -> FastString
mkFastString String
s)
mkHsStringPrimLit :: FastString -> HsLit (GhcPass p)
mkHsStringPrimLit :: forall (p :: Pass). FastString -> HsLit (GhcPass p)
mkHsStringPrimLit FastString
fs = forall x. XHsStringPrim x -> ByteString -> HsLit x
HsStringPrim SourceText
NoSourceText (FastString -> ByteString
bytesFS FastString
fs)
mkHsCharPrimLit :: Char -> HsLit (GhcPass p)
mkHsCharPrimLit :: forall (p :: Pass). Char -> HsLit (GhcPass p)
mkHsCharPrimLit Char
c = forall x. XHsChar x -> Char -> HsLit x
HsChar SourceText
NoSourceText Char
c
nlHsVar :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> LHsExpr (GhcPass p)
nlHsVar :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsExpr (GhcPass p)
nlHsVar IdP (GhcPass p)
n = forall a an. a -> LocatedAn an a
noLocA (forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
n))
nl_HsVar :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> HsExpr (GhcPass p)
nl_HsVar :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> HsExpr (GhcPass p)
nl_HsVar IdP (GhcPass p)
n = forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
n)
nlHsDataCon :: DataCon -> LHsExpr GhcTc
nlHsDataCon :: DataCon -> LHsExpr GhcTc
nlHsDataCon DataCon
con = forall a an. a -> LocatedAn an a
noLocA (forall p. XConLikeOut p -> ConLike -> HsExpr p
HsConLikeOut NoExtField
noExtField (DataCon -> ConLike
RealDataCon DataCon
con))
nlHsLit :: HsLit (GhcPass p) -> LHsExpr (GhcPass p)
nlHsLit :: forall (p :: Pass). HsLit (GhcPass p) -> LHsExpr (GhcPass p)
nlHsLit HsLit (GhcPass p)
n = forall a an. a -> LocatedAn an a
noLocA (forall p. XLitE p -> HsLit p -> HsExpr p
HsLit EpAnnCO
noComments HsLit (GhcPass p)
n)
nlHsIntLit :: Integer -> LHsExpr (GhcPass p)
nlHsIntLit :: forall (p :: Pass). Integer -> LHsExpr (GhcPass p)
nlHsIntLit Integer
n = forall a an. a -> LocatedAn an a
noLocA (forall p. XLitE p -> HsLit p -> HsExpr p
HsLit EpAnnCO
noComments (forall x. XHsInt x -> IntegralLit -> HsLit x
HsInt NoExtField
noExtField (forall a. Integral a => a -> IntegralLit
mkIntegralLit Integer
n)))
nlVarPat :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> LPat (GhcPass p)
nlVarPat :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LPat (GhcPass p)
nlVarPat IdP (GhcPass p)
n = forall a an. a -> LocatedAn an a
noLocA (forall p. XVarPat p -> LIdP p -> Pat p
VarPat NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
n))
nlLitPat :: HsLit GhcPs -> LPat GhcPs
nlLitPat :: HsLit GhcPs -> LPat GhcPs
nlLitPat HsLit GhcPs
l = forall a an. a -> LocatedAn an a
noLocA (forall p. XLitPat p -> HsLit p -> Pat p
LitPat NoExtField
noExtField HsLit GhcPs
l)
nlHsApp :: IsPass id => LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsApp :: forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsApp LHsExpr (GhcPass id)
f LHsExpr (GhcPass id)
x = forall a an. a -> LocatedAn an a
noLocA (forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp EpAnnCO
noComments LHsExpr (GhcPass id)
f (forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkLHsPar LHsExpr (GhcPass id)
x))
nlHsSyntaxApps :: SyntaxExprTc -> [LHsExpr GhcTc]
-> LHsExpr GhcTc
nlHsSyntaxApps :: SyntaxExprTc -> [LHsExpr GhcTc] -> LHsExpr GhcTc
nlHsSyntaxApps (SyntaxExprTc { syn_expr :: SyntaxExprTc -> HsExpr GhcTc
syn_expr = HsExpr GhcTc
fun
, syn_arg_wraps :: SyntaxExprTc -> [HsWrapper]
syn_arg_wraps = [HsWrapper]
arg_wraps
, syn_res_wrap :: SyntaxExprTc -> HsWrapper
syn_res_wrap = HsWrapper
res_wrap }) [LHsExpr GhcTc]
args
= HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap HsWrapper
res_wrap (forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsApp (forall a an. a -> LocatedAn an a
noLocA HsExpr GhcTc
fun) (forall a b c. String -> (a -> b -> c) -> [a] -> [b] -> [c]
zipWithEqual String
"nlHsSyntaxApps"
HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap [HsWrapper]
arg_wraps [LHsExpr GhcTc]
args))
nlHsSyntaxApps SyntaxExprTc
NoSyntaxExprTc [LHsExpr GhcTc]
args = forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"nlHsSyntaxApps" (forall a. Outputable a => a -> SDoc
ppr [LHsExpr GhcTc]
args)
nlHsApps :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> [LHsExpr (GhcPass p)] -> LHsExpr (GhcPass p)
nlHsApps :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> [LHsExpr (GhcPass p)] -> LHsExpr (GhcPass p)
nlHsApps IdP (GhcPass p)
f [LHsExpr (GhcPass p)]
xs = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsApp (forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsExpr (GhcPass p)
nlHsVar IdP (GhcPass p)
f) [LHsExpr (GhcPass p)]
xs
nlHsVarApps :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> [IdP (GhcPass p)] -> LHsExpr (GhcPass p)
nlHsVarApps :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> [IdP (GhcPass p)] -> LHsExpr (GhcPass p)
nlHsVarApps IdP (GhcPass p)
f [IdP (GhcPass p)]
xs = forall a an. a -> LocatedAn an a
noLocA (forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall {p} {an}.
(XApp p ~ EpAnnCO,
XRec p (HsExpr p) ~ GenLocated (SrcAnn an) (HsExpr p)) =>
HsExpr p -> HsExpr p -> HsExpr p
mk (forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
f))
(forall a b. (a -> b) -> [a] -> [b]
map ((forall p. XVar p -> LIdP p -> HsExpr p
HsVar NoExtField
noExtField) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a an. a -> LocatedAn an a
noLocA) [IdP (GhcPass p)]
xs))
where
mk :: HsExpr p -> HsExpr p -> HsExpr p
mk HsExpr p
f HsExpr p
a = forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp EpAnnCO
noComments (forall a an. a -> LocatedAn an a
noLocA HsExpr p
f) (forall a an. a -> LocatedAn an a
noLocA HsExpr p
a)
nlConVarPat :: RdrName -> [RdrName] -> LPat GhcPs
nlConVarPat :: RdrName -> [RdrName] -> LPat GhcPs
nlConVarPat RdrName
con [RdrName]
vars = RdrName -> [LPat GhcPs] -> LPat GhcPs
nlConPat RdrName
con (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LPat (GhcPass p)
nlVarPat [RdrName]
vars)
nlConVarPatName :: Name -> [Name] -> LPat GhcRn
nlConVarPatName :: Name -> [Name] -> LPat (GhcPass 'Renamed)
nlConVarPatName Name
con [Name]
vars = Name -> [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
nlConPatName Name
con (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LPat (GhcPass p)
nlVarPat [Name]
vars)
nlInfixConPat :: RdrName -> LPat GhcPs -> LPat GhcPs -> LPat GhcPs
nlInfixConPat :: RdrName -> LPat GhcPs -> LPat GhcPs -> LPat GhcPs
nlInfixConPat RdrName
con LPat GhcPs
l LPat GhcPs
r = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ ConPat
{ pat_con :: XRec GhcPs (ConLikeP GhcPs)
pat_con = forall a an. a -> LocatedAn an a
noLocA RdrName
con
, pat_args :: HsConPatDetails GhcPs
pat_args = forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon (forall (p :: Pass).
IsPass p =>
PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p)
parenthesizePat PprPrec
opPrec LPat GhcPs
l)
(forall (p :: Pass).
IsPass p =>
PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p)
parenthesizePat PprPrec
opPrec LPat GhcPs
r)
, pat_con_ext :: XConPat GhcPs
pat_con_ext = forall a. EpAnn a
noAnn
}
nlConPat :: RdrName -> [LPat GhcPs] -> LPat GhcPs
nlConPat :: RdrName -> [LPat GhcPs] -> LPat GhcPs
nlConPat RdrName
con [LPat GhcPs]
pats = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ ConPat
{ pat_con_ext :: XConPat GhcPs
pat_con_ext = forall a. EpAnn a
noAnn
, pat_con :: XRec GhcPs (ConLikeP GhcPs)
pat_con = forall a an. a -> LocatedAn an a
noLocA RdrName
con
, pat_args :: HsConPatDetails GhcPs
pat_args = forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [] (forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
IsPass p =>
PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p)
parenthesizePat PprPrec
appPrec) [LPat GhcPs]
pats)
}
nlConPatName :: Name -> [LPat GhcRn] -> LPat GhcRn
nlConPatName :: Name -> [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
nlConPatName Name
con [LPat (GhcPass 'Renamed)]
pats = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ ConPat
{ pat_con_ext :: XConPat (GhcPass 'Renamed)
pat_con_ext = NoExtField
noExtField
, pat_con :: XRec (GhcPass 'Renamed) (ConLikeP (GhcPass 'Renamed))
pat_con = forall a an. a -> LocatedAn an a
noLocA Name
con
, pat_args :: HsConPatDetails (GhcPass 'Renamed)
pat_args = forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [] (forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
IsPass p =>
PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p)
parenthesizePat PprPrec
appPrec) [LPat (GhcPass 'Renamed)]
pats)
}
nlNullaryConPat :: RdrName -> LPat GhcPs
nlNullaryConPat :: RdrName -> LPat GhcPs
nlNullaryConPat RdrName
con = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ ConPat
{ pat_con_ext :: XConPat GhcPs
pat_con_ext = forall a. EpAnn a
noAnn
, pat_con :: XRec GhcPs (ConLikeP GhcPs)
pat_con = forall a an. a -> LocatedAn an a
noLocA RdrName
con
, pat_args :: HsConPatDetails GhcPs
pat_args = forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [] []
}
nlWildConPat :: DataCon -> LPat GhcPs
nlWildConPat :: DataCon -> LPat GhcPs
nlWildConPat DataCon
con = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ ConPat
{ pat_con_ext :: XConPat GhcPs
pat_con_ext = forall a. EpAnn a
noAnn
, pat_con :: XRec GhcPs (ConLikeP GhcPs)
pat_con = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ forall thing. NamedThing thing => thing -> RdrName
getRdrName DataCon
con
, pat_args :: HsConPatDetails GhcPs
pat_args = forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [] forall a b. (a -> b) -> a -> b
$
forall a. Int -> a -> [a]
replicate (DataCon -> Int
dataConSourceArity DataCon
con)
LPat GhcPs
nlWildPat
}
nlWildPat :: LPat GhcPs
nlWildPat :: LPat GhcPs
nlWildPat = forall a an. a -> LocatedAn an a
noLocA (forall p. XWildPat p -> Pat p
WildPat NoExtField
noExtField )
nlWildPatName :: LPat GhcRn
nlWildPatName :: LPat (GhcPass 'Renamed)
nlWildPatName = forall a an. a -> LocatedAn an a
noLocA (forall p. XWildPat p -> Pat p
WildPat NoExtField
noExtField )
nlHsDo :: HsStmtContext GhcRn -> [LStmt GhcPs (LHsExpr GhcPs)]
-> LHsExpr GhcPs
nlHsDo :: HsStmtContext (GhcPass 'Renamed)
-> [ExprLStmt GhcPs] -> LHsExpr GhcPs
nlHsDo HsStmtContext (GhcPass 'Renamed)
ctxt [ExprLStmt GhcPs]
stmts = forall a an. a -> LocatedAn an a
noLocA (HsStmtContext (GhcPass 'Renamed)
-> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs
mkHsDo HsStmtContext (GhcPass 'Renamed)
ctxt (forall a an. a -> LocatedAn an a
noLocA [ExprLStmt GhcPs]
stmts))
nlHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
nlHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
nlHsOpApp LHsExpr GhcPs
e1 IdP GhcPs
op LHsExpr GhcPs
e2 = forall a an. a -> LocatedAn an a
noLocA (LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsOpApp LHsExpr GhcPs
e1 IdP GhcPs
op LHsExpr GhcPs
e2)
nlHsLam :: LMatch GhcPs (LHsExpr GhcPs) -> LHsExpr GhcPs
nlHsPar :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsCase :: LHsExpr GhcPs -> [LMatch GhcPs (LHsExpr GhcPs)]
-> LHsExpr GhcPs
nlList :: [LHsExpr GhcPs] -> LHsExpr GhcPs
nlHsLam :: LMatch GhcPs (LHsExpr GhcPs) -> LHsExpr GhcPs
nlHsLam LMatch GhcPs (LHsExpr GhcPs)
match = forall a an. a -> LocatedAn an a
noLocA (forall p. XLam p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLam NoExtField
noExtField (forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
Generated (forall a an. a -> LocatedAn an a
noLocA [LMatch GhcPs (LHsExpr GhcPs)
match])))
nlHsPar :: forall (id :: Pass). LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
nlHsPar LHsExpr (GhcPass id)
e = forall a an. a -> LocatedAn an a
noLocA (forall p. XPar p -> LHsExpr p -> HsExpr p
HsPar forall a. EpAnn a
noAnn LHsExpr (GhcPass id)
e)
nlHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
nlHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
nlHsIf LHsExpr GhcPs
cond LHsExpr GhcPs
true LHsExpr GhcPs
false = forall a an. a -> LocatedAn an a
noLocA (forall p. XIf p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsIf forall a. EpAnn a
noAnn LHsExpr GhcPs
cond LHsExpr GhcPs
true LHsExpr GhcPs
false)
nlHsCase :: LHsExpr GhcPs -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs
nlHsCase LHsExpr GhcPs
expr [LMatch GhcPs (LHsExpr GhcPs)]
matches
= forall a an. a -> LocatedAn an a
noLocA (forall p.
XCase p -> LHsExpr p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsCase forall a. EpAnn a
noAnn LHsExpr GhcPs
expr (forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
Generated (forall a an. a -> LocatedAn an a
noLocA [LMatch GhcPs (LHsExpr GhcPs)]
matches)))
nlList :: [LHsExpr GhcPs] -> LHsExpr GhcPs
nlList [LHsExpr GhcPs]
exprs = forall a an. a -> LocatedAn an a
noLocA (forall p. XExplicitList p -> [LHsExpr p] -> HsExpr p
ExplicitList forall a. EpAnn a
noAnn [LHsExpr GhcPs]
exprs)
nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsTyVar :: IsSrcSpanAnn p a
=> IdP (GhcPass p) -> LHsType (GhcPass p)
nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsAppTy :: forall (p :: Pass).
LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsAppTy LHsType (GhcPass p)
f LHsType (GhcPass p)
t = forall a an. a -> LocatedAn an a
noLocA (forall pass.
XAppTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppTy NoExtField
noExtField LHsType (GhcPass p)
f (forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
appPrec LHsType (GhcPass p)
t))
nlHsTyVar :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsType (GhcPass p)
nlHsTyVar IdP (GhcPass p)
x = forall a an. a -> LocatedAn an a
noLocA (forall pass.
XTyVar pass -> PromotionFlag -> LIdP pass -> HsType pass
HsTyVar forall a. EpAnn a
noAnn PromotionFlag
NotPromoted (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
x))
nlHsFunTy :: forall (p :: Pass).
LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsFunTy LHsType (GhcPass p)
a LHsType (GhcPass p)
b = forall a an. a -> LocatedAn an a
noLocA (forall pass.
XFunTy pass
-> HsArrow pass -> LHsType pass -> LHsType pass -> HsType pass
HsFunTy forall a. EpAnn a
noAnn (forall pass. IsUnicodeSyntax -> HsArrow pass
HsUnrestrictedArrow IsUnicodeSyntax
NormalSyntax) (forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
funPrec LHsType (GhcPass p)
a) LHsType (GhcPass p)
b)
nlHsParTy :: forall (p :: Pass). LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsParTy LHsType (GhcPass p)
t = forall a an. a -> LocatedAn an a
noLocA (forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy forall a. EpAnn a
noAnn LHsType (GhcPass p)
t)
nlHsTyConApp :: IsSrcSpanAnn p a
=> LexicalFixity -> IdP (GhcPass p)
-> [LHsTypeArg (GhcPass p)] -> LHsType (GhcPass p)
nlHsTyConApp :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
LexicalFixity
-> IdP (GhcPass p)
-> [LHsTypeArg (GhcPass p)]
-> LHsType (GhcPass p)
nlHsTyConApp LexicalFixity
fixity IdP (GhcPass p)
tycon [LHsTypeArg (GhcPass p)]
tys
| LexicalFixity
Infix <- LexicalFixity
fixity
, HsValArg LHsType (GhcPass p)
ty1 : HsValArg LHsType (GhcPass p)
ty2 : [LHsTypeArg (GhcPass p)]
rest <- [LHsTypeArg (GhcPass p)]
tys
= forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (p :: Pass).
LHsType (GhcPass p)
-> LHsTypeArg (GhcPass p) -> LHsType (GhcPass p)
mk_app (forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ forall pass.
XOpTy pass
-> LHsType pass -> LIdP pass -> LHsType pass -> HsType pass
HsOpTy NoExtField
noExtField LHsType (GhcPass p)
ty1 (forall a an. a -> LocatedAn an a
noLocA IdP (GhcPass p)
tycon) LHsType (GhcPass p)
ty2) [LHsTypeArg (GhcPass p)]
rest
| Bool
otherwise
= forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (p :: Pass).
LHsType (GhcPass p)
-> LHsTypeArg (GhcPass p) -> LHsType (GhcPass p)
mk_app (forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsType (GhcPass p)
nlHsTyVar IdP (GhcPass p)
tycon) [LHsTypeArg (GhcPass p)]
tys
where
mk_app :: LHsType (GhcPass p) -> LHsTypeArg (GhcPass p) -> LHsType (GhcPass p)
mk_app :: forall (p :: Pass).
LHsType (GhcPass p)
-> LHsTypeArg (GhcPass p) -> LHsType (GhcPass p)
mk_app fun :: LHsType (GhcPass p)
fun@(L SrcSpanAnnA
_ (HsOpTy {})) LHsTypeArg (GhcPass p)
arg = forall (p :: Pass).
LHsType (GhcPass p)
-> LHsTypeArg (GhcPass p) -> LHsType (GhcPass p)
mk_app (forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy forall a. EpAnn a
noAnn LHsType (GhcPass p)
fun) LHsTypeArg (GhcPass p)
arg
mk_app LHsType (GhcPass p)
fun (HsValArg LHsType (GhcPass p)
ty) = forall a an. a -> LocatedAn an a
noLocA (forall pass.
XAppTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppTy NoExtField
noExtField LHsType (GhcPass p)
fun (forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
appPrec LHsType (GhcPass p)
ty))
mk_app LHsType (GhcPass p)
fun (HsTypeArg SrcSpan
_ LHsType (GhcPass p)
ki) = forall a an. a -> LocatedAn an a
noLocA (forall pass.
XAppKindTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppKindTy SrcSpan
noSrcSpan LHsType (GhcPass p)
fun (forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
appPrec LHsType (GhcPass p)
ki))
mk_app LHsType (GhcPass p)
fun (HsArgPar SrcSpan
_) = forall a an. a -> LocatedAn an a
noLocA (forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy forall a. EpAnn a
noAnn LHsType (GhcPass p)
fun)
nlHsAppKindTy ::
LHsType (GhcPass p) -> LHsKind (GhcPass p) -> LHsType (GhcPass p)
nlHsAppKindTy :: forall (p :: Pass).
LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsAppKindTy LHsType (GhcPass p)
f LHsType (GhcPass p)
k
= forall a an. a -> LocatedAn an a
noLocA (forall pass.
XAppKindTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppKindTy SrcSpan
noSrcSpan LHsType (GhcPass p)
f (forall (p :: Pass).
PprPrec -> LHsType (GhcPass p) -> LHsType (GhcPass p)
parenthesizeHsType PprPrec
appPrec LHsType (GhcPass p)
k))
mkLHsTupleExpr :: [LHsExpr (GhcPass p)] -> XExplicitTuple (GhcPass p)
-> LHsExpr (GhcPass p)
mkLHsTupleExpr :: forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkLHsTupleExpr [LHsExpr (GhcPass p)
e] XExplicitTuple (GhcPass p)
_ = LHsExpr (GhcPass p)
e
mkLHsTupleExpr [LHsExpr (GhcPass p)]
es XExplicitTuple (GhcPass p)
ext
= forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ forall p. XExplicitTuple p -> [HsTupArg p] -> Boxity -> HsExpr p
ExplicitTuple XExplicitTuple (GhcPass p)
ext (forall a b. (a -> b) -> [a] -> [b]
map (forall id. XPresent id -> LHsExpr id -> HsTupArg id
Present forall a. EpAnn a
noAnn) [LHsExpr (GhcPass p)]
es) Boxity
Boxed
mkLHsVarTuple :: IsSrcSpanAnn p a
=> [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p)
-> LHsExpr (GhcPass p)
mkLHsVarTuple :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
[IdP (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkLHsVarTuple [IdP (GhcPass p)]
ids XExplicitTuple (GhcPass p)
ext = forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkLHsTupleExpr (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsExpr (GhcPass p)
nlHsVar [IdP (GhcPass p)]
ids) XExplicitTuple (GhcPass p)
ext
nlTuplePat :: [LPat GhcPs] -> Boxity -> LPat GhcPs
nlTuplePat :: [LPat GhcPs] -> Boxity -> LPat GhcPs
nlTuplePat [LPat GhcPs]
pats Boxity
box = forall a an. a -> LocatedAn an a
noLocA (forall p. XTuplePat p -> [LPat p] -> Boxity -> Pat p
TuplePat forall a. EpAnn a
noAnn [LPat GhcPs]
pats Boxity
box)
missingTupArg :: EpAnn EpaLocation -> HsTupArg GhcPs
missingTupArg :: EpAnn EpaLocation -> HsTupArg GhcPs
missingTupArg EpAnn EpaLocation
ann = forall id. XMissing id -> HsTupArg id
Missing EpAnn EpaLocation
ann
mkLHsPatTup :: [LPat GhcRn] -> LPat GhcRn
mkLHsPatTup :: [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
mkLHsPatTup [] = forall a an. a -> LocatedAn an a
noLocA forall a b. (a -> b) -> a -> b
$ forall p. XTuplePat p -> [LPat p] -> Boxity -> Pat p
TuplePat NoExtField
noExtField [] Boxity
Boxed
mkLHsPatTup [LPat (GhcPass 'Renamed)
lpat] = LPat (GhcPass 'Renamed)
lpat
mkLHsPatTup [LPat (GhcPass 'Renamed)]
lpats = forall l e. l -> e -> GenLocated l e
L (forall l e. GenLocated l e -> l
getLoc (forall a. [a] -> a
head [LPat (GhcPass 'Renamed)]
lpats)) forall a b. (a -> b) -> a -> b
$ forall p. XTuplePat p -> [LPat p] -> Boxity -> Pat p
TuplePat NoExtField
noExtField [LPat (GhcPass 'Renamed)]
lpats Boxity
Boxed
mkBigLHsVarTup :: IsSrcSpanAnn p a
=> [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p)
-> LHsExpr (GhcPass p)
mkBigLHsVarTup :: forall (p :: Pass) a.
IsSrcSpanAnn p a =>
[IdP (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkBigLHsVarTup [IdP (GhcPass p)]
ids XExplicitTuple (GhcPass p)
anns = forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkBigLHsTup (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LHsExpr (GhcPass p)
nlHsVar [IdP (GhcPass p)]
ids) XExplicitTuple (GhcPass p)
anns
mkBigLHsTup :: [LHsExpr (GhcPass id)] -> XExplicitTuple (GhcPass id)
-> LHsExpr (GhcPass id)
mkBigLHsTup :: forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkBigLHsTup [LHsExpr (GhcPass id)]
es XExplicitTuple (GhcPass id)
anns = forall a. ([a] -> a) -> [a] -> a
mkChunkified (\[GenLocated SrcSpanAnnA (HsExpr (GhcPass id))]
e -> forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkLHsTupleExpr [GenLocated SrcSpanAnnA (HsExpr (GhcPass id))]
e XExplicitTuple (GhcPass id)
anns) [LHsExpr (GhcPass id)]
es
mkBigLHsVarPatTup :: [IdP GhcRn] -> LPat GhcRn
mkBigLHsVarPatTup :: [IdP (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
mkBigLHsVarPatTup [IdP (GhcPass 'Renamed)]
bs = [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
mkBigLHsPatTup (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass) a.
IsSrcSpanAnn p a =>
IdP (GhcPass p) -> LPat (GhcPass p)
nlVarPat [IdP (GhcPass 'Renamed)]
bs)
mkBigLHsPatTup :: [LPat GhcRn] -> LPat GhcRn
mkBigLHsPatTup :: [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
mkBigLHsPatTup = forall a. ([a] -> a) -> [a] -> a
mkChunkified [LPat (GhcPass 'Renamed)] -> LPat (GhcPass 'Renamed)
mkLHsPatTup
mkChunkified :: ([a] -> a)
-> [a]
-> a
mkChunkified :: forall a. ([a] -> a) -> [a] -> a
mkChunkified [a] -> a
small_tuple [a]
as = [[a]] -> a
mk_big_tuple (forall a. [a] -> [[a]]
chunkify [a]
as)
where
mk_big_tuple :: [[a]] -> a
mk_big_tuple [[a]
as] = [a] -> a
small_tuple [a]
as
mk_big_tuple [[a]]
as_s = [[a]] -> a
mk_big_tuple (forall a. [a] -> [[a]]
chunkify (forall a b. (a -> b) -> [a] -> [b]
map [a] -> a
small_tuple [[a]]
as_s))
chunkify :: [a] -> [[a]]
chunkify :: forall a. [a] -> [[a]]
chunkify [a]
xs
| Int
n_xs forall a. Ord a => a -> a -> Bool
<= Int
mAX_TUPLE_SIZE = [[a]
xs]
| Bool
otherwise = forall a. [a] -> [[a]]
split [a]
xs
where
n_xs :: Int
n_xs = forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs
split :: [a] -> [[a]]
split [] = []
split [a]
xs = forall a. Int -> [a] -> [a]
take Int
mAX_TUPLE_SIZE [a]
xs forall a. a -> [a] -> [a]
: [a] -> [[a]]
split (forall a. Int -> [a] -> [a]
drop Int
mAX_TUPLE_SIZE [a]
xs)
hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs
hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs
hsTypeToHsSigType lty :: LHsType GhcPs
lty@(L SrcSpanAnnA
loc HsType GhcPs
ty) = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc forall a b. (a -> b) -> a -> b
$ case HsType GhcPs
ty of
HsForAllTy { hst_tele :: forall pass. HsType pass -> HsForAllTelescope pass
hst_tele = HsForAllInvis { hsf_xinvis :: forall pass. HsForAllTelescope pass -> XHsForAllInvis pass
hsf_xinvis = XHsForAllInvis GhcPs
an
, hsf_invis_bndrs :: forall pass.
HsForAllTelescope pass -> [LHsTyVarBndr Specificity pass]
hsf_invis_bndrs = [LHsTyVarBndr Specificity GhcPs]
bndrs }
, hst_body :: forall pass. HsType pass -> LHsType pass
hst_body = LHsType GhcPs
body }
-> EpAnnForallTy
-> [LHsTyVarBndr Specificity GhcPs]
-> LHsType GhcPs
-> HsSigType GhcPs
mkHsExplicitSigType XHsForAllInvis GhcPs
an [LHsTyVarBndr Specificity GhcPs]
bndrs LHsType GhcPs
body
HsType GhcPs
_ -> LHsType GhcPs -> HsSigType GhcPs
mkHsImplicitSigType LHsType GhcPs
lty
hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs
hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs
hsTypeToHsSigWcType = forall thing. thing -> HsWildCardBndrs GhcPs thing
mkHsWildCardBndrs forall b c a. (b -> c) -> (a -> b) -> a -> c
. LHsType GhcPs -> LHsSigType GhcPs
hsTypeToHsSigType
mkHsSigEnv :: forall a. (LSig GhcRn -> Maybe ([LocatedN Name], a))
-> [LSig GhcRn]
-> NameEnv a
mkHsSigEnv :: forall a.
(LSig (GhcPass 'Renamed)
-> Maybe ([GenLocated SrcSpanAnnN Name], a))
-> [LSig (GhcPass 'Renamed)] -> NameEnv a
mkHsSigEnv LSig (GhcPass 'Renamed) -> Maybe ([GenLocated SrcSpanAnnN Name], a)
get_info [LSig (GhcPass 'Renamed)]
sigs
= forall a. [(Name, a)] -> NameEnv a
mkNameEnv ([LSig (GhcPass 'Renamed)] -> [(Name, a)]
mk_pairs [GenLocated SrcSpanAnnA (Sig (GhcPass 'Renamed))]
ordinary_sigs)
forall a. NameEnv a -> [(Name, a)] -> NameEnv a
`extendNameEnvList` ([LSig (GhcPass 'Renamed)] -> [(Name, a)]
mk_pairs [GenLocated SrcSpanAnnA (Sig (GhcPass 'Renamed))]
gen_dm_sigs)
where
([GenLocated SrcSpanAnnA (Sig (GhcPass 'Renamed))]
gen_dm_sigs, [GenLocated SrcSpanAnnA (Sig (GhcPass 'Renamed))]
ordinary_sigs) = forall a. (a -> Bool) -> [a] -> ([a], [a])
partition forall {l} {pass}. GenLocated l (Sig pass) -> Bool
is_gen_dm_sig [LSig (GhcPass 'Renamed)]
sigs
is_gen_dm_sig :: GenLocated l (Sig pass) -> Bool
is_gen_dm_sig (L l
_ (ClassOpSig XClassOpSig pass
_ Bool
True [LIdP pass]
_ LHsSigType pass
_)) = Bool
True
is_gen_dm_sig GenLocated l (Sig pass)
_ = Bool
False
mk_pairs :: [LSig GhcRn] -> [(Name, a)]
mk_pairs :: [LSig (GhcPass 'Renamed)] -> [(Name, a)]
mk_pairs [LSig (GhcPass 'Renamed)]
sigs = [ (Name
n,a
a) | Just ([GenLocated SrcSpanAnnN Name]
ns,a
a) <- forall a b. (a -> b) -> [a] -> [b]
map LSig (GhcPass 'Renamed) -> Maybe ([GenLocated SrcSpanAnnN Name], a)
get_info [LSig (GhcPass 'Renamed)]
sigs
, L SrcSpanAnnN
_ Name
n <- [GenLocated SrcSpanAnnN Name]
ns ]
mkClassOpSigs :: [LSig GhcPs] -> [LSig GhcPs]
mkClassOpSigs :: [LSig GhcPs] -> [LSig GhcPs]
mkClassOpSigs [LSig GhcPs]
sigs
= forall a b. (a -> b) -> [a] -> [b]
map forall {pass} {l}.
(XTypeSig pass ~ XClassOpSig pass) =>
GenLocated l (Sig pass) -> GenLocated l (Sig pass)
fiddle [LSig GhcPs]
sigs
where
fiddle :: GenLocated l (Sig pass) -> GenLocated l (Sig pass)
fiddle (L l
loc (TypeSig XTypeSig pass
anns [LIdP pass]
nms LHsSigWcType pass
ty))
= forall l e. l -> e -> GenLocated l e
L l
loc (forall pass.
XClassOpSig pass
-> Bool -> [LIdP pass] -> LHsSigType pass -> Sig pass
ClassOpSig XTypeSig pass
anns Bool
False [LIdP pass]
nms (forall pass. LHsSigWcType pass -> LHsSigType pass
dropWildCards LHsSigWcType pass
ty))
fiddle GenLocated l (Sig pass)
sig = GenLocated l (Sig pass)
sig
mkLHsWrap :: HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap :: HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap HsWrapper
co_fn (L SrcSpanAnnA
loc HsExpr GhcTc
e) = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap HsWrapper
co_fn HsExpr GhcTc
e)
mkHsWrap :: HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap :: HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap HsWrapper
co_fn HsExpr GhcTc
e | HsWrapper -> Bool
isIdHsWrapper HsWrapper
co_fn = HsExpr GhcTc
e
mkHsWrap HsWrapper
co_fn (XExpr (WrapExpr (HsWrap HsWrapper
co_fn' HsExpr GhcTc
e))) = HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap (HsWrapper
co_fn HsWrapper -> HsWrapper -> HsWrapper
<.> HsWrapper
co_fn') HsExpr GhcTc
e
mkHsWrap HsWrapper
co_fn (HsPar XPar GhcTc
x (L SrcSpanAnnA
l HsExpr GhcTc
e)) = forall p. XPar p -> LHsExpr p -> HsExpr p
HsPar XPar GhcTc
x (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap HsWrapper
co_fn HsExpr GhcTc
e))
mkHsWrap HsWrapper
co_fn HsExpr GhcTc
e = forall p. XXExpr p -> HsExpr p
XExpr (HsWrap HsExpr -> XXExprGhcTc
WrapExpr forall a b. (a -> b) -> a -> b
$ forall (hs_syn :: * -> *).
HsWrapper -> hs_syn GhcTc -> HsWrap hs_syn
HsWrap HsWrapper
co_fn HsExpr GhcTc
e)
mkHsWrapCo :: TcCoercionN
-> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrapCo :: TcCoercionN -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrapCo TcCoercionN
co HsExpr GhcTc
e = HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap (TcCoercionN -> HsWrapper
mkWpCastN TcCoercionN
co) HsExpr GhcTc
e
mkHsWrapCoR :: TcCoercionR
-> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrapCoR :: TcCoercionN -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrapCoR TcCoercionN
co HsExpr GhcTc
e = HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrap (TcCoercionN -> HsWrapper
mkWpCastR TcCoercionN
co) HsExpr GhcTc
e
mkLHsWrapCo :: TcCoercionN -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrapCo :: TcCoercionN -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrapCo TcCoercionN
co (L SrcSpanAnnA
loc HsExpr GhcTc
e) = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (TcCoercionN -> HsExpr GhcTc -> HsExpr GhcTc
mkHsWrapCo TcCoercionN
co HsExpr GhcTc
e)
mkHsCmdWrap :: HsWrapper -> HsCmd GhcTc -> HsCmd GhcTc
mkHsCmdWrap :: HsWrapper -> HsCmd GhcTc -> HsCmd GhcTc
mkHsCmdWrap HsWrapper
w HsCmd GhcTc
cmd | HsWrapper -> Bool
isIdHsWrapper HsWrapper
w = HsCmd GhcTc
cmd
| Bool
otherwise = forall id. XXCmd id -> HsCmd id
XCmd (forall (hs_syn :: * -> *).
HsWrapper -> hs_syn GhcTc -> HsWrap hs_syn
HsWrap HsWrapper
w HsCmd GhcTc
cmd)
mkLHsCmdWrap :: HsWrapper -> LHsCmd GhcTc -> LHsCmd GhcTc
mkLHsCmdWrap :: HsWrapper -> LHsCmd GhcTc -> LHsCmd GhcTc
mkLHsCmdWrap HsWrapper
w (L SrcSpanAnnA
loc HsCmd GhcTc
c) = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (HsWrapper -> HsCmd GhcTc -> HsCmd GhcTc
mkHsCmdWrap HsWrapper
w HsCmd GhcTc
c)
mkHsWrapPat :: HsWrapper -> Pat GhcTc -> Type -> Pat GhcTc
mkHsWrapPat :: HsWrapper -> Pat GhcTc -> Type -> Pat GhcTc
mkHsWrapPat HsWrapper
co_fn Pat GhcTc
p Type
ty | HsWrapper -> Bool
isIdHsWrapper HsWrapper
co_fn = Pat GhcTc
p
| Bool
otherwise = forall p. XXPat p -> Pat p
XPat forall a b. (a -> b) -> a -> b
$ HsWrapper -> Pat GhcTc -> Type -> CoPat
CoPat HsWrapper
co_fn Pat GhcTc
p Type
ty
mkHsWrapPatCo :: TcCoercionN -> Pat GhcTc -> Type -> Pat GhcTc
mkHsWrapPatCo :: TcCoercionN -> Pat GhcTc -> Type -> Pat GhcTc
mkHsWrapPatCo TcCoercionN
co Pat GhcTc
pat Type
ty | TcCoercionN -> Bool
isTcReflCo TcCoercionN
co = Pat GhcTc
pat
| Bool
otherwise = forall p. XXPat p -> Pat p
XPat forall a b. (a -> b) -> a -> b
$ HsWrapper -> Pat GhcTc -> Type -> CoPat
CoPat (TcCoercionN -> HsWrapper
mkWpCastN TcCoercionN
co) Pat GhcTc
pat Type
ty
mkHsDictLet :: TcEvBinds -> LHsExpr GhcTc -> LHsExpr GhcTc
mkHsDictLet :: TcEvBinds -> LHsExpr GhcTc -> LHsExpr GhcTc
mkHsDictLet TcEvBinds
ev_binds LHsExpr GhcTc
expr = HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc
mkLHsWrap (TcEvBinds -> HsWrapper
mkWpLet TcEvBinds
ev_binds) LHsExpr GhcTc
expr
mkFunBind :: Origin -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)]
-> HsBind GhcPs
mkFunBind :: Origin
-> LocatedN RdrName
-> [LMatch GhcPs (LHsExpr GhcPs)]
-> HsBind GhcPs
mkFunBind Origin
origin LocatedN RdrName
fn [LMatch GhcPs (LHsExpr GhcPs)]
ms
= FunBind { fun_id :: LIdP GhcPs
fun_id = LocatedN RdrName
fn
, fun_matches :: MatchGroup GhcPs (LHsExpr GhcPs)
fun_matches = forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
origin (forall a an. a -> LocatedAn an a
noLocA [LMatch GhcPs (LHsExpr GhcPs)]
ms)
, fun_ext :: XFunBind GhcPs GhcPs
fun_ext = NoExtField
noExtField
, fun_tick :: [CoreTickish]
fun_tick = [] }
mkTopFunBind :: Origin -> LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)]
-> HsBind GhcRn
mkTopFunBind :: Origin
-> GenLocated SrcSpanAnnN Name
-> [LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
-> HsBind (GhcPass 'Renamed)
mkTopFunBind Origin
origin GenLocated SrcSpanAnnN Name
fn [LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
ms = FunBind { fun_id :: LIdP (GhcPass 'Renamed)
fun_id = GenLocated SrcSpanAnnN Name
fn
, fun_matches :: MatchGroup (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))
fun_matches = forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
[LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
origin (forall a an. a -> LocatedAn an a
noLocA [LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
ms)
, fun_ext :: XFunBind (GhcPass 'Renamed) (GhcPass 'Renamed)
fun_ext = NameSet
emptyNameSet
, fun_tick :: [CoreTickish]
fun_tick = [] }
mkHsVarBind :: SrcSpan -> RdrName -> LHsExpr GhcPs -> LHsBind GhcPs
mkHsVarBind :: SrcSpan -> RdrName -> LHsExpr GhcPs -> LHsBind GhcPs
mkHsVarBind SrcSpan
loc RdrName
var LHsExpr GhcPs
rhs = SrcSpan
-> RdrName -> [LPat GhcPs] -> LHsExpr GhcPs -> LHsBind GhcPs
mkSimpleGeneratedFunBind SrcSpan
loc RdrName
var [] LHsExpr GhcPs
rhs
mkVarBind :: IdP (GhcPass p) -> LHsExpr (GhcPass p) -> LHsBind (GhcPass p)
mkVarBind :: forall (p :: Pass).
IdP (GhcPass p) -> LHsExpr (GhcPass p) -> LHsBind (GhcPass p)
mkVarBind IdP (GhcPass p)
var LHsExpr (GhcPass p)
rhs = forall l e. l -> e -> GenLocated l e
L (forall l e. GenLocated l e -> l
getLoc LHsExpr (GhcPass p)
rhs) forall a b. (a -> b) -> a -> b
$
VarBind { var_ext :: XVarBind (GhcPass p) (GhcPass p)
var_ext = NoExtField
noExtField,
var_id :: IdP (GhcPass p)
var_id = IdP (GhcPass p)
var, var_rhs :: LHsExpr (GhcPass p)
var_rhs = LHsExpr (GhcPass p)
rhs }
mkPatSynBind :: LocatedN RdrName -> HsPatSynDetails GhcPs
-> LPat GhcPs -> HsPatSynDir GhcPs -> EpAnn [AddEpAnn] -> HsBind GhcPs
mkPatSynBind :: LocatedN RdrName
-> HsPatSynDetails GhcPs
-> LPat GhcPs
-> HsPatSynDir GhcPs
-> EpAnn [AddEpAnn]
-> HsBind GhcPs
mkPatSynBind LocatedN RdrName
name HsPatSynDetails GhcPs
details LPat GhcPs
lpat HsPatSynDir GhcPs
dir EpAnn [AddEpAnn]
anns = forall idL idR.
XPatSynBind idL idR -> PatSynBind idL idR -> HsBindLR idL idR
PatSynBind NoExtField
noExtField PatSynBind GhcPs GhcPs
psb
where
psb :: PatSynBind GhcPs GhcPs
psb = PSB{ psb_ext :: XPSB GhcPs GhcPs
psb_ext = EpAnn [AddEpAnn]
anns
, psb_id :: LIdP GhcPs
psb_id = LocatedN RdrName
name
, psb_args :: HsPatSynDetails GhcPs
psb_args = HsPatSynDetails GhcPs
details
, psb_def :: LPat GhcPs
psb_def = LPat GhcPs
lpat
, psb_dir :: HsPatSynDir GhcPs
psb_dir = HsPatSynDir GhcPs
dir }
isInfixFunBind :: forall id1 id2. UnXRec id2 => HsBindLR id1 id2 -> Bool
isInfixFunBind :: forall id1 id2. UnXRec id2 => HsBindLR id1 id2 -> Bool
isInfixFunBind (FunBind { fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MG XMG id2 (LHsExpr id2)
_ XRec id2 [LMatch id2 (LHsExpr id2)]
matches Origin
_ })
= forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall id body. Match id body -> Bool
isInfixMatch forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @id2) (forall p a. UnXRec p => XRec p a -> a
unXRec @id2 XRec id2 [LMatch id2 (LHsExpr id2)]
matches)
isInfixFunBind HsBindLR id1 id2
_ = Bool
False
spanHsLocaLBinds :: (Data (HsLocalBinds (GhcPass p))) => HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds :: forall (p :: Pass).
Data (HsLocalBinds (GhcPass p)) =>
HsLocalBinds (GhcPass p) -> SrcSpan
spanHsLocaLBinds (EmptyLocalBinds XEmptyLocalBinds (GhcPass p) (GhcPass p)
_) = SrcSpan
noSrcSpan
spanHsLocaLBinds (HsValBinds XHsValBinds (GhcPass p) (GhcPass p)
_ (ValBinds XValBinds (GhcPass p) (GhcPass p)
_ LHsBindsLR (GhcPass p) (GhcPass p)
bs [LSig (GhcPass p)]
sigs))
= forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
noSrcSpan ([SrcSpan]
bsSpans forall a. [a] -> [a] -> [a]
++ [SrcSpan]
sigsSpans)
where
bsSpans :: [SrcSpan]
bsSpans :: [SrcSpan]
bsSpans = forall a b. (a -> b) -> [a] -> [b]
map forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA forall a b. (a -> b) -> a -> b
$ forall a. Bag a -> [a]
bagToList LHsBindsLR (GhcPass p) (GhcPass p)
bs
sigsSpans :: [SrcSpan]
sigsSpans :: [SrcSpan]
sigsSpans = forall a b. (a -> b) -> [a] -> [b]
map forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA [LSig (GhcPass p)]
sigs
spanHsLocaLBinds (HsValBinds XHsValBinds (GhcPass p) (GhcPass p)
_ (XValBindsLR (NValBinds [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
bs [LSig (GhcPass 'Renamed)]
sigs)))
= forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
noSrcSpan ([SrcSpan]
bsSpans forall a. [a] -> [a] -> [a]
++ [SrcSpan]
sigsSpans)
where
bsSpans :: [SrcSpan]
bsSpans :: [SrcSpan]
bsSpans = forall a b. (a -> b) -> [a] -> [b]
map forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a. Bag a -> [a]
bagToList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
bs
sigsSpans :: [SrcSpan]
sigsSpans :: [SrcSpan]
sigsSpans = forall a b. (a -> b) -> [a] -> [b]
map forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA [LSig (GhcPass 'Renamed)]
sigs
spanHsLocaLBinds (HsIPBinds XHsIPBinds (GhcPass p) (GhcPass p)
_ (IPBinds XIPBinds (GhcPass p)
_ [LIPBind (GhcPass p)]
bs))
= forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr SrcSpan -> SrcSpan -> SrcSpan
combineSrcSpans SrcSpan
noSrcSpan (forall a b. (a -> b) -> [a] -> [b]
map forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA [LIPBind (GhcPass p)]
bs)
mkSimpleGeneratedFunBind :: SrcSpan -> RdrName -> [LPat GhcPs]
-> LHsExpr GhcPs -> LHsBind GhcPs
mkSimpleGeneratedFunBind :: SrcSpan
-> RdrName -> [LPat GhcPs] -> LHsExpr GhcPs -> LHsBind GhcPs
mkSimpleGeneratedFunBind SrcSpan
loc RdrName
fun [LPat GhcPs]
pats LHsExpr GhcPs
expr
= forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
loc) forall a b. (a -> b) -> a -> b
$ Origin
-> LocatedN RdrName
-> [LMatch GhcPs (LHsExpr GhcPs)]
-> HsBind GhcPs
mkFunBind Origin
Generated (forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
loc) RdrName
fun)
[forall (p :: Pass).
IsPass p =>
HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LHsExpr (GhcPass p)
-> HsLocalBinds (GhcPass p)
-> LMatch (GhcPass p) (LHsExpr (GhcPass p))
mkMatch (forall p. LIdP p -> HsMatchContext p
mkPrefixFunRhs (forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan SrcSpan
loc) RdrName
fun)) [LPat GhcPs]
pats LHsExpr GhcPs
expr
forall (a :: Pass) (b :: Pass).
HsLocalBindsLR (GhcPass a) (GhcPass b)
emptyLocalBinds]
mkPrefixFunRhs :: LIdP p -> HsMatchContext p
mkPrefixFunRhs :: forall p. LIdP p -> HsMatchContext p
mkPrefixFunRhs LIdP p
n = FunRhs { mc_fun :: LIdP p
mc_fun = LIdP p
n
, mc_fixity :: LexicalFixity
mc_fixity = LexicalFixity
Prefix
, mc_strictness :: SrcStrictness
mc_strictness = SrcStrictness
NoSrcStrict }
mkMatch :: forall p. IsPass p
=> HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LHsExpr (GhcPass p)
-> HsLocalBinds (GhcPass p)
-> LMatch (GhcPass p) (LHsExpr (GhcPass p))
mkMatch :: forall (p :: Pass).
IsPass p =>
HsMatchContext (NoGhcTc (GhcPass p))
-> [LPat (GhcPass p)]
-> LHsExpr (GhcPass p)
-> HsLocalBinds (GhcPass p)
-> LMatch (GhcPass p) (LHsExpr (GhcPass p))
mkMatch HsMatchContext (NoGhcTc (GhcPass p))
ctxt [LPat (GhcPass p)]
pats LHsExpr (GhcPass p)
expr HsLocalBinds (GhcPass p)
binds
= forall a an. a -> LocatedAn an a
noLocA (Match { m_ext :: XCMatch (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
m_ext = forall a. EpAnn a
noAnn
, m_ctxt :: HsMatchContext (NoGhcTc (GhcPass p))
m_ctxt = HsMatchContext (NoGhcTc (GhcPass p))
ctxt
, m_pats :: [LPat (GhcPass p)]
m_pats = forall a b. (a -> b) -> [a] -> [b]
map LPat (GhcPass p) -> LPat (GhcPass p)
paren [LPat (GhcPass p)]
pats
, m_grhss :: GRHSs (GhcPass p) (LocatedA (HsExpr (GhcPass p)))
m_grhss = forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs EpAnnComments
emptyComments (forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
~ SrcSpan) =>
EpAnn GrhsAnn
-> SrcSpan
-> LocatedA (body (GhcPass p))
-> [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))]
unguardedRHS forall a. EpAnn a
noAnn SrcSpan
noSrcSpan LHsExpr (GhcPass p)
expr) HsLocalBinds (GhcPass p)
binds })
where
paren :: LPat (GhcPass p) -> LPat (GhcPass p)
paren :: LPat (GhcPass p) -> LPat (GhcPass p)
paren lp :: LPat (GhcPass p)
lp@(L SrcSpanAnnA
l Pat (GhcPass p)
p)
| forall (p :: Pass). IsPass p => PprPrec -> Pat (GhcPass p) -> Bool
patNeedsParens PprPrec
appPrec Pat (GhcPass p)
p = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (forall p. XParPat p -> LPat p -> Pat p
ParPat forall a. EpAnn a
noAnn LPat (GhcPass p)
lp)
| Bool
otherwise = LPat (GhcPass p)
lp
isUnliftedHsBind :: HsBind GhcTc -> Bool
isUnliftedHsBind :: HsBind GhcTc -> Bool
isUnliftedHsBind HsBind GhcTc
bind
| AbsBinds { abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport GhcTc]
exports, abs_sig :: forall idL idR. HsBindLR idL idR -> Bool
abs_sig = Bool
has_sig } <- HsBind GhcTc
bind
= if Bool
has_sig
then forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Id -> Bool
is_unlifted_id forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p. ABExport p -> IdP p
abe_poly) [ABExport GhcTc]
exports
else forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Id -> Bool
is_unlifted_id forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p. ABExport p -> IdP p
abe_mono) [ABExport GhcTc]
exports
| Bool
otherwise
= forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Id -> Bool
is_unlifted_id (forall p idR.
CollectPass p =>
CollectFlag p -> HsBindLR p idR -> [IdP p]
collectHsBindBinders forall p. CollectFlag p
CollNoDictBinders HsBind GhcTc
bind)
where
is_unlifted_id :: Id -> Bool
is_unlifted_id Id
id = HasDebugCallStack => Type -> Bool
isUnliftedType (Id -> Type
idType Id
id)
isBangedHsBind :: HsBind GhcTc -> Bool
isBangedHsBind :: HsBind GhcTc -> Bool
isBangedHsBind (AbsBinds { abs_binds :: forall idL idR. HsBindLR idL idR -> LHsBinds idL
abs_binds = LHsBinds GhcTc
binds })
= forall a. (a -> Bool) -> Bag a -> Bool
anyBag (HsBind GhcTc -> Bool
isBangedHsBind forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) LHsBinds GhcTc
binds
isBangedHsBind (FunBind {fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MatchGroup GhcTc (LHsExpr GhcTc)
matches})
| [L Anno (Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc)))
_ Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
match] <- forall l e. GenLocated l e -> e
unLoc forall a b. (a -> b) -> a -> b
$ forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts MatchGroup GhcTc (LHsExpr GhcTc)
matches
, FunRhs{mc_strictness :: forall p. HsMatchContext p -> SrcStrictness
mc_strictness = SrcStrictness
SrcStrict} <- forall p body. Match p body -> HsMatchContext (NoGhcTc p)
m_ctxt Match GhcTc (GenLocated SrcSpanAnnA (HsExpr GhcTc))
match
= Bool
True
isBangedHsBind (PatBind {pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat GhcTc
pat})
= forall (p :: Pass). LPat (GhcPass p) -> Bool
isBangedLPat LPat GhcTc
pat
isBangedHsBind HsBind GhcTc
_
= Bool
False
collectLocalBinders :: CollectPass (GhcPass idL)
=> CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders :: forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag (GhcPass idL)
flag = \case
HsValBinds XHsValBinds (GhcPass idL) (GhcPass idR)
_ HsValBindsLR (GhcPass idL) (GhcPass idR)
binds -> forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)]
collectHsIdBinders CollectFlag (GhcPass idL)
flag HsValBindsLR (GhcPass idL) (GhcPass idR)
binds
HsIPBinds {} -> []
EmptyLocalBinds XEmptyLocalBinds (GhcPass idL) (GhcPass idR)
_ -> []
collectHsIdBinders :: CollectPass (GhcPass idL)
=> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectHsIdBinders :: forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)]
collectHsIdBinders CollectFlag (GhcPass idL)
flag = forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
Bool
-> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collect_hs_val_binders Bool
True CollectFlag (GhcPass idL)
flag
collectHsValBinders :: CollectPass (GhcPass idL)
=> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectHsValBinders :: forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)]
collectHsValBinders CollectFlag (GhcPass idL)
flag = forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
Bool
-> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collect_hs_val_binders Bool
False CollectFlag (GhcPass idL)
flag
collectHsBindBinders :: CollectPass p
=> CollectFlag p
-> HsBindLR p idR
-> [IdP p]
collectHsBindBinders :: forall p idR.
CollectPass p =>
CollectFlag p -> HsBindLR p idR -> [IdP p]
collectHsBindBinders CollectFlag p
flag HsBindLR p idR
b = forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> HsBindLR p idR -> [IdP p] -> [IdP p]
collect_bind Bool
False CollectFlag p
flag HsBindLR p idR
b []
collectHsBindsBinders :: CollectPass p
=> CollectFlag p
-> LHsBindsLR p idR
-> [IdP p]
collectHsBindsBinders :: forall p idR.
CollectPass p =>
CollectFlag p -> LHsBindsLR p idR -> [IdP p]
collectHsBindsBinders CollectFlag p
flag LHsBindsLR p idR
binds = forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> LHsBindsLR p idR -> [IdP p] -> [IdP p]
collect_binds Bool
False CollectFlag p
flag LHsBindsLR p idR
binds []
collectHsBindListBinders :: forall p idR. CollectPass p
=> CollectFlag p
-> [LHsBindLR p idR]
-> [IdP p]
collectHsBindListBinders :: forall p idR.
CollectPass p =>
CollectFlag p -> [LHsBindLR p idR] -> [IdP p]
collectHsBindListBinders CollectFlag p
flag = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> HsBindLR p idR -> [IdP p] -> [IdP p]
collect_bind Bool
False CollectFlag p
flag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @p) []
collect_hs_val_binders :: CollectPass (GhcPass idL)
=> Bool
-> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collect_hs_val_binders :: forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
Bool
-> CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collect_hs_val_binders Bool
ps CollectFlag (GhcPass idL)
flag = \case
ValBinds XValBinds (GhcPass idL) (GhcPass idR)
_ LHsBindsLR (GhcPass idL) (GhcPass idR)
binds [LSig (GhcPass idR)]
_ -> forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> LHsBindsLR p idR -> [IdP p] -> [IdP p]
collect_binds Bool
ps CollectFlag (GhcPass idL)
flag LHsBindsLR (GhcPass idL) (GhcPass idR)
binds []
XValBindsLR (NValBinds [(RecFlag, LHsBinds (GhcPass idL))]
binds [LSig (GhcPass 'Renamed)]
_) -> forall p.
CollectPass p =>
Bool -> CollectFlag p -> [(RecFlag, LHsBinds p)] -> [IdP p]
collect_out_binds Bool
ps CollectFlag (GhcPass idL)
flag [(RecFlag, LHsBinds (GhcPass idL))]
binds
collect_out_binds :: forall p. CollectPass p
=> Bool
-> CollectFlag p
-> [(RecFlag, LHsBinds p)]
-> [IdP p]
collect_out_binds :: forall p.
CollectPass p =>
Bool -> CollectFlag p -> [(RecFlag, LHsBinds p)] -> [IdP p]
collect_out_binds Bool
ps CollectFlag p
flag = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> LHsBindsLR p idR -> [IdP p] -> [IdP p]
collect_binds Bool
ps CollectFlag p
flag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) []
collect_binds :: forall p idR. CollectPass p
=> Bool
-> CollectFlag p
-> LHsBindsLR p idR
-> [IdP p]
-> [IdP p]
collect_binds :: forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> LHsBindsLR p idR -> [IdP p] -> [IdP p]
collect_binds Bool
ps CollectFlag p
flag LHsBindsLR p idR
binds [IdP p]
acc = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> HsBindLR p idR -> [IdP p] -> [IdP p]
collect_bind Bool
ps CollectFlag p
flag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @p) [IdP p]
acc LHsBindsLR p idR
binds
collect_bind :: forall p idR. CollectPass p
=> Bool
-> CollectFlag p
-> HsBindLR p idR
-> [IdP p]
-> [IdP p]
collect_bind :: forall p idR.
CollectPass p =>
Bool -> CollectFlag p -> HsBindLR p idR -> [IdP p] -> [IdP p]
collect_bind Bool
_ CollectFlag p
flag (PatBind { pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat p
p }) [IdP p]
acc = forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
p [IdP p]
acc
collect_bind Bool
_ CollectFlag p
_ (FunBind { fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = LIdP p
f }) [IdP p]
acc = forall p a. UnXRec p => XRec p a -> a
unXRec @p LIdP p
f forall a. a -> [a] -> [a]
: [IdP p]
acc
collect_bind Bool
_ CollectFlag p
_ (VarBind { var_id :: forall idL idR. HsBindLR idL idR -> IdP idL
var_id = IdP p
f }) [IdP p]
acc = IdP p
f forall a. a -> [a] -> [a]
: [IdP p]
acc
collect_bind Bool
_ CollectFlag p
_ (AbsBinds { abs_exports :: forall idL idR. HsBindLR idL idR -> [ABExport idL]
abs_exports = [ABExport p]
dbinds }) [IdP p]
acc = forall a b. (a -> b) -> [a] -> [b]
map forall p. ABExport p -> IdP p
abe_poly [ABExport p]
dbinds forall a. [a] -> [a] -> [a]
++ [IdP p]
acc
collect_bind Bool
omitPatSyn CollectFlag p
_ (PatSynBind XPatSynBind p idR
_ (PSB { psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_id = LIdP p
ps })) [IdP p]
acc
| Bool
omitPatSyn = [IdP p]
acc
| Bool
otherwise = forall p a. UnXRec p => XRec p a -> a
unXRec @p LIdP p
ps forall a. a -> [a] -> [a]
: [IdP p]
acc
collect_bind Bool
_ CollectFlag p
_ (PatSynBind XPatSynBind p idR
_ (XPatSynBind XXPatSynBind p idR
_)) [IdP p]
acc = [IdP p]
acc
collect_bind Bool
_ CollectFlag p
_ (XHsBindsLR XXHsBindsLR p idR
_) [IdP p]
acc = [IdP p]
acc
collectMethodBinders :: forall idL idR. UnXRec idL => LHsBindsLR idL idR -> [LIdP idL]
collectMethodBinders :: forall idL idR. UnXRec idL => LHsBindsLR idL idR -> [LIdP idL]
collectMethodBinders LHsBindsLR idL idR
binds = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall {idL} {idR}.
HsBindLR idL idR -> [XRec idL (IdP idL)] -> [XRec idL (IdP idL)]
get forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall p a. UnXRec p => XRec p a -> a
unXRec @idL) [] LHsBindsLR idL idR
binds
where
get :: HsBindLR idL idR -> [XRec idL (IdP idL)] -> [XRec idL (IdP idL)]
get (FunBind { fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = XRec idL (IdP idL)
f }) [XRec idL (IdP idL)]
fs = XRec idL (IdP idL)
f forall a. a -> [a] -> [a]
: [XRec idL (IdP idL)]
fs
get HsBindLR idL idR
_ [XRec idL (IdP idL)]
fs = [XRec idL (IdP idL)]
fs
collectLStmtsBinders
:: CollectPass (GhcPass idL)
=> CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders :: forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag (GhcPass idL)
flag = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> LStmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)]
collectLStmtBinders CollectFlag (GhcPass idL)
flag)
collectStmtsBinders
:: (CollectPass (GhcPass idL))
=> CollectFlag (GhcPass idL)
-> [StmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectStmtsBinders :: forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [StmtLR (GhcPass idL) (GhcPass idR) body] -> [IdP (GhcPass idL)]
collectStmtsBinders CollectFlag (GhcPass idL)
flag = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> StmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)]
collectStmtBinders CollectFlag (GhcPass idL)
flag)
collectLStmtBinders
:: (CollectPass (GhcPass idL))
=> CollectFlag (GhcPass idL)
-> LStmtLR (GhcPass idL) (GhcPass idR) body
-> [IdP (GhcPass idL)]
collectLStmtBinders :: forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> LStmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)]
collectLStmtBinders CollectFlag (GhcPass idL)
flag = forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> StmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)]
collectStmtBinders CollectFlag (GhcPass idL)
flag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc
collectStmtBinders
:: CollectPass (GhcPass idL)
=> CollectFlag (GhcPass idL)
-> StmtLR (GhcPass idL) (GhcPass idR) body
-> [IdP (GhcPass idL)]
collectStmtBinders :: forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> StmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)]
collectStmtBinders CollectFlag (GhcPass idL)
flag = \case
BindStmt XBindStmt (GhcPass idL) (GhcPass idR) body
_ LPat (GhcPass idL)
pat body
_ -> forall p. CollectPass p => CollectFlag p -> LPat p -> [IdP p]
collectPatBinders CollectFlag (GhcPass idL)
flag LPat (GhcPass idL)
pat
LetStmt XLetStmt (GhcPass idL) (GhcPass idR) body
_ HsLocalBindsLR (GhcPass idL) (GhcPass idR)
binds -> forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsLocalBindsLR (GhcPass idL) (GhcPass idR)
-> [IdP (GhcPass idL)]
collectLocalBinders CollectFlag (GhcPass idL)
flag HsLocalBindsLR (GhcPass idL) (GhcPass idR)
binds
BodyStmt {} -> []
LastStmt {} -> []
ParStmt XParStmt (GhcPass idL) (GhcPass idR) body
_ [ParStmtBlock (GhcPass idL) (GhcPass idR)]
xs HsExpr (GhcPass idR)
_ SyntaxExpr (GhcPass idR)
_ -> forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag (GhcPass idL)
flag [GenLocated
SrcSpanAnnA
(StmtLR
(GhcPass idL)
(GhcPass idL)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
s | ParStmtBlock XParStmtBlock (GhcPass idL) (GhcPass idR)
_ [ExprLStmt (GhcPass idL)]
ss [IdP (GhcPass idR)]
_ SyntaxExpr (GhcPass idR)
_ <- [ParStmtBlock (GhcPass idL) (GhcPass idR)]
xs, GenLocated
SrcSpanAnnA
(StmtLR
(GhcPass idL)
(GhcPass idL)
(GenLocated SrcSpanAnnA (HsExpr (GhcPass idL))))
s <- [ExprLStmt (GhcPass idL)]
ss]
TransStmt { trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_stmts = [ExprLStmt (GhcPass idL)]
stmts } -> forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag (GhcPass idL)
flag [ExprLStmt (GhcPass idL)]
stmts
RecStmt { recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts = L Anno
[GenLocated
(Anno (StmtLR (GhcPass idL) (GhcPass idR) body))
(StmtLR (GhcPass idL) (GhcPass idR) body)]
_ [GenLocated
(Anno (StmtLR (GhcPass idL) (GhcPass idR) body))
(StmtLR (GhcPass idL) (GhcPass idR) body)]
ss } -> forall (idL :: Pass) (idR :: Pass) body.
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> [LStmtLR (GhcPass idL) (GhcPass idR) body]
-> [IdP (GhcPass idL)]
collectLStmtsBinders CollectFlag (GhcPass idL)
flag [GenLocated
(Anno (StmtLR (GhcPass idL) (GhcPass idR) body))
(StmtLR (GhcPass idL) (GhcPass idR) body)]
ss
ApplicativeStmt XApplicativeStmt (GhcPass idL) (GhcPass idR) body
_ [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
args Maybe (SyntaxExpr (GhcPass idR))
_ -> forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))
-> [IdP (GhcPass idL)]
collectArgBinders [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass idL))]
args
where
collectArgBinders :: (SyntaxExprGhc idR, ApplicativeArg (GhcPass idL))
-> [IdP (GhcPass idL)]
collectArgBinders = \case
(SyntaxExprGhc idR
_, ApplicativeArgOne { app_arg_pattern :: forall idL. ApplicativeArg idL -> LPat idL
app_arg_pattern = LPat (GhcPass idL)
pat }) -> forall p. CollectPass p => CollectFlag p -> LPat p -> [IdP p]
collectPatBinders CollectFlag (GhcPass idL)
flag LPat (GhcPass idL)
pat
(SyntaxExprGhc idR
_, ApplicativeArgMany { bv_pattern :: forall idL. ApplicativeArg idL -> LPat idL
bv_pattern = LPat (GhcPass idL)
pat }) -> forall p. CollectPass p => CollectFlag p -> LPat p -> [IdP p]
collectPatBinders CollectFlag (GhcPass idL)
flag LPat (GhcPass idL)
pat
collectPatBinders
:: CollectPass p
=> CollectFlag p
-> LPat p
-> [IdP p]
collectPatBinders :: forall p. CollectPass p => CollectFlag p -> LPat p -> [IdP p]
collectPatBinders CollectFlag p
flag LPat p
pat = forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat []
collectPatsBinders
:: CollectPass p
=> CollectFlag p
-> [LPat p]
-> [IdP p]
collectPatsBinders :: forall p. CollectPass p => CollectFlag p -> [LPat p] -> [IdP p]
collectPatsBinders CollectFlag p
flag [LPat p]
pats = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag) [] [LPat p]
pats
data CollectFlag p where
CollNoDictBinders :: CollectFlag p
CollWithDictBinders :: CollectFlag GhcTc
collect_lpat :: forall p. (CollectPass p)
=> CollectFlag p
-> LPat p
-> [IdP p]
-> [IdP p]
collect_lpat :: forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs = forall p.
CollectPass p =>
CollectFlag p -> Pat p -> [IdP p] -> [IdP p]
collect_pat CollectFlag p
flag (forall p a. UnXRec p => XRec p a -> a
unXRec @p LPat p
pat) [IdP p]
bndrs
collect_pat :: forall p. CollectPass p
=> CollectFlag p
-> Pat p
-> [IdP p]
-> [IdP p]
collect_pat :: forall p.
CollectPass p =>
CollectFlag p -> Pat p -> [IdP p] -> [IdP p]
collect_pat CollectFlag p
flag Pat p
pat [IdP p]
bndrs = case Pat p
pat of
VarPat XVarPat p
_ LIdP p
var -> forall p a. UnXRec p => XRec p a -> a
unXRec @p LIdP p
var forall a. a -> [a] -> [a]
: [IdP p]
bndrs
WildPat XWildPat p
_ -> [IdP p]
bndrs
LazyPat XLazyPat p
_ LPat p
pat -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
BangPat XBangPat p
_ LPat p
pat -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
AsPat XAsPat p
_ LIdP p
a LPat p
pat -> forall p a. UnXRec p => XRec p a -> a
unXRec @p LIdP p
a forall a. a -> [a] -> [a]
: forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
ViewPat XViewPat p
_ LHsExpr p
_ LPat p
pat -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
ParPat XParPat p
_ LPat p
pat -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
ListPat XListPat p
_ [LPat p]
pats -> forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag) [IdP p]
bndrs [LPat p]
pats
TuplePat XTuplePat p
_ [LPat p]
pats Boxity
_ -> forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag) [IdP p]
bndrs [LPat p]
pats
SumPat XSumPat p
_ LPat p
pat Int
_ Int
_ -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
LitPat XLitPat p
_ HsLit p
_ -> [IdP p]
bndrs
NPat {} -> [IdP p]
bndrs
NPlusKPat XNPlusKPat p
_ LIdP p
n XRec p (HsOverLit p)
_ HsOverLit p
_ SyntaxExpr p
_ SyntaxExpr p
_ -> forall p a. UnXRec p => XRec p a -> a
unXRec @p LIdP p
n forall a. a -> [a] -> [a]
: [IdP p]
bndrs
SigPat XSigPat p
_ LPat p
pat HsPatSigType (NoGhcTc p)
_ -> forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag LPat p
pat [IdP p]
bndrs
XPat XXPat p
ext -> forall p.
CollectPass p =>
Proxy p -> CollectFlag p -> XXPat p -> [IdP p] -> [IdP p]
collectXXPat (forall {k} (t :: k). Proxy t
Proxy @p) CollectFlag p
flag XXPat p
ext [IdP p]
bndrs
SplicePat XSplicePat p
_ (HsSpliced XSpliced p
_ ThModFinalizers
_ (HsSplicedPat Pat p
pat))
-> forall p.
CollectPass p =>
CollectFlag p -> Pat p -> [IdP p] -> [IdP p]
collect_pat CollectFlag p
flag Pat p
pat [IdP p]
bndrs
SplicePat XSplicePat p
_ HsSplice p
_ -> [IdP p]
bndrs
ConPat {pat_args :: forall p. Pat p -> HsConPatDetails p
pat_args=HsConPatDetails p
ps} -> case CollectFlag p
flag of
CollectFlag p
CollNoDictBinders -> forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag) [IdP p]
bndrs (forall p. UnXRec p => HsConPatDetails p -> [LPat p]
hsConPatArgs HsConPatDetails p
ps)
CollectFlag p
CollWithDictBinders -> forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall p.
CollectPass p =>
CollectFlag p -> LPat p -> [IdP p] -> [IdP p]
collect_lpat CollectFlag p
flag) [IdP p]
bndrs (forall p. UnXRec p => HsConPatDetails p -> [LPat p]
hsConPatArgs HsConPatDetails p
ps)
forall a. [a] -> [a] -> [a]
++ TcEvBinds -> [Id]
collectEvBinders (ConPatTc -> TcEvBinds
cpt_binds (forall p. Pat p -> XConPat p
pat_con_ext Pat p
pat))
collectEvBinders :: TcEvBinds -> [Id]
collectEvBinders :: TcEvBinds -> [Id]
collectEvBinders (EvBinds Bag EvBind
bs) = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr EvBind -> [Id] -> [Id]
add_ev_bndr [] Bag EvBind
bs
collectEvBinders (TcEvBinds {}) = forall a. String -> a
panic String
"ToDo: collectEvBinders"
add_ev_bndr :: EvBind -> [Id] -> [Id]
add_ev_bndr :: EvBind -> [Id] -> [Id]
add_ev_bndr (EvBind { eb_lhs :: EvBind -> Id
eb_lhs = Id
b }) [Id]
bs | Id -> Bool
isId Id
b = Id
bforall a. a -> [a] -> [a]
:[Id]
bs
| Bool
otherwise = [Id]
bs
class UnXRec p => CollectPass p where
collectXXPat :: Proxy p -> CollectFlag p -> XXPat p -> [IdP p] -> [IdP p]
instance IsPass p => CollectPass (GhcPass p) where
collectXXPat :: Proxy (GhcPass p)
-> CollectFlag (GhcPass p)
-> XXPat (GhcPass p)
-> [IdP (GhcPass p)]
-> [IdP (GhcPass p)]
collectXXPat Proxy (GhcPass p)
_ CollectFlag (GhcPass p)
flag XXPat (GhcPass p)
ext =
case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcTc -> let CoPat HsWrapper
_ Pat GhcTc
pat Type
_ = XXPat (GhcPass p)
ext in forall p.
CollectPass p =>
CollectFlag p -> Pat p -> [IdP p] -> [IdP p]
collect_pat CollectFlag (GhcPass p)
flag Pat GhcTc
pat
GhcPass p
GhcRn -> forall a. NoExtCon -> a
noExtCon XXPat (GhcPass p)
ext
GhcPass p
GhcPs -> forall a. NoExtCon -> a
noExtCon XXPat (GhcPass p)
ext
hsGroupBinders :: HsGroup GhcRn -> [Name]
hsGroupBinders :: HsGroup (GhcPass 'Renamed) -> [Name]
hsGroupBinders (HsGroup { hs_valds :: forall p. HsGroup p -> HsValBinds p
hs_valds = HsValBinds (GhcPass 'Renamed)
val_decls, hs_tyclds :: forall p. HsGroup p -> [TyClGroup p]
hs_tyclds = [TyClGroup (GhcPass 'Renamed)]
tycl_decls,
hs_fords :: forall p. HsGroup p -> [LForeignDecl p]
hs_fords = [LForeignDecl (GhcPass 'Renamed)]
foreign_decls })
= forall (idL :: Pass) (idR :: Pass).
CollectPass (GhcPass idL) =>
CollectFlag (GhcPass idL)
-> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)]
collectHsValBinders forall p. CollectFlag p
CollNoDictBinders HsValBinds (GhcPass 'Renamed)
val_decls
forall a. [a] -> [a] -> [a]
++ [TyClGroup (GhcPass 'Renamed)]
-> [LForeignDecl (GhcPass 'Renamed)] -> [Name]
hsTyClForeignBinders [TyClGroup (GhcPass 'Renamed)]
tycl_decls [LForeignDecl (GhcPass 'Renamed)]
foreign_decls
hsTyClForeignBinders :: [TyClGroup GhcRn]
-> [LForeignDecl GhcRn]
-> [Name]
hsTyClForeignBinders :: [TyClGroup (GhcPass 'Renamed)]
-> [LForeignDecl (GhcPass 'Renamed)] -> [Name]
hsTyClForeignBinders [TyClGroup (GhcPass 'Renamed)]
tycl_decls [LForeignDecl (GhcPass 'Renamed)]
foreign_decls
= forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc (forall (p :: Pass) a.
(UnXRec (GhcPass p), IsSrcSpanAnn p a) =>
[LForeignDecl (GhcPass p)] -> [LIdP (GhcPass p)]
hsForeignDeclsBinders [LForeignDecl (GhcPass 'Renamed)]
foreign_decls)
forall a. [a] -> [a] -> [a]
++ ([LocatedA Name], [LFieldOcc (GhcPass 'Renamed)]) -> [Name]
getSelectorNames
(forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap forall (p :: Pass).
IsPass p =>
LocatedA (TyClDecl (GhcPass p))
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLTyClDeclBinders forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall pass. TyClGroup pass -> [LTyClDecl pass]
group_tyclds) [TyClGroup (GhcPass 'Renamed)]
tycl_decls
forall a. Monoid a => a -> a -> a
`mappend`
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap forall (p :: Pass).
IsPass p =>
LInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLInstDeclBinders forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall pass. TyClGroup pass -> [LInstDecl pass]
group_instds) [TyClGroup (GhcPass 'Renamed)]
tycl_decls)
where
getSelectorNames :: ([LocatedA Name], [LFieldOcc GhcRn]) -> [Name]
getSelectorNames :: ([LocatedA Name], [LFieldOcc (GhcPass 'Renamed)]) -> [Name]
getSelectorNames ([LocatedA Name]
ns, [LFieldOcc (GhcPass 'Renamed)]
fs) = forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LocatedA Name]
ns forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map (forall pass. FieldOcc pass -> XCFieldOcc pass
extFieldOcc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LFieldOcc (GhcPass 'Renamed)]
fs
hsLTyClDeclBinders :: IsPass p
=> LocatedA (TyClDecl (GhcPass p))
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLTyClDeclBinders :: forall (p :: Pass).
IsPass p =>
LocatedA (TyClDecl (GhcPass p))
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLTyClDeclBinders (L SrcSpanAnnA
loc (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl
{ fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = (L Anno (IdGhcP p)
_ IdGhcP p
name) } }))
= ([forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc IdGhcP p
name], [])
hsLTyClDeclBinders (L SrcSpanAnnA
loc (SynDecl
{ tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = (L Anno (IdGhcP p)
_ IdGhcP p
name) }))
= ([forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc IdGhcP p
name], [])
hsLTyClDeclBinders (L SrcSpanAnnA
loc (ClassDecl
{ tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = (L Anno (IdGhcP p)
_ IdGhcP p
cls_name)
, tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig (GhcPass p)]
sigs
, tcdATs :: forall pass. TyClDecl pass -> [LFamilyDecl pass]
tcdATs = [LFamilyDecl (GhcPass p)]
ats }))
= (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc IdGhcP p
cls_name forall a. a -> [a] -> [a]
:
[ forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
fam_loc IdGhcP p
fam_name | (L SrcSpanAnnA
fam_loc (FamilyDecl
{ fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = L Anno (IdGhcP p)
_ IdGhcP p
fam_name })) <- [LFamilyDecl (GhcPass p)]
ats ]
forall a. [a] -> [a] -> [a]
++
[ forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
mem_loc IdGhcP p
mem_name
| (L SrcSpanAnnA
mem_loc (ClassOpSig XClassOpSig (GhcPass p)
_ Bool
False [LIdP (GhcPass p)]
ns LHsSigType (GhcPass p)
_)) <- [LSig (GhcPass p)]
sigs
, (L Anno (IdGhcP p)
_ IdGhcP p
mem_name) <- [LIdP (GhcPass p)]
ns ]
, [])
hsLTyClDeclBinders (L SrcSpanAnnA
loc (DataDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = (L Anno (IdGhcP p)
_ IdGhcP p
name)
, tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn (GhcPass p)
defn }))
= (\ ([GenLocated SrcSpanAnnA (IdGhcP p)]
xs, [GenLocated SrcSpan (FieldOcc (GhcPass p))]
ys) -> (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc IdGhcP p
name forall a. a -> [a] -> [a]
: [GenLocated SrcSpanAnnA (IdGhcP p)]
xs, [GenLocated SrcSpan (FieldOcc (GhcPass p))]
ys)) forall a b. (a -> b) -> a -> b
$ forall (p :: Pass).
IsPass p =>
HsDataDefn (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataDefnBinders HsDataDefn (GhcPass p)
defn
hsForeignDeclsBinders :: forall p a. (UnXRec (GhcPass p), IsSrcSpanAnn p a)
=> [LForeignDecl (GhcPass p)] -> [LIdP (GhcPass p)]
hsForeignDeclsBinders :: forall (p :: Pass) a.
(UnXRec (GhcPass p), IsSrcSpanAnn p a) =>
[LForeignDecl (GhcPass p)] -> [LIdP (GhcPass p)]
hsForeignDeclsBinders [LForeignDecl (GhcPass p)]
foreign_decls
= [ forall l e. l -> e -> GenLocated l e
L (forall ann. SrcSpan -> SrcAnn ann
noAnnSrcSpan (forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
decl_loc)) IdGhcP p
n
| L SrcSpanAnnA
decl_loc (ForeignImport { fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_name = L SrcSpanAnn' (EpAnn a)
_ IdGhcP p
n })
<- [LForeignDecl (GhcPass p)]
foreign_decls]
hsPatSynSelectors :: IsPass p => HsValBinds (GhcPass p) -> [FieldOcc (GhcPass p)]
hsPatSynSelectors :: forall (p :: Pass).
IsPass p =>
HsValBinds (GhcPass p) -> [FieldOcc (GhcPass p)]
hsPatSynSelectors (ValBinds XValBinds (GhcPass p) (GhcPass p)
_ LHsBindsLR (GhcPass p) (GhcPass p)
_ [LSig (GhcPass p)]
_) = forall a. String -> a
panic String
"hsPatSynSelectors"
hsPatSynSelectors (XValBindsLR (NValBinds [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
binds [LSig (GhcPass 'Renamed)]
_))
= forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall p. UnXRec p => LHsBind p -> [FieldOcc p] -> [FieldOcc p]
addPatSynSelector [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Bag a] -> Bag a
unionManyBags forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(RecFlag, LHsBindsLR (GhcPass p) (GhcPass p))]
binds
addPatSynSelector :: forall p. UnXRec p => LHsBind p -> [FieldOcc p] -> [FieldOcc p]
addPatSynSelector :: forall p. UnXRec p => LHsBind p -> [FieldOcc p] -> [FieldOcc p]
addPatSynSelector LHsBind p
bind [FieldOcc p]
sels
| PatSynBind XPatSynBind p p
_ (PSB { psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_args = RecCon [RecordPatSynField p]
as }) <- forall p a. UnXRec p => XRec p a -> a
unXRec @p LHsBind p
bind
= forall a b. (a -> b) -> [a] -> [b]
map forall pass. RecordPatSynField pass -> FieldOcc pass
recordPatSynField [RecordPatSynField p]
as forall a. [a] -> [a] -> [a]
++ [FieldOcc p]
sels
| Bool
otherwise = [FieldOcc p]
sels
getPatSynBinds :: forall id. UnXRec id
=> [(RecFlag, LHsBinds id)] -> [PatSynBind id id]
getPatSynBinds :: forall id.
UnXRec id =>
[(RecFlag, LHsBinds id)] -> [PatSynBind id id]
getPatSynBinds [(RecFlag, LHsBinds id)]
binds
= [ PatSynBind id id
psb | (RecFlag
_, LHsBinds id
lbinds) <- [(RecFlag, LHsBinds id)]
binds
, (forall p a. UnXRec p => XRec p a -> a
unXRec @id -> (PatSynBind XPatSynBind id id
_ PatSynBind id id
psb)) <- forall a. Bag a -> [a]
bagToList LHsBinds id
lbinds ]
hsLInstDeclBinders :: IsPass p
=> LInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLInstDeclBinders :: forall (p :: Pass).
IsPass p =>
LInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsLInstDeclBinders (L SrcSpanAnnA
_ (ClsInstD
{ cid_inst :: forall pass. InstDecl pass -> ClsInstDecl pass
cid_inst = ClsInstDecl
{ cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts = [LDataFamInstDecl (GhcPass p)]
dfis }}))
= forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (forall (p :: Pass).
IsPass p =>
DataFamInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataFamInstBinders forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LDataFamInstDecl (GhcPass p)]
dfis
hsLInstDeclBinders (L SrcSpanAnnA
_ (DataFamInstD { dfid_inst :: forall pass. InstDecl pass -> DataFamInstDecl pass
dfid_inst = DataFamInstDecl (GhcPass p)
fi }))
= forall (p :: Pass).
IsPass p =>
DataFamInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataFamInstBinders DataFamInstDecl (GhcPass p)
fi
hsLInstDeclBinders (L SrcSpanAnnA
_ (TyFamInstD {})) = forall a. Monoid a => a
mempty
hsDataFamInstBinders :: IsPass p
=> DataFamInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataFamInstBinders :: forall (p :: Pass).
IsPass p =>
DataFamInstDecl (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataFamInstBinders (DataFamInstDecl { dfid_eqn :: forall pass. DataFamInstDecl pass -> FamEqn pass (HsDataDefn pass)
dfid_eqn = FamEqn { feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = HsDataDefn (GhcPass p)
defn }})
= forall (p :: Pass).
IsPass p =>
HsDataDefn (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataDefnBinders HsDataDefn (GhcPass p)
defn
hsDataDefnBinders :: IsPass p
=> HsDataDefn (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataDefnBinders :: forall (p :: Pass).
IsPass p =>
HsDataDefn (GhcPass p)
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsDataDefnBinders (HsDataDefn { dd_cons :: forall pass. HsDataDefn pass -> [LConDecl pass]
dd_cons = [LConDecl (GhcPass p)]
cons })
= forall (p :: Pass).
IsPass p =>
[LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsConDeclsBinders [LConDecl (GhcPass p)]
cons
type Seen p = [LFieldOcc (GhcPass p)] -> [LFieldOcc (GhcPass p)]
hsConDeclsBinders :: forall p. IsPass p
=> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsConDeclsBinders :: forall (p :: Pass).
IsPass p =>
[LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
hsConDeclsBinders [LConDecl (GhcPass p)]
cons
= Seen p
-> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
go forall a. a -> a
id [LConDecl (GhcPass p)]
cons
where
go :: Seen p -> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
go :: Seen p
-> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
go Seen p
_ [] = ([], [])
go Seen p
remSeen (LConDecl (GhcPass p)
r:[LConDecl (GhcPass p)]
rs)
= let loc :: SrcSpanAnnA
loc = forall l e. GenLocated l e -> l
getLoc LConDecl (GhcPass p)
r
in case forall l e. GenLocated l e -> e
unLoc LConDecl (GhcPass p)
r of
ConDeclGADT { con_names :: forall pass. ConDecl pass -> [LIdP pass]
con_names = [LIdP (GhcPass p)]
names, con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_g_args = HsConDeclGADTDetails (GhcPass p)
args }
-> (forall a b. (a -> b) -> [a] -> [b]
map (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LIdP (GhcPass p)]
names forall a. [a] -> [a] -> [a]
++ [LocatedA (IdP (GhcPass p))]
ns, [LFieldOcc (GhcPass p)]
flds forall a. [a] -> [a] -> [a]
++ [LFieldOcc (GhcPass p)]
fs)
where
(Seen p
remSeen', [LFieldOcc (GhcPass p)]
flds) = Seen p
-> HsConDeclGADTDetails (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_gadt Seen p
remSeen HsConDeclGADTDetails (GhcPass p)
args
([LocatedA (IdP (GhcPass p))]
ns, [LFieldOcc (GhcPass p)]
fs) = Seen p
-> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
go Seen p
remSeen' [LConDecl (GhcPass p)]
rs
ConDeclH98 { con_name :: forall pass. ConDecl pass -> LIdP pass
con_name = LIdP (GhcPass p)
name, con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details (GhcPass p)
args }
-> ([forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
name)] forall a. [a] -> [a] -> [a]
++ [LocatedA (IdP (GhcPass p))]
ns, [LFieldOcc (GhcPass p)]
flds forall a. [a] -> [a] -> [a]
++ [LFieldOcc (GhcPass p)]
fs)
where
(Seen p
remSeen', [LFieldOcc (GhcPass p)]
flds) = Seen p
-> HsConDeclH98Details (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_h98 Seen p
remSeen HsConDeclH98Details (GhcPass p)
args
([LocatedA (IdP (GhcPass p))]
ns, [LFieldOcc (GhcPass p)]
fs) = Seen p
-> [LConDecl (GhcPass p)]
-> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)])
go Seen p
remSeen' [LConDecl (GhcPass p)]
rs
get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_h98 :: Seen p
-> HsConDeclH98Details (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_h98 Seen p
remSeen (RecCon XRec (GhcPass p) [LConDeclField (GhcPass p)]
flds) = Seen p
-> LocatedL [LConDeclField (GhcPass p)]
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds Seen p
remSeen XRec (GhcPass p) [LConDeclField (GhcPass p)]
flds
get_flds_h98 Seen p
remSeen HsConDeclH98Details (GhcPass p)
_ = (Seen p
remSeen, [])
get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_gadt :: Seen p
-> HsConDeclGADTDetails (GhcPass p)
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds_gadt Seen p
remSeen (RecConGADT XRec (GhcPass p) [LConDeclField (GhcPass p)]
flds) = Seen p
-> LocatedL [LConDeclField (GhcPass p)]
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds Seen p
remSeen XRec (GhcPass p) [LConDeclField (GhcPass p)]
flds
get_flds_gadt Seen p
remSeen HsConDeclGADTDetails (GhcPass p)
_ = (Seen p
remSeen, [])
get_flds :: Seen p -> LocatedL [LConDeclField (GhcPass p)]
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds :: Seen p
-> LocatedL [LConDeclField (GhcPass p)]
-> (Seen p, [LFieldOcc (GhcPass p)])
get_flds Seen p
remSeen LocatedL [LConDeclField (GhcPass p)]
flds = ([GenLocated SrcSpan (FieldOcc (GhcPass p))]
-> [GenLocated SrcSpan (FieldOcc (GhcPass p))]
remSeen', [LFieldOcc (GhcPass p)]
fld_names)
where
fld_names :: [LFieldOcc (GhcPass p)]
fld_names = Seen p
remSeen (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall pass. ConDeclField pass -> [LFieldOcc pass]
cd_fld_names forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) (forall l e. GenLocated l e -> e
unLoc LocatedL [LConDeclField (GhcPass p)]
flds))
remSeen' :: [GenLocated SrcSpan (FieldOcc (GhcPass p))]
-> [GenLocated SrcSpan (FieldOcc (GhcPass p))]
remSeen' = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) Seen p
remSeen
[forall a. (a -> a -> Bool) -> a -> [a] -> [a]
deleteBy (forall a. Eq a => a -> a -> Bool
(==) forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall pass. FieldOcc pass -> LocatedN RdrName
rdrNameFieldOcc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) GenLocated SrcSpan (FieldOcc (GhcPass p))
v
| GenLocated SrcSpan (FieldOcc (GhcPass p))
v <- [LFieldOcc (GhcPass p)]
fld_names]
lStmtsImplicits :: [LStmtLR GhcRn (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
lStmtsImplicits :: forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
lStmtsImplicits = forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts
where
hs_lstmts :: [LStmtLR GhcRn (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts :: forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall (idR :: Pass) (body :: * -> *).
StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
-> [(SrcSpan, [Name])]
hs_stmt forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc)
hs_stmt :: StmtLR GhcRn (GhcPass idR) (LocatedA (body (GhcPass idR)))
-> [(SrcSpan, [Name])]
hs_stmt :: forall (idR :: Pass) (body :: * -> *).
StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
-> [(SrcSpan, [Name])]
hs_stmt (BindStmt XBindStmt
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
_ LPat (GhcPass 'Renamed)
pat LocatedA (body (GhcPass idR))
_) = LPat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
lPatImplicits LPat (GhcPass 'Renamed)
pat
hs_stmt (ApplicativeStmt XApplicativeStmt
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
_ [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass 'Renamed))]
args Maybe (SyntaxExpr (GhcPass idR))
_) = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {a}.
(a, ApplicativeArg (GhcPass 'Renamed)) -> [(SrcSpan, [Name])]
do_arg [(SyntaxExpr (GhcPass idR), ApplicativeArg (GhcPass 'Renamed))]
args
where do_arg :: (a, ApplicativeArg (GhcPass 'Renamed)) -> [(SrcSpan, [Name])]
do_arg (a
_, ApplicativeArgOne { app_arg_pattern :: forall idL. ApplicativeArg idL -> LPat idL
app_arg_pattern = LPat (GhcPass 'Renamed)
pat }) = LPat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
lPatImplicits LPat (GhcPass 'Renamed)
pat
do_arg (a
_, ApplicativeArgMany { app_stmts :: forall idL. ApplicativeArg idL -> [ExprLStmt idL]
app_stmts = [ExprLStmt (GhcPass 'Renamed)]
stmts }) = forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts [ExprLStmt (GhcPass 'Renamed)]
stmts
hs_stmt (LetStmt XLetStmt
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
_ HsLocalBindsLR (GhcPass 'Renamed) (GhcPass idR)
binds) = forall {idR :: Pass}.
HsLocalBindsLR (GhcPass 'Renamed) (GhcPass idR)
-> [(SrcSpan, [Name])]
hs_local_binds HsLocalBindsLR (GhcPass 'Renamed) (GhcPass idR)
binds
hs_stmt (BodyStmt {}) = []
hs_stmt (LastStmt {}) = []
hs_stmt (ParStmt XParStmt
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))
_ [ParStmtBlock (GhcPass 'Renamed) (GhcPass idR)]
xs HsExpr (GhcPass idR)
_ SyntaxExpr (GhcPass idR)
_) = forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts [GenLocated
SrcSpanAnnA
(StmtLR
(GhcPass 'Renamed)
(GhcPass 'Renamed)
(LocatedA (HsExpr (GhcPass 'Renamed))))
s | ParStmtBlock XParStmtBlock (GhcPass 'Renamed) (GhcPass idR)
_ [ExprLStmt (GhcPass 'Renamed)]
ss [IdP (GhcPass idR)]
_ SyntaxExpr (GhcPass idR)
_ <- [ParStmtBlock (GhcPass 'Renamed) (GhcPass idR)]
xs
, GenLocated
SrcSpanAnnA
(StmtLR
(GhcPass 'Renamed)
(GhcPass 'Renamed)
(LocatedA (HsExpr (GhcPass 'Renamed))))
s <- [ExprLStmt (GhcPass 'Renamed)]
ss]
hs_stmt (TransStmt { trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_stmts = [ExprLStmt (GhcPass 'Renamed)]
stmts }) = forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts [ExprLStmt (GhcPass 'Renamed)]
stmts
hs_stmt (RecStmt { recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_stmts = L Anno
[GenLocated
(Anno
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))))
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR))))]
_ [GenLocated
(Anno
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))))
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR))))]
ss }) = forall (idR :: Pass) (body :: * -> *).
[LStmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))]
-> [(SrcSpan, [Name])]
hs_lstmts [GenLocated
(Anno
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR)))))
(StmtLR
(GhcPass 'Renamed) (GhcPass idR) (LocatedA (body (GhcPass idR))))]
ss
hs_local_binds :: HsLocalBindsLR (GhcPass 'Renamed) (GhcPass idR)
-> [(SrcSpan, [Name])]
hs_local_binds (HsValBinds XHsValBinds (GhcPass 'Renamed) (GhcPass idR)
_ HsValBindsLR (GhcPass 'Renamed) (GhcPass idR)
val_binds) = forall (idR :: Pass).
HsValBindsLR (GhcPass 'Renamed) (GhcPass idR)
-> [(SrcSpan, [Name])]
hsValBindsImplicits HsValBindsLR (GhcPass 'Renamed) (GhcPass idR)
val_binds
hs_local_binds (HsIPBinds {}) = []
hs_local_binds (EmptyLocalBinds XEmptyLocalBinds (GhcPass 'Renamed) (GhcPass idR)
_) = []
hsValBindsImplicits :: HsValBindsLR GhcRn (GhcPass idR) -> [(SrcSpan, [Name])]
hsValBindsImplicits :: forall (idR :: Pass).
HsValBindsLR (GhcPass 'Renamed) (GhcPass idR)
-> [(SrcSpan, [Name])]
hsValBindsImplicits (XValBindsLR (NValBinds [(RecFlag, LHsBinds (GhcPass 'Renamed))]
binds [LSig (GhcPass 'Renamed)]
_))
= forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall idR.
LHsBindsLR (GhcPass 'Renamed) idR -> [(SrcSpan, [Name])]
lhsBindsImplicits forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) [(RecFlag, LHsBinds (GhcPass 'Renamed))]
binds
hsValBindsImplicits (ValBinds XValBinds (GhcPass 'Renamed) (GhcPass idR)
_ LHsBindsLR (GhcPass 'Renamed) (GhcPass idR)
binds [LSig (GhcPass idR)]
_)
= forall idR.
LHsBindsLR (GhcPass 'Renamed) idR -> [(SrcSpan, [Name])]
lhsBindsImplicits LHsBindsLR (GhcPass 'Renamed) (GhcPass idR)
binds
lhsBindsImplicits :: LHsBindsLR GhcRn idR -> [(SrcSpan, [Name])]
lhsBindsImplicits :: forall idR.
LHsBindsLR (GhcPass 'Renamed) idR -> [(SrcSpan, [Name])]
lhsBindsImplicits = forall r a. (r -> r -> r) -> (a -> r) -> r -> Bag a -> r
foldBag forall a. [a] -> [a] -> [a]
(++) (forall {idR}.
HsBindLR (GhcPass 'Renamed) idR -> [(SrcSpan, [Name])]
lhs_bind forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) []
where
lhs_bind :: HsBindLR (GhcPass 'Renamed) idR -> [(SrcSpan, [Name])]
lhs_bind (PatBind { pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat (GhcPass 'Renamed)
lpat }) = LPat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
lPatImplicits LPat (GhcPass 'Renamed)
lpat
lhs_bind HsBindLR (GhcPass 'Renamed) idR
_ = []
lPatImplicits :: LPat GhcRn -> [(SrcSpan, [Name])]
lPatImplicits :: LPat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
lPatImplicits = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat
where
hs_lpat :: LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
lpat = Pat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
hs_pat (forall l e. GenLocated l e -> e
unLoc LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
lpat)
hs_lpats :: [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
-> [(SrcSpan, [Name])]
hs_lpats = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
pat [(SrcSpan, [Name])]
rest -> LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
pat forall a. [a] -> [a] -> [a]
++ [(SrcSpan, [Name])]
rest) []
hs_pat :: Pat (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
hs_pat (LazyPat XLazyPat (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (BangPat XBangPat (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (AsPat XAsPat (GhcPass 'Renamed)
_ LIdP (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (ViewPat XViewPat (GhcPass 'Renamed)
_ LHsExpr (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (ParPat XParPat (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (ListPat XListPat (GhcPass 'Renamed)
_ [LPat (GhcPass 'Renamed)]
pats) = [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
-> [(SrcSpan, [Name])]
hs_lpats [LPat (GhcPass 'Renamed)]
pats
hs_pat (TuplePat XTuplePat (GhcPass 'Renamed)
_ [LPat (GhcPass 'Renamed)]
pats Boxity
_) = [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
-> [(SrcSpan, [Name])]
hs_lpats [LPat (GhcPass 'Renamed)]
pats
hs_pat (SigPat XSigPat (GhcPass 'Renamed)
_ LPat (GhcPass 'Renamed)
pat HsPatSigType (NoGhcTc (GhcPass 'Renamed))
_) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
pat
hs_pat (ConPat {pat_con :: forall p. Pat p -> XRec p (ConLikeP p)
pat_con=XRec (GhcPass 'Renamed) (ConLikeP (GhcPass 'Renamed))
con, pat_args :: forall p. Pat p -> HsConPatDetails p
pat_args=HsConPatDetails (GhcPass 'Renamed)
ps}) = GenLocated SrcSpanAnnN Name
-> HsConPatDetails (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
details XRec (GhcPass 'Renamed) (ConLikeP (GhcPass 'Renamed))
con HsConPatDetails (GhcPass 'Renamed)
ps
hs_pat Pat (GhcPass 'Renamed)
_ = []
details :: LocatedN Name -> HsConPatDetails GhcRn -> [(SrcSpan, [Name])]
details :: GenLocated SrcSpanAnnN Name
-> HsConPatDetails (GhcPass 'Renamed) -> [(SrcSpan, [Name])]
details GenLocated SrcSpanAnnN Name
_ (PrefixCon [HsPatSigType (NoGhcTc (GhcPass 'Renamed))]
_ [LPat (GhcPass 'Renamed)]
ps) = [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
-> [(SrcSpan, [Name])]
hs_lpats [LPat (GhcPass 'Renamed)]
ps
details GenLocated SrcSpanAnnN Name
n (RecCon HsRecFields (GhcPass 'Renamed) (LPat (GhcPass 'Renamed))
fs) =
[(SrcSpan
err_loc, forall p. CollectPass p => CollectFlag p -> [LPat p] -> [IdP p]
collectPatsBinders forall p. CollectFlag p
CollNoDictBinders [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
implicit_pats) | Just{} <- [forall p arg. HsRecFields p arg -> Maybe (Located Int)
rec_dotdot HsRecFields (GhcPass 'Renamed) (LPat (GhcPass 'Renamed))
fs] ]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
-> [(SrcSpan, [Name])]
hs_lpats [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
explicit_pats
where implicit_pats :: [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
implicit_pats = forall a b. (a -> b) -> [a] -> [b]
map (forall id arg. HsRecField' id arg -> arg
hsRecFieldArg forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))]
implicit
explicit_pats :: [LocatedAn AnnListItem (Pat (GhcPass 'Renamed))]
explicit_pats = forall a b. (a -> b) -> [a] -> [b]
map (forall id arg. HsRecField' id arg -> arg
hsRecFieldArg forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))]
explicit
([GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))]
explicit, [GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))]
implicit) = forall a b. [Either a b] -> ([a], [b])
partitionEithers [if Bool
pat_explicit then forall a b. a -> Either a b
Left GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))
fld else forall a b. b -> Either a b
Right GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))
fld
| (Int
i, GenLocated
SrcSpanAnnA
(HsRecField'
(FieldOcc (GhcPass 'Renamed))
(LocatedAn AnnListItem (Pat (GhcPass 'Renamed))))
fld) <- [Int
0..] forall a b. [a] -> [b] -> [(a, b)]
`zip` forall p arg. HsRecFields p arg -> [LHsRecField p arg]
rec_flds HsRecFields (GhcPass 'Renamed) (LPat (GhcPass 'Renamed))
fs
, let pat_explicit :: Bool
pat_explicit =
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True ((Int
iforall a. Ord a => a -> a -> Bool
<) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc)
(forall p arg. HsRecFields p arg -> Maybe (Located Int)
rec_dotdot HsRecFields (GhcPass 'Renamed) (LPat (GhcPass 'Renamed))
fs)]
err_loc :: SrcSpan
err_loc = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA GenLocated SrcSpanAnnN Name
n) forall l e. GenLocated l e -> l
getLoc (forall p arg. HsRecFields p arg -> Maybe (Located Int)
rec_dotdot HsRecFields (GhcPass 'Renamed) (LPat (GhcPass 'Renamed))
fs)
details GenLocated SrcSpanAnnN Name
_ (InfixCon LPat (GhcPass 'Renamed)
p1 LPat (GhcPass 'Renamed)
p2) = LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
p1 forall a. [a] -> [a] -> [a]
++ LocatedAn AnnListItem (Pat (GhcPass 'Renamed))
-> [(SrcSpan, [Name])]
hs_lpat LPat (GhcPass 'Renamed)
p2