{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module GHC.Hs.Binds
( module Language.Haskell.Syntax.Binds
, module GHC.Hs.Binds
) where
import GHC.Prelude
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Binds
import {-# SOURCE #-} GHC.Hs.Expr ( pprExpr, pprFunBind, pprPatBind )
import {-# SOURCE #-} GHC.Hs.Pat (pprLPat )
import GHC.Types.Tickish
import GHC.Hs.Extension
import GHC.Parser.Annotation
import GHC.Hs.Type
import GHC.Tc.Types.Evidence
import GHC.Core.Type
import GHC.Types.Name.Set
import GHC.Types.Basic
import GHC.Types.SourceText
import GHC.Types.SrcLoc as SrcLoc
import GHC.Types.Var
import GHC.Data.Bag
import GHC.Data.BooleanFormula (LBooleanFormula)
import GHC.Types.Name.Reader
import GHC.Types.Name
import GHC.Utils.Outputable
import GHC.Utils.Panic
import Data.Function
import Data.List (sortBy)
import Data.Data (Data)
type instance XHsValBinds (GhcPass pL) (GhcPass pR) = EpAnn AnnList
type instance XHsIPBinds (GhcPass pL) (GhcPass pR) = EpAnn AnnList
type instance XEmptyLocalBinds (GhcPass pL) (GhcPass pR) = NoExtField
type instance XXHsLocalBindsLR (GhcPass pL) (GhcPass pR) = DataConCantHappen
data NHsValBindsLR idL
= NValBinds
[(RecFlag, LHsBinds idL)]
[LSig GhcRn]
type instance XValBinds (GhcPass pL) (GhcPass pR) = AnnSortKey
type instance XXValBindsLR (GhcPass pL) pR
= NHsValBindsLR (GhcPass pL)
type instance XFunBind (GhcPass pL) GhcPs = NoExtField
type instance XFunBind (GhcPass pL) GhcRn = NameSet
type instance XFunBind (GhcPass pL) GhcTc = (HsWrapper, [CoreTickish])
type instance XPatBind GhcPs (GhcPass pR) = EpAnn [AddEpAnn]
type instance XPatBind GhcRn (GhcPass pR) = NameSet
type instance XPatBind GhcTc (GhcPass pR) =
( Type
, ( [CoreTickish]
, [[CoreTickish]] ) )
type instance XVarBind (GhcPass pL) (GhcPass pR) = NoExtField
type instance XPatSynBind (GhcPass pL) (GhcPass pR) = NoExtField
type instance XXHsBindsLR GhcPs pR = DataConCantHappen
type instance XXHsBindsLR GhcRn pR = DataConCantHappen
type instance XXHsBindsLR GhcTc pR = AbsBinds
type instance XPSB (GhcPass idL) GhcPs = EpAnn [AddEpAnn]
type instance XPSB (GhcPass idL) GhcRn = NameSet
type instance XPSB (GhcPass idL) GhcTc = NameSet
type instance XXPatSynBind (GhcPass idL) (GhcPass idR) = DataConCantHappen
data AbsBinds = AbsBinds {
AbsBinds -> [TyVar]
abs_tvs :: [TyVar],
AbsBinds -> [TyVar]
abs_ev_vars :: [EvVar],
AbsBinds -> [ABExport]
abs_exports :: [ABExport],
AbsBinds -> [TcEvBinds]
abs_ev_binds :: [TcEvBinds],
AbsBinds -> LHsBinds GhcTc
abs_binds :: LHsBinds GhcTc,
AbsBinds -> Bool
abs_sig :: Bool
}
data ABExport
= ABE { ABExport -> TyVar
abe_poly :: Id
, ABExport -> TyVar
abe_mono :: Id
, ABExport -> HsWrapper
abe_wrap :: HsWrapper
, ABExport -> TcSpecPrags
abe_prags :: TcSpecPrags
}
instance (OutputableBndrId pl, OutputableBndrId pr)
=> Outputable (HsLocalBindsLR (GhcPass pl) (GhcPass pr)) where
ppr :: HsLocalBindsLR (GhcPass pl) (GhcPass pr) -> SDoc
ppr (HsValBinds XHsValBinds (GhcPass pl) (GhcPass pr)
_ HsValBindsLR (GhcPass pl) (GhcPass pr)
bs) = forall a. Outputable a => a -> SDoc
ppr HsValBindsLR (GhcPass pl) (GhcPass pr)
bs
ppr (HsIPBinds XHsIPBinds (GhcPass pl) (GhcPass pr)
_ HsIPBinds (GhcPass pr)
bs) = forall a. Outputable a => a -> SDoc
ppr HsIPBinds (GhcPass pr)
bs
ppr (EmptyLocalBinds XEmptyLocalBinds (GhcPass pl) (GhcPass pr)
_) = forall doc. IsOutput doc => doc
empty
instance (OutputableBndrId pl, OutputableBndrId pr)
=> Outputable (HsValBindsLR (GhcPass pl) (GhcPass pr)) where
ppr :: HsValBindsLR (GhcPass pl) (GhcPass pr) -> SDoc
ppr (ValBinds XValBinds (GhcPass pl) (GhcPass pr)
_ LHsBindsLR (GhcPass pl) (GhcPass pr)
binds [LSig (GhcPass pr)]
sigs)
= [SDoc] -> SDoc
pprDeclList (forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
OutputableBndrId id2) =>
LHsBindsLR (GhcPass idL) (GhcPass idR)
-> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser LHsBindsLR (GhcPass pl) (GhcPass pr)
binds [LSig (GhcPass pr)]
sigs)
ppr (XValBindsLR (NValBinds [(RecFlag, LHsBinds (GhcPass pl))]
sccs [LSig GhcRn]
sigs))
= forall doc. IsOutput doc => (Bool -> doc) -> doc
getPprDebug forall a b. (a -> b) -> a -> b
$ \case
Bool
True -> forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LSig GhcRn]
sigs) forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall {idL :: Pass} {idR :: Pass}.
(OutputableBndr (IdGhcP idL), OutputableBndr (IdGhcP idR),
OutputableBndr (IdGhcP (NoGhcTcPass idL)),
OutputableBndr (IdGhcP (NoGhcTcPass idR)), IsPass idL, IsPass idR,
Outputable (GenLocated (Anno (IdGhcP idL)) (IdGhcP idL)),
Outputable (GenLocated (Anno (IdGhcP idR)) (IdGhcP idR)),
Outputable
(GenLocated
(Anno (IdGhcP (NoGhcTcPass idL))) (IdGhcP (NoGhcTcPass idL))),
Outputable
(GenLocated
(Anno (IdGhcP (NoGhcTcPass idR))) (IdGhcP (NoGhcTcPass idR)))) =>
(RecFlag,
Bag
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass idL) (GhcPass idR))))
-> SDoc
ppr_scc [(RecFlag, LHsBinds (GhcPass pl))]
sccs)
Bool
False -> [SDoc] -> SDoc
pprDeclList (forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
OutputableBndrId id2) =>
LHsBindsLR (GhcPass idL) (GhcPass idR)
-> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser (forall a. [Bag a] -> Bag a
unionManyBags (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(RecFlag, LHsBinds (GhcPass pl))]
sccs)) [LSig GhcRn]
sigs)
where
ppr_scc :: (RecFlag,
Bag
(GenLocated SrcSpanAnnA (HsBindLR (GhcPass idL) (GhcPass idR))))
-> SDoc
ppr_scc (RecFlag
rec_flag, Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass idL) (GhcPass idR)))
binds) = forall {doc}. IsLine doc => RecFlag -> doc
pp_rec RecFlag
rec_flag forall doc. IsLine doc => doc -> doc -> doc
<+> forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds Bag (GenLocated SrcSpanAnnA (HsBindLR (GhcPass idL) (GhcPass idR)))
binds
pp_rec :: RecFlag -> doc
pp_rec RecFlag
Recursive = forall doc. IsLine doc => String -> doc
text String
"rec"
pp_rec RecFlag
NonRecursive = forall doc. IsLine doc => String -> doc
text String
"nonrec"
pprLHsBinds :: (OutputableBndrId idL, OutputableBndrId idR)
=> LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds :: forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds LHsBindsLR (GhcPass idL) (GhcPass idR)
binds
| forall (idL :: Pass) idR. LHsBindsLR (GhcPass idL) idR -> Bool
isEmptyLHsBinds LHsBindsLR (GhcPass idL) (GhcPass idR)
binds = forall doc. IsOutput doc => doc
empty
| Bool
otherwise = [SDoc] -> SDoc
pprDeclList (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr (forall a. Bag a -> [a]
bagToList LHsBindsLR (GhcPass idL) (GhcPass idR)
binds))
pprLHsBindsForUser :: (OutputableBndrId idL,
OutputableBndrId idR,
OutputableBndrId id2)
=> LHsBindsLR (GhcPass idL) (GhcPass idR) -> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser :: forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
OutputableBndrId id2) =>
LHsBindsLR (GhcPass idL) (GhcPass idR)
-> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser LHsBindsLR (GhcPass idL) (GhcPass idR)
binds [LSig (GhcPass id2)]
sigs
= forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd (forall {b}. [(SrcSpan, b)] -> [(SrcSpan, b)]
sort_by_loc [(SrcSpan, SDoc)]
decls)
where
decls :: [(SrcSpan, SDoc)]
decls :: [(SrcSpan, SDoc)]
decls = [(forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
loc, forall a. Outputable a => a -> SDoc
ppr Sig (GhcPass id2)
sig) | L SrcSpanAnnA
loc Sig (GhcPass id2)
sig <- [LSig (GhcPass id2)]
sigs] forall a. [a] -> [a] -> [a]
++
[(forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
loc, forall a. Outputable a => a -> SDoc
ppr HsBindLR (GhcPass idL) (GhcPass idR)
bind) | L SrcSpanAnnA
loc HsBindLR (GhcPass idL) (GhcPass idR)
bind <- forall a. Bag a -> [a]
bagToList LHsBindsLR (GhcPass idL) (GhcPass idR)
binds]
sort_by_loc :: [(SrcSpan, b)] -> [(SrcSpan, b)]
sort_by_loc [(SrcSpan, b)]
decls = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (SrcSpan -> SrcSpan -> Ordering
SrcLoc.leftmost_smallest forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a b. (a, b) -> a
fst) [(SrcSpan, b)]
decls
pprDeclList :: [SDoc] -> SDoc
pprDeclList :: [SDoc] -> SDoc
pprDeclList [SDoc]
ds = ([SDoc] -> SDoc) -> [SDoc] -> SDoc
pprDeeperList forall doc. IsDoc doc => [doc] -> doc
vcat [SDoc]
ds
emptyLocalBinds :: HsLocalBindsLR (GhcPass a) (GhcPass b)
emptyLocalBinds :: forall (a :: Pass) (b :: Pass).
HsLocalBindsLR (GhcPass a) (GhcPass b)
emptyLocalBinds = forall idL idR. XEmptyLocalBinds idL idR -> HsLocalBindsLR idL idR
EmptyLocalBinds NoExtField
noExtField
eqEmptyLocalBinds :: HsLocalBindsLR a b -> Bool
eqEmptyLocalBinds :: forall a b. HsLocalBindsLR a b -> Bool
eqEmptyLocalBinds (EmptyLocalBinds XEmptyLocalBinds a b
_) = Bool
True
eqEmptyLocalBinds HsLocalBindsLR a b
_ = Bool
False
isEmptyValBinds :: HsValBindsLR (GhcPass a) (GhcPass b) -> Bool
isEmptyValBinds :: forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b) -> Bool
isEmptyValBinds (ValBinds XValBinds (GhcPass a) (GhcPass b)
_ LHsBindsLR (GhcPass a) (GhcPass b)
ds [LSig (GhcPass b)]
sigs) = forall (idL :: Pass) idR. LHsBindsLR (GhcPass idL) idR -> Bool
isEmptyLHsBinds LHsBindsLR (GhcPass a) (GhcPass b)
ds Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig (GhcPass b)]
sigs
isEmptyValBinds (XValBindsLR (NValBinds [(RecFlag, LHsBinds (GhcPass a))]
ds [LSig GhcRn]
sigs)) = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(RecFlag, LHsBinds (GhcPass a))]
ds Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig GhcRn]
sigs
emptyValBindsIn, emptyValBindsOut :: HsValBindsLR (GhcPass a) (GhcPass b)
emptyValBindsIn :: forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b)
emptyValBindsIn = forall idL idR.
XValBinds idL idR
-> LHsBindsLR idL idR -> [LSig idR] -> HsValBindsLR idL idR
ValBinds AnnSortKey
NoAnnSortKey forall a. Bag a
emptyBag []
emptyValBindsOut :: forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b)
emptyValBindsOut = forall idL idR. XXValBindsLR idL idR -> HsValBindsLR idL idR
XValBindsLR (forall idL.
[(RecFlag, LHsBinds idL)] -> [LSig GhcRn] -> NHsValBindsLR idL
NValBinds [] [])
emptyLHsBinds :: LHsBindsLR (GhcPass idL) idR
emptyLHsBinds :: forall (idL :: Pass) idR. LHsBindsLR (GhcPass idL) idR
emptyLHsBinds = forall a. Bag a
emptyBag
isEmptyLHsBinds :: LHsBindsLR (GhcPass idL) idR -> Bool
isEmptyLHsBinds :: forall (idL :: Pass) idR. LHsBindsLR (GhcPass idL) idR -> Bool
isEmptyLHsBinds = forall a. Bag a -> Bool
isEmptyBag
plusHsValBinds :: HsValBinds (GhcPass a) -> HsValBinds (GhcPass a)
-> HsValBinds(GhcPass a)
plusHsValBinds :: forall (a :: Pass).
HsValBinds (GhcPass a)
-> HsValBinds (GhcPass a) -> HsValBinds (GhcPass a)
plusHsValBinds (ValBinds XValBinds (GhcPass a) (GhcPass a)
_ LHsBindsLR (GhcPass a) (GhcPass a)
ds1 [LSig (GhcPass a)]
sigs1) (ValBinds XValBinds (GhcPass a) (GhcPass a)
_ LHsBindsLR (GhcPass a) (GhcPass a)
ds2 [LSig (GhcPass a)]
sigs2)
= forall idL idR.
XValBinds idL idR
-> LHsBindsLR idL idR -> [LSig idR] -> HsValBindsLR idL idR
ValBinds AnnSortKey
NoAnnSortKey (LHsBindsLR (GhcPass a) (GhcPass a)
ds1 forall a. Bag a -> Bag a -> Bag a
`unionBags` LHsBindsLR (GhcPass a) (GhcPass a)
ds2) ([LSig (GhcPass a)]
sigs1 forall a. [a] -> [a] -> [a]
++ [LSig (GhcPass a)]
sigs2)
plusHsValBinds (XValBindsLR (NValBinds [(RecFlag, LHsBindsLR (GhcPass a) (GhcPass a))]
ds1 [LSig GhcRn]
sigs1))
(XValBindsLR (NValBinds [(RecFlag, LHsBindsLR (GhcPass a) (GhcPass a))]
ds2 [LSig GhcRn]
sigs2))
= forall idL idR. XXValBindsLR idL idR -> HsValBindsLR idL idR
XValBindsLR (forall idL.
[(RecFlag, LHsBinds idL)] -> [LSig GhcRn] -> NHsValBindsLR idL
NValBinds ([(RecFlag, LHsBindsLR (GhcPass a) (GhcPass a))]
ds1 forall a. [a] -> [a] -> [a]
++ [(RecFlag, LHsBindsLR (GhcPass a) (GhcPass a))]
ds2) ([LSig GhcRn]
sigs1 forall a. [a] -> [a] -> [a]
++ [LSig GhcRn]
sigs2))
plusHsValBinds HsValBindsLR (GhcPass a) (GhcPass a)
_ HsValBindsLR (GhcPass a) (GhcPass a)
_
= forall a. HasCallStack => String -> a
panic String
"HsBinds.plusHsValBinds"
instance (OutputableBndrId pl, OutputableBndrId pr)
=> Outputable (HsBindLR (GhcPass pl) (GhcPass pr)) where
ppr :: HsBindLR (GhcPass pl) (GhcPass pr) -> SDoc
ppr HsBindLR (GhcPass pl) (GhcPass pr)
mbind = forall (pl :: Pass) (pr :: Pass).
(OutputableBndrId pl, OutputableBndrId pr) =>
HsBindLR (GhcPass pl) (GhcPass pr) -> SDoc
ppr_monobind HsBindLR (GhcPass pl) (GhcPass pr)
mbind
ppr_monobind :: forall idL idR.
(OutputableBndrId idL, OutputableBndrId idR)
=> HsBindLR (GhcPass idL) (GhcPass idR) -> SDoc
ppr_monobind :: forall (pl :: Pass) (pr :: Pass).
(OutputableBndrId pl, OutputableBndrId pr) =>
HsBindLR (GhcPass pl) (GhcPass pr) -> SDoc
ppr_monobind (PatBind { pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_lhs = LPat (GhcPass idL)
pat, pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_rhs = GRHSs (GhcPass idR) (LHsExpr (GhcPass idR))
grhss })
= forall (bndr :: Pass) (p :: Pass).
(OutputableBndrId bndr, OutputableBndrId p) =>
LPat (GhcPass bndr)
-> GRHSs (GhcPass p) (LHsExpr (GhcPass p)) -> SDoc
pprPatBind LPat (GhcPass idL)
pat GRHSs (GhcPass idR) (LHsExpr (GhcPass idR))
grhss
ppr_monobind (VarBind { var_id :: forall idL idR. HsBindLR idL idR -> IdP idL
var_id = IdP (GhcPass idL)
var, var_rhs :: forall idL idR. HsBindLR idL idR -> LHsExpr idR
var_rhs = LHsExpr (GhcPass idR)
rhs })
= forall doc. IsLine doc => [doc] -> doc
sep [forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
CasePatBind IdP (GhcPass idL)
var, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (forall l e. GenLocated l e -> e
unLoc LHsExpr (GhcPass idR)
rhs)]
ppr_monobind (FunBind { fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_id = LIdP (GhcPass idL)
fun,
fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_matches = MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR))
matches,
fun_ext :: forall idL idR. HsBindLR idL idR -> XFunBind idL idR
fun_ext = XFunBind (GhcPass idL) (GhcPass idR)
ext })
= SDoc -> SDoc -> SDoc
pprTicks forall doc. IsOutput doc => doc
empty SDoc
ticksDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsOutput doc => doc -> doc
whenPprDebug (forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LetBind (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass idL)
fun))
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall (idR :: Pass).
OutputableBndrId idR =>
MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR)) -> SDoc
pprFunBind MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR))
matches
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsOutput doc => doc -> doc
whenPprDebug (forall (p :: Pass).
IsPass p =>
((p ~ 'Typechecked) => SDoc) -> SDoc
pprIfTc @idR forall a b. (a -> b) -> a -> b
$ SDoc
wrapDoc)
where
ticksDoc :: SDoc
ticksDoc :: SDoc
ticksDoc = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @idR of
GhcPass idR
GhcPs -> forall doc. IsOutput doc => doc
empty
GhcPass idR
GhcRn -> forall doc. IsOutput doc => doc
empty
GhcPass idR
GhcTc | (HsWrapper
_, [CoreTickish]
ticks) <- XFunBind (GhcPass idL) (GhcPass idR)
ext ->
if forall (t :: * -> *) a. Foldable t => t a -> Bool
null [CoreTickish]
ticks
then forall doc. IsOutput doc => doc
empty
else forall doc. IsLine doc => String -> doc
text String
"-- ticks = " forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr [CoreTickish]
ticks
wrapDoc :: SDoc
wrapDoc :: SDoc
wrapDoc = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @idR of
GhcPass idR
GhcPs -> forall doc. IsOutput doc => doc
empty
GhcPass idR
GhcRn -> forall doc. IsOutput doc => doc
empty
GhcPass idR
GhcTc | (HsWrapper
wrap, [CoreTickish]
_) <- XFunBind (GhcPass idL) (GhcPass idR)
ext -> forall a. Outputable a => a -> SDoc
ppr HsWrapper
wrap
ppr_monobind (PatSynBind XPatSynBind (GhcPass idL) (GhcPass idR)
_ PatSynBind (GhcPass idL) (GhcPass idR)
psb) = forall a. Outputable a => a -> SDoc
ppr PatSynBind (GhcPass idL) (GhcPass idR)
psb
ppr_monobind (XHsBindsLR XXHsBindsLR (GhcPass idL) (GhcPass idR)
b) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @idL of
#if __GLASGOW_HASKELL__ <= 900
GhcPs -> dataConCantHappen b
GhcRn -> dataConCantHappen b
#endif
GhcPass idL
GhcTc -> AbsBinds -> SDoc
ppr_absbinds XXHsBindsLR (GhcPass idL) (GhcPass idR)
b
where
ppr_absbinds :: AbsBinds -> SDoc
ppr_absbinds (AbsBinds { abs_tvs :: AbsBinds -> [TyVar]
abs_tvs = [TyVar]
tyvars, abs_ev_vars :: AbsBinds -> [TyVar]
abs_ev_vars = [TyVar]
dictvars
, abs_exports :: AbsBinds -> [ABExport]
abs_exports = [ABExport]
exports, abs_binds :: AbsBinds -> LHsBinds GhcTc
abs_binds = LHsBinds GhcTc
val_binds
, abs_ev_binds :: AbsBinds -> [TcEvBinds]
abs_ev_binds = [TcEvBinds]
ev_binds })
= forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintTypecheckerElaboration forall a b. (a -> b) -> a -> b
$ \case
Bool
False -> forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds LHsBinds GhcTc
val_binds
Bool
True ->
SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"AbsBinds"
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
sep [ forall doc. IsLine doc => doc -> doc
brackets (forall a. Outputable a => [a] -> SDoc
interpp'SP [TyVar]
tyvars)
, forall doc. IsLine doc => doc -> doc
brackets (forall a. Outputable a => [a] -> SDoc
interpp'SP [TyVar]
dictvars) ])
Int
2 forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc -> doc
braces forall a b. (a -> b) -> a -> b
$ forall doc. IsDoc doc => [doc] -> doc
vcat
[ forall doc. IsLine doc => String -> doc
text String
"Exports:" forall doc. IsLine doc => doc -> doc -> doc
<+>
forall doc. IsLine doc => doc -> doc
brackets (forall doc. IsLine doc => [doc] -> doc
sep (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [ABExport]
exports)))
, forall doc. IsLine doc => String -> doc
text String
"Exported types:" forall doc. IsLine doc => doc -> doc -> doc
<+>
forall doc. IsDoc doc => [doc] -> doc
vcat [forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LetBind (ABExport -> TyVar
abe_poly ABExport
ex) | ABExport
ex <- [ABExport]
exports]
, forall doc. IsLine doc => String -> doc
text String
"Binds:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall (idL :: Pass) (idR :: Pass).
(OutputableBndrId idL, OutputableBndrId idR) =>
LHsBindsLR (GhcPass idL) (GhcPass idR) -> SDoc
pprLHsBinds LHsBinds GhcTc
val_binds
, forall (p :: Pass).
IsPass p =>
((p ~ 'Typechecked) => SDoc) -> SDoc
pprIfTc @idR (forall doc. IsLine doc => String -> doc
text String
"Evidence:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr [TcEvBinds]
ev_binds)
]
instance Outputable ABExport where
ppr :: ABExport -> SDoc
ppr (ABE { abe_wrap :: ABExport -> HsWrapper
abe_wrap = HsWrapper
wrap, abe_poly :: ABExport -> TyVar
abe_poly = TyVar
gbl, abe_mono :: ABExport -> TyVar
abe_mono = TyVar
lcl, abe_prags :: ABExport -> TcSpecPrags
abe_prags = TcSpecPrags
prags })
= forall doc. IsDoc doc => [doc] -> doc
vcat [ forall doc. IsLine doc => [doc] -> doc
sep [ forall a. Outputable a => a -> SDoc
ppr TyVar
gbl, Int -> SDoc -> SDoc
nest Int
2 (forall doc. IsLine doc => String -> doc
text String
"<=" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr TyVar
lcl) ]
, Int -> SDoc -> SDoc
nest Int
2 (TcSpecPrags -> SDoc
pprTcSpecPrags TcSpecPrags
prags)
, forall a. Outputable a => a -> SDoc
ppr forall a b. (a -> b) -> a -> b
$ Int -> SDoc -> SDoc
nest Int
2 (forall doc. IsLine doc => String -> doc
text String
"wrap:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr HsWrapper
wrap) ]
instance (OutputableBndrId l, OutputableBndrId r)
=> Outputable (PatSynBind (GhcPass l) (GhcPass r)) where
ppr :: PatSynBind (GhcPass l) (GhcPass r) -> SDoc
ppr (PSB{ psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_id = (L Anno (IdGhcP l)
_ IdGhcP l
psyn), psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_args = HsPatSynDetails (GhcPass r)
details, psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_def = LPat (GhcPass r)
pat,
psb_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
psb_dir = HsPatSynDir (GhcPass r)
dir })
= SDoc
ppr_lhs forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
ppr_rhs
where
ppr_lhs :: SDoc
ppr_lhs = forall doc. IsLine doc => String -> doc
text String
"pattern" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
ppr_details
ppr_simple :: SDoc -> SDoc
ppr_simple SDoc
syntax = SDoc
syntax forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass). OutputableBndrId p => LPat (GhcPass p) -> SDoc
pprLPat LPat (GhcPass r)
pat
ppr_details :: SDoc
ppr_details = case HsPatSynDetails (GhcPass r)
details of
InfixCon LIdP (GhcPass r)
v1 LIdP (GhcPass r)
v2 -> forall doc. IsLine doc => [doc] -> doc
hsep [GenLocated (Anno (IdGhcP r)) (IdGhcP r) -> SDoc
ppr_v LIdP (GhcPass r)
v1, forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP l
psyn, GenLocated (Anno (IdGhcP r)) (IdGhcP r) -> SDoc
ppr_v LIdP (GhcPass r)
v2]
where
ppr_v :: GenLocated (Anno (IdGhcP r)) (IdGhcP r) -> SDoc
ppr_v GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @r of
GhcPass r
GhcPs -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
GhcPass r
GhcRn -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
GhcPass r
GhcTc -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
PrefixCon [Void]
_ [LIdP (GhcPass r)]
vs -> forall doc. IsLine doc => [doc] -> doc
hsep (forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP l
psyn forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map GenLocated (Anno (IdGhcP r)) (IdGhcP r) -> SDoc
ppr_v [LIdP (GhcPass r)]
vs)
where
ppr_v :: GenLocated (Anno (IdGhcP r)) (IdGhcP r) -> SDoc
ppr_v GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @r of
GhcPass r
GhcPs -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
GhcPass r
GhcRn -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
GhcPass r
GhcTc -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP r)) (IdGhcP r)
v
RecCon [RecordPatSynField (GhcPass r)]
vs -> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP l
psyn
forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
braces (forall doc. IsLine doc => [doc] -> doc
sep (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map RecordPatSynField (GhcPass r) -> SDoc
ppr_v [RecordPatSynField (GhcPass r)]
vs)))
where
ppr_v :: RecordPatSynField (GhcPass r) -> SDoc
ppr_v RecordPatSynField (GhcPass r)
v = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @r of
GhcPass r
GhcPs -> forall a. Outputable a => a -> SDoc
ppr RecordPatSynField (GhcPass r)
v
GhcPass r
GhcRn -> forall a. Outputable a => a -> SDoc
ppr RecordPatSynField (GhcPass r)
v
GhcPass r
GhcTc -> forall a. Outputable a => a -> SDoc
ppr RecordPatSynField (GhcPass r)
v
ppr_rhs :: SDoc
ppr_rhs = case HsPatSynDir (GhcPass r)
dir of
HsPatSynDir (GhcPass r)
Unidirectional -> SDoc -> SDoc
ppr_simple (forall doc. IsLine doc => String -> doc
text String
"<-")
HsPatSynDir (GhcPass r)
ImplicitBidirectional -> SDoc -> SDoc
ppr_simple forall doc. IsLine doc => doc
equals
ExplicitBidirectional MatchGroup (GhcPass r) (LHsExpr (GhcPass r))
mg -> SDoc -> SDoc
ppr_simple (forall doc. IsLine doc => String -> doc
text String
"<-") forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"where" forall doc. IsDoc doc => doc -> doc -> doc
$$
(Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ forall (idR :: Pass).
OutputableBndrId idR =>
MatchGroup (GhcPass idR) (LHsExpr (GhcPass idR)) -> SDoc
pprFunBind MatchGroup (GhcPass r) (LHsExpr (GhcPass r))
mg)
pprTicks :: SDoc -> SDoc -> SDoc
pprTicks :: SDoc -> SDoc -> SDoc
pprTicks SDoc
pp_no_debug SDoc
pp_when_debug
= (PprStyle -> SDoc) -> SDoc
getPprStyle forall a b. (a -> b) -> a -> b
$ \PprStyle
sty ->
forall doc. IsOutput doc => (Bool -> doc) -> doc
getPprDebug forall a b. (a -> b) -> a -> b
$ \Bool
debug ->
if Bool
debug Bool -> Bool -> Bool
|| PprStyle -> Bool
dumpStyle PprStyle
sty
then SDoc
pp_when_debug
else SDoc
pp_no_debug
instance Outputable (XRec a RdrName) => Outputable (RecordPatSynField a) where
ppr :: RecordPatSynField a -> SDoc
ppr (RecordPatSynField { recordPatSynField :: forall pass. RecordPatSynField pass -> FieldOcc pass
recordPatSynField = FieldOcc a
v }) = forall a. Outputable a => a -> SDoc
ppr FieldOcc a
v
type instance XIPBinds GhcPs = NoExtField
type instance XIPBinds GhcRn = NoExtField
type instance XIPBinds GhcTc = TcEvBinds
type instance XXHsIPBinds (GhcPass p) = DataConCantHappen
isEmptyIPBindsPR :: HsIPBinds (GhcPass p) -> Bool
isEmptyIPBindsPR :: forall (p :: Pass). HsIPBinds (GhcPass p) -> Bool
isEmptyIPBindsPR (IPBinds XIPBinds (GhcPass p)
_ [LIPBind (GhcPass p)]
is) = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LIPBind (GhcPass p)]
is
isEmptyIPBindsTc :: HsIPBinds GhcTc -> Bool
isEmptyIPBindsTc :: HsIPBinds GhcTc -> Bool
isEmptyIPBindsTc (IPBinds XIPBinds GhcTc
ds [LIPBind GhcTc]
is) = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LIPBind GhcTc]
is Bool -> Bool -> Bool
&& TcEvBinds -> Bool
isEmptyTcEvBinds XIPBinds GhcTc
ds
type instance XCIPBind GhcPs = EpAnn [AddEpAnn]
type instance XCIPBind GhcRn = NoExtField
type instance XCIPBind GhcTc = Id
type instance XXIPBind (GhcPass p) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (HsIPBinds (GhcPass p)) where
ppr :: HsIPBinds (GhcPass p) -> SDoc
ppr (IPBinds XIPBinds (GhcPass p)
ds [LIPBind (GhcPass p)]
bs) = ([SDoc] -> SDoc) -> [SDoc] -> SDoc
pprDeeperList forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LIPBind (GhcPass p)]
bs)
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsOutput doc => doc -> doc
whenPprDebug (forall (p :: Pass).
IsPass p =>
((p ~ 'Typechecked) => SDoc) -> SDoc
pprIfTc @p forall a b. (a -> b) -> a -> b
$ forall a. Outputable a => a -> SDoc
ppr XIPBinds (GhcPass p)
ds)
instance OutputableBndrId p => Outputable (IPBind (GhcPass p)) where
ppr :: IPBind (GhcPass p) -> SDoc
ppr (IPBind XCIPBind (GhcPass p)
x (L SrcAnn NoEpAnns
_ HsIPName
ip) LHsExpr (GhcPass p)
rhs) = SDoc
name forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (forall l e. GenLocated l e -> e
unLoc LHsExpr (GhcPass p)
rhs)
where name :: SDoc
name = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs -> forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LetBind HsIPName
ip
GhcPass p
GhcRn -> forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LetBind HsIPName
ip
GhcPass p
GhcTc -> forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LetBind XCIPBind (GhcPass p)
x
type instance XTypeSig (GhcPass p) = EpAnn AnnSig
type instance XPatSynSig (GhcPass p) = EpAnn AnnSig
type instance XClassOpSig (GhcPass p) = EpAnn AnnSig
type instance XFixSig (GhcPass p) = EpAnn [AddEpAnn]
type instance XInlineSig (GhcPass p) = EpAnn [AddEpAnn]
type instance XSpecSig (GhcPass p) = EpAnn [AddEpAnn]
type instance XSpecInstSig (GhcPass p) = (EpAnn [AddEpAnn], SourceText)
type instance XMinimalSig (GhcPass p) = (EpAnn [AddEpAnn], SourceText)
type instance XSCCFunSig (GhcPass p) = (EpAnn [AddEpAnn], SourceText)
type instance XCompleteMatchSig (GhcPass p) = (EpAnn [AddEpAnn], SourceText)
type instance XXSig GhcPs = DataConCantHappen
type instance XXSig GhcRn = IdSig
type instance XXSig GhcTc = IdSig
type instance XFixitySig (GhcPass p) = NoExtField
type instance XXFixitySig (GhcPass p) = DataConCantHappen
newtype IdSig = IdSig { IdSig -> TyVar
unIdSig :: Id }
deriving Typeable IdSig
IdSig -> DataType
IdSig -> Constr
(forall b. Data b => b -> b) -> IdSig -> IdSig
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> IdSig -> u
forall u. (forall d. Data d => d -> u) -> IdSig -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IdSig
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IdSig -> c IdSig
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IdSig)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IdSig)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IdSig -> m IdSig
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> IdSig -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> IdSig -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> IdSig -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IdSig -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IdSig -> r
gmapT :: (forall b. Data b => b -> b) -> IdSig -> IdSig
$cgmapT :: (forall b. Data b => b -> b) -> IdSig -> IdSig
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IdSig)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IdSig)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IdSig)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IdSig)
dataTypeOf :: IdSig -> DataType
$cdataTypeOf :: IdSig -> DataType
toConstr :: IdSig -> Constr
$ctoConstr :: IdSig -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IdSig
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IdSig
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IdSig -> c IdSig
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IdSig -> c IdSig
Data
data AnnSig
= AnnSig {
AnnSig -> AddEpAnn
asDcolon :: AddEpAnn,
AnnSig -> [AddEpAnn]
asRest :: [AddEpAnn]
} deriving Typeable AnnSig
AnnSig -> DataType
AnnSig -> Constr
(forall b. Data b => b -> b) -> AnnSig -> AnnSig
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AnnSig -> u
forall u. (forall d. Data d => d -> u) -> AnnSig -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSig
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSig -> c AnnSig
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSig)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSig)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSig -> m AnnSig
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSig -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSig -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSig -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSig -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnnSig -> r
gmapT :: (forall b. Data b => b -> b) -> AnnSig -> AnnSig
$cgmapT :: (forall b. Data b => b -> b) -> AnnSig -> AnnSig
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSig)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSig)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSig)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSig)
dataTypeOf :: AnnSig -> DataType
$cdataTypeOf :: AnnSig -> DataType
toConstr :: AnnSig -> Constr
$ctoConstr :: AnnSig -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSig
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSig
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSig -> c AnnSig
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSig -> c AnnSig
Data
data TcSpecPrags
= IsDefaultMethod
| SpecPrags [LTcSpecPrag]
deriving Typeable TcSpecPrags
TcSpecPrags -> DataType
TcSpecPrags -> Constr
(forall b. Data b => b -> b) -> TcSpecPrags -> TcSpecPrags
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrags -> u
forall u. (forall d. Data d => d -> u) -> TcSpecPrags -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrags
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrags -> c TcSpecPrags
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrags)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TcSpecPrags)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrags -> m TcSpecPrags
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrags -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrags -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TcSpecPrags -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TcSpecPrags -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrags -> r
gmapT :: (forall b. Data b => b -> b) -> TcSpecPrags -> TcSpecPrags
$cgmapT :: (forall b. Data b => b -> b) -> TcSpecPrags -> TcSpecPrags
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TcSpecPrags)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TcSpecPrags)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrags)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrags)
dataTypeOf :: TcSpecPrags -> DataType
$cdataTypeOf :: TcSpecPrags -> DataType
toConstr :: TcSpecPrags -> Constr
$ctoConstr :: TcSpecPrags -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrags
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrags
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrags -> c TcSpecPrags
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrags -> c TcSpecPrags
Data
type LTcSpecPrag = Located TcSpecPrag
data TcSpecPrag
= SpecPrag
Id
HsWrapper
InlinePragma
deriving Typeable TcSpecPrag
TcSpecPrag -> DataType
TcSpecPrag -> Constr
(forall b. Data b => b -> b) -> TcSpecPrag -> TcSpecPrag
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrag -> u
forall u. (forall d. Data d => d -> u) -> TcSpecPrag -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrag
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrag -> c TcSpecPrag
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrag)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TcSpecPrag)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TcSpecPrag -> m TcSpecPrag
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrag -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TcSpecPrag -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TcSpecPrag -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TcSpecPrag -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TcSpecPrag -> r
gmapT :: (forall b. Data b => b -> b) -> TcSpecPrag -> TcSpecPrag
$cgmapT :: (forall b. Data b => b -> b) -> TcSpecPrag -> TcSpecPrag
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TcSpecPrag)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TcSpecPrag)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrag)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TcSpecPrag)
dataTypeOf :: TcSpecPrag -> DataType
$cdataTypeOf :: TcSpecPrag -> DataType
toConstr :: TcSpecPrag -> Constr
$ctoConstr :: TcSpecPrag -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrag
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcSpecPrag
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrag -> c TcSpecPrag
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TcSpecPrag -> c TcSpecPrag
Data
noSpecPrags :: TcSpecPrags
noSpecPrags :: TcSpecPrags
noSpecPrags = [LTcSpecPrag] -> TcSpecPrags
SpecPrags []
hasSpecPrags :: TcSpecPrags -> Bool
hasSpecPrags :: TcSpecPrags -> Bool
hasSpecPrags (SpecPrags [LTcSpecPrag]
ps) = Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTcSpecPrag]
ps)
hasSpecPrags TcSpecPrags
IsDefaultMethod = Bool
False
isDefaultMethod :: TcSpecPrags -> Bool
isDefaultMethod :: TcSpecPrags -> Bool
isDefaultMethod TcSpecPrags
IsDefaultMethod = Bool
True
isDefaultMethod (SpecPrags {}) = Bool
False
instance OutputableBndrId p => Outputable (Sig (GhcPass p)) where
ppr :: Sig (GhcPass p) -> SDoc
ppr Sig (GhcPass p)
sig = forall (p :: Pass). OutputableBndrId p => Sig (GhcPass p) -> SDoc
ppr_sig Sig (GhcPass p)
sig
ppr_sig :: forall p. OutputableBndrId p
=> Sig (GhcPass p) -> SDoc
ppr_sig :: forall (p :: Pass). OutputableBndrId p => Sig (GhcPass p) -> SDoc
ppr_sig (TypeSig XTypeSig (GhcPass p)
_ [LIdP (GhcPass p)]
vars LHsSigWcType (GhcPass p)
ty) = forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig (forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
vars) (forall a. Outputable a => a -> SDoc
ppr LHsSigWcType (GhcPass p)
ty)
ppr_sig (ClassOpSig XClassOpSig (GhcPass p)
_ Bool
is_deflt [LIdP (GhcPass p)]
vars LHsSigType (GhcPass p)
ty)
| Bool
is_deflt = forall doc. IsLine doc => String -> doc
text String
"default" forall doc. IsLine doc => doc -> doc -> doc
<+> forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig (forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
vars) (forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty)
| Bool
otherwise = forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig (forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
vars) (forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty)
ppr_sig (FixSig XFixSig (GhcPass p)
_ FixitySig (GhcPass p)
fix_sig) = forall a. Outputable a => a -> SDoc
ppr FixitySig (GhcPass p)
fix_sig
ppr_sig (SpecSig XSpecSig (GhcPass p)
_ LIdP (GhcPass p)
var [LHsSigType (GhcPass p)]
ty inl :: InlinePragma
inl@(InlinePragma { inl_inline :: InlinePragma -> InlineSpec
inl_inline = InlineSpec
spec }))
= SourceText -> String -> SDoc -> SDoc
pragSrcBrackets (InlinePragma -> SourceText
inlinePragmaSource InlinePragma
inl) String
pragmaSrc (forall id. OutputableBndr id => id -> SDoc -> InlinePragma -> SDoc
pprSpec (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
var)
(forall a. Outputable a => [a] -> SDoc
interpp'SP [LHsSigType (GhcPass p)]
ty) InlinePragma
inl)
where
pragmaSrc :: String
pragmaSrc = case InlineSpec
spec of
InlineSpec
NoUserInlinePrag -> String
"{-# " forall a. [a] -> [a] -> [a]
++ SourceText -> String
extractSpecPragName (InlinePragma -> SourceText
inl_src InlinePragma
inl)
InlineSpec
_ -> String
"{-# " forall a. [a] -> [a] -> [a]
++ SourceText -> String
extractSpecPragName (InlinePragma -> SourceText
inl_src InlinePragma
inl) forall a. [a] -> [a] -> [a]
++ String
"_INLINE"
ppr_sig (InlineSig XInlineSig (GhcPass p)
_ LIdP (GhcPass p)
var InlinePragma
inl)
= SDoc
ppr_pfx forall doc. IsLine doc => doc -> doc -> doc
<+> InlinePragma -> SDoc
pprInline InlinePragma
inl forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
var) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
where
ppr_pfx :: SDoc
ppr_pfx = case InlinePragma -> SourceText
inlinePragmaSource InlinePragma
inl of
SourceText String
src -> forall doc. IsLine doc => String -> doc
text String
src
SourceText
NoSourceText -> forall doc. IsLine doc => String -> doc
text String
"{-#" forall doc. IsLine doc => doc -> doc -> doc
<+> InlineSpec -> SDoc
inlinePragmaName (InlinePragma -> InlineSpec
inl_inline InlinePragma
inl)
ppr_sig (SpecInstSig (EpAnn [AddEpAnn]
_, SourceText
src) LHsSigType (GhcPass p)
ty)
= SourceText -> String -> SDoc -> SDoc
pragSrcBrackets SourceText
src String
"{-# pragma" (forall doc. IsLine doc => String -> doc
text String
"instance" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty)
ppr_sig (MinimalSig (EpAnn [AddEpAnn]
_, SourceText
src) LBooleanFormula (LIdP (GhcPass p))
bf)
= SourceText -> String -> SDoc -> SDoc
pragSrcBrackets SourceText
src String
"{-# MINIMAL" (forall name l.
OutputableBndr name =>
LBooleanFormula (GenLocated l name) -> SDoc
pprMinimalSig LBooleanFormula (LIdP (GhcPass p))
bf)
ppr_sig (PatSynSig XPatSynSig (GhcPass p)
_ [LIdP (GhcPass p)]
names LHsSigType (GhcPass p)
sig_ty)
= forall doc. IsLine doc => String -> doc
text String
"pattern" forall doc. IsLine doc => doc -> doc -> doc
<+> forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig (forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LIdP (GhcPass p)]
names) (forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
sig_ty)
ppr_sig (SCCFunSig (EpAnn [AddEpAnn]
_, SourceText
src) LIdP (GhcPass p)
fn Maybe (XRec (GhcPass p) StringLiteral)
mlabel)
= SourceText -> String -> SDoc -> SDoc
pragSrcBrackets SourceText
src String
"{-# SCC" (SDoc
ppr_fn forall doc. IsLine doc => doc -> doc -> doc
<+> forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall doc. IsOutput doc => doc
empty forall a. Outputable a => a -> SDoc
ppr Maybe (XRec (GhcPass p) StringLiteral)
mlabel )
where
ppr_fn :: SDoc
ppr_fn = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs -> forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
fn
GhcPass p
GhcRn -> forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
fn
GhcPass p
GhcTc -> forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
fn
ppr_sig (CompleteMatchSig (EpAnn [AddEpAnn]
_, SourceText
src) XRec (GhcPass p) [LIdP (GhcPass p)]
cs Maybe (LIdP (GhcPass p))
mty)
= SourceText -> String -> SDoc -> SDoc
pragSrcBrackets SourceText
src String
"{-# COMPLETE"
((forall doc. IsLine doc => [doc] -> doc
hsep (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
ppr_n (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) [LIdP (GhcPass p)]
cs))))
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
opt_sig)
where
opt_sig :: SDoc
opt_sig = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall doc. IsOutput doc => doc
empty ((\IdGhcP p
t -> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr IdGhcP p
t) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) Maybe (LIdP (GhcPass p))
mty
ppr_n :: GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
ppr_n GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n
GhcPass p
GhcRn -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n
GhcPass p
GhcTc -> forall a. Outputable a => a -> SDoc
ppr GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n
ppr_sig (XSig XXSig (GhcPass p)
x) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcRn | IdSig TyVar
id <- XXSig (GhcPass p)
x -> forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig [TyVar
id] (forall a. Outputable a => a -> SDoc
ppr (TyVar -> Kind
varType TyVar
id))
GhcPass p
GhcTc | IdSig TyVar
id <- XXSig (GhcPass p)
x -> forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig [TyVar
id] (forall a. Outputable a => a -> SDoc
ppr (TyVar -> Kind
varType TyVar
id))
hsSigDoc :: forall p. IsPass p => Sig (GhcPass p) -> SDoc
hsSigDoc :: forall (p :: Pass). IsPass p => Sig (GhcPass p) -> SDoc
hsSigDoc (TypeSig {}) = forall doc. IsLine doc => String -> doc
text String
"type signature"
hsSigDoc (PatSynSig {}) = forall doc. IsLine doc => String -> doc
text String
"pattern synonym signature"
hsSigDoc (ClassOpSig XClassOpSig (GhcPass p)
_ Bool
is_deflt [LIdP (GhcPass p)]
_ LHsSigType (GhcPass p)
_)
| Bool
is_deflt = forall doc. IsLine doc => String -> doc
text String
"default type signature"
| Bool
otherwise = forall doc. IsLine doc => String -> doc
text String
"class method signature"
hsSigDoc (SpecSig XSpecSig (GhcPass p)
_ LIdP (GhcPass p)
_ [LHsSigType (GhcPass p)]
_ InlinePragma
inl) = (InlineSpec -> SDoc
inlinePragmaName forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlinePragma -> InlineSpec
inl_inline forall a b. (a -> b) -> a -> b
$ InlinePragma
inl) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"pragma"
hsSigDoc (InlineSig XInlineSig (GhcPass p)
_ LIdP (GhcPass p)
_ InlinePragma
prag) = (InlineSpec -> SDoc
inlinePragmaName forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlinePragma -> InlineSpec
inl_inline forall a b. (a -> b) -> a -> b
$ InlinePragma
prag) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"pragma"
hsSigDoc (SpecInstSig (EpAnn [AddEpAnn]
_, SourceText
src) LHsSigType (GhcPass p)
_) = forall doc. IsLine doc => String -> doc
text (SourceText -> String
extractSpecPragName SourceText
src) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"instance pragma"
hsSigDoc (FixSig {}) = forall doc. IsLine doc => String -> doc
text String
"fixity declaration"
hsSigDoc (MinimalSig {}) = forall doc. IsLine doc => String -> doc
text String
"MINIMAL pragma"
hsSigDoc (SCCFunSig {}) = forall doc. IsLine doc => String -> doc
text String
"SCC pragma"
hsSigDoc (CompleteMatchSig {}) = forall doc. IsLine doc => String -> doc
text String
"COMPLETE pragma"
hsSigDoc (XSig XXSig (GhcPass p)
_) = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcRn -> forall doc. IsLine doc => String -> doc
text String
"id signature"
GhcPass p
GhcTc -> forall doc. IsLine doc => String -> doc
text String
"id signature"
extractSpecPragName :: SourceText -> String
SourceText
srcTxt = case (String -> [String]
words forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show SourceText
srcTxt) of
(String
_:String
_:String
pragName:[String]
_) -> forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/= Char
'\"') String
pragName
[String]
_ -> forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"hsSigDoc: Misformed SPECIALISE instance pragma:" (forall a. Outputable a => a -> SDoc
ppr SourceText
srcTxt)
instance OutputableBndrId p
=> Outputable (FixitySig (GhcPass p)) where
ppr :: FixitySig (GhcPass p) -> SDoc
ppr (FixitySig XFixitySig (GhcPass p)
_ [LIdP (GhcPass p)]
names Fixity
fixity) = forall doc. IsLine doc => [doc] -> doc
sep [forall a. Outputable a => a -> SDoc
ppr Fixity
fixity, SDoc
pprops]
where
pprops :: SDoc
pprops = forall doc. IsLine doc => [doc] -> doc
hsep forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map (forall a. OutputableBndr a => a -> SDoc
pprInfixOcc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LIdP (GhcPass p)]
names)
pragBrackets :: SDoc -> SDoc
pragBrackets :: SDoc -> SDoc
pragBrackets SDoc
doc = forall doc. IsLine doc => String -> doc
text String
"{-#" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
doc forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
pragSrcBrackets :: SourceText -> String -> SDoc -> SDoc
pragSrcBrackets :: SourceText -> String -> SDoc -> SDoc
pragSrcBrackets (SourceText String
src) String
_ SDoc
doc = forall doc. IsLine doc => String -> doc
text String
src forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
doc forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
pragSrcBrackets SourceText
NoSourceText String
alt SDoc
doc = forall doc. IsLine doc => String -> doc
text String
alt forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
doc forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
pprVarSig :: (OutputableBndr id) => [id] -> SDoc -> SDoc
pprVarSig :: forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig [id]
vars SDoc
pp_ty = forall doc. IsLine doc => [doc] -> doc
sep [SDoc
pprvars forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon, Int -> SDoc -> SDoc
nest Int
2 SDoc
pp_ty]
where
pprvars :: SDoc
pprvars = forall doc. IsLine doc => [doc] -> doc
hsep forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc [id]
vars)
pprSpec :: (OutputableBndr id) => id -> SDoc -> InlinePragma -> SDoc
pprSpec :: forall id. OutputableBndr id => id -> SDoc -> InlinePragma -> SDoc
pprSpec id
var SDoc
pp_ty InlinePragma
inl = SDoc
pp_inl forall doc. IsLine doc => doc -> doc -> doc
<+> forall id. OutputableBndr id => [id] -> SDoc -> SDoc
pprVarSig [id
var] SDoc
pp_ty
where
pp_inl :: SDoc
pp_inl | InlinePragma -> Bool
isDefaultInlinePragma InlinePragma
inl = forall doc. IsOutput doc => doc
empty
| Bool
otherwise = InlinePragma -> SDoc
pprInline InlinePragma
inl
pprTcSpecPrags :: TcSpecPrags -> SDoc
pprTcSpecPrags :: TcSpecPrags -> SDoc
pprTcSpecPrags TcSpecPrags
IsDefaultMethod = forall doc. IsLine doc => String -> doc
text String
"<default method>"
pprTcSpecPrags (SpecPrags [LTcSpecPrag]
ps) = forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
ppr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LTcSpecPrag]
ps)
instance Outputable TcSpecPrag where
ppr :: TcSpecPrag -> SDoc
ppr (SpecPrag TyVar
var HsWrapper
_ InlinePragma
inl)
= forall doc. IsLine doc => String -> doc
text (SourceText -> String
extractSpecPragName forall a b. (a -> b) -> a -> b
$ InlinePragma -> SourceText
inl_src InlinePragma
inl) forall doc. IsLine doc => doc -> doc -> doc
<+> forall id. OutputableBndr id => id -> SDoc -> InlinePragma -> SDoc
pprSpec TyVar
var (forall doc. IsLine doc => String -> doc
text String
"<type>") InlinePragma
inl
pprMinimalSig :: (OutputableBndr name)
=> LBooleanFormula (GenLocated l name) -> SDoc
pprMinimalSig :: forall name l.
OutputableBndr name =>
LBooleanFormula (GenLocated l name) -> SDoc
pprMinimalSig (L SrcSpanAnnL
_ BooleanFormula (GenLocated l name)
bf) = forall a. Outputable a => a -> SDoc
ppr (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall l e. GenLocated l e -> e
unLoc BooleanFormula (GenLocated l name)
bf)
type instance Anno (HsBindLR (GhcPass idL) (GhcPass idR)) = SrcSpanAnnA
type instance Anno (IPBind (GhcPass p)) = SrcSpanAnnA
type instance Anno (Sig (GhcPass p)) = SrcSpanAnnA
type instance Anno [LocatedN RdrName] = SrcSpan
type instance Anno [LocatedN Name] = SrcSpan
type instance Anno [LocatedN Id] = SrcSpan
type instance Anno (FixitySig (GhcPass p)) = SrcSpanAnnA
type instance Anno StringLiteral = SrcAnn NoEpAnns
type instance Anno (LocatedN RdrName) = SrcSpan
type instance Anno (LocatedN Name) = SrcSpan
type instance Anno (LocatedN Id) = SrcSpan