summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-02-03 17:57:29 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-20 21:18:48 -0500
commit6880d6aa1e6e96579bbff89712efd813489cc828 (patch)
treef2156d5a5c168bf28ee569a62a74b51adf74dac9 /compiler/GHC/Hs
parent74ad75e87317196c600dfabc61aee1b87d95c214 (diff)
downloadhaskell-6880d6aa1e6e96579bbff89712efd813489cc828.tar.gz
Disentangle DynFlags and SDoc
Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Binds.hs29
-rw-r--r--compiler/GHC/Hs/Expr.hs5
-rw-r--r--compiler/GHC/Hs/Pat.hs29
3 files changed, 30 insertions, 33 deletions
diff --git a/compiler/GHC/Hs/Binds.hs b/compiler/GHC/Hs/Binds.hs
index 2014d92c25..6796216c87 100644
--- a/compiler/GHC/Hs/Binds.hs
+++ b/compiler/GHC/Hs/Binds.hs
@@ -19,6 +19,7 @@ Datatype for: @BindGroup@, @Bind@, @Sig@, @Bind@.
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE LambdaCase #-}
module GHC.Hs.Binds where
@@ -42,7 +43,6 @@ import Var
import Bag
import FastString
import BooleanFormula (LBooleanFormula)
-import DynFlags
import Data.Data hiding ( Fixity )
import Data.List hiding ( foldr )
@@ -739,20 +739,19 @@ ppr_monobind (PatSynBind _ psb) = ppr psb
ppr_monobind (AbsBinds { abs_tvs = tyvars, abs_ev_vars = dictvars
, abs_exports = exports, abs_binds = val_binds
, abs_ev_binds = ev_binds })
- = sdocWithDynFlags $ \ dflags ->
- if gopt Opt_PrintTypecheckerElaboration dflags then
- -- Show extra information (bug number: #10662)
- hang (text "AbsBinds" <+> brackets (interpp'SP tyvars)
- <+> brackets (interpp'SP dictvars))
- 2 $ braces $ vcat
- [ text "Exports:" <+>
- brackets (sep (punctuate comma (map ppr exports)))
- , text "Exported types:" <+>
- vcat [pprBndr LetBind (abe_poly ex) | ex <- exports]
- , text "Binds:" <+> pprLHsBinds val_binds
- , pprIfTc @idR (text "Evidence:" <+> ppr ev_binds) ]
- else
- pprLHsBinds val_binds
+ = sdocOption sdocPrintTypecheckerElaboration $ \case
+ False -> pprLHsBinds val_binds
+ True -> -- Show extra information (bug number: #10662)
+ hang (text "AbsBinds" <+> brackets (interpp'SP tyvars)
+ <+> brackets (interpp'SP dictvars))
+ 2 $ braces $ vcat
+ [ text "Exports:" <+>
+ brackets (sep (punctuate comma (map ppr exports)))
+ , text "Exported types:" <+>
+ vcat [pprBndr LetBind (abe_poly ex) | ex <- exports]
+ , text "Binds:" <+> pprLHsBinds val_binds
+ , pprIfTc @idR (text "Evidence:" <+> ppr ev_binds)
+ ]
ppr_monobind (XHsBindsLR x) = ppr x
instance OutputableBndrId p => Outputable (ABExport (GhcPass p)) where
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index 6890484472..308b112886 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -38,7 +38,6 @@ import GHC.Hs.Binds
-- others:
import TcEvidence
import CoreSyn
-import DynFlags ( gopt, GeneralFlag(Opt_PrintExplicitCoercions) )
import Name
import NameSet
import BasicTypes
@@ -186,9 +185,9 @@ instance Outputable SyntaxExprTc where
ppr (SyntaxExprTc { syn_expr = expr
, syn_arg_wraps = arg_wraps
, syn_res_wrap = res_wrap })
- = sdocWithDynFlags $ \ dflags ->
+ = sdocOption sdocPrintExplicitCoercions $ \print_co ->
getPprStyle $ \s ->
- if debugStyle s || gopt Opt_PrintExplicitCoercions dflags
+ if debugStyle s || print_co
then ppr expr <> braces (pprWithCommas ppr arg_wraps)
<> braces (ppr res_wrap)
else ppr expr
diff --git a/compiler/GHC/Hs/Pat.hs b/compiler/GHC/Hs/Pat.hs
index 50db04e92e..3e78ec4fb9 100644
--- a/compiler/GHC/Hs/Pat.hs
+++ b/compiler/GHC/Hs/Pat.hs
@@ -19,6 +19,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE LambdaCase #-}
module GHC.Hs.Pat (
Pat(..), InPat, OutPat, LPat,
@@ -67,7 +68,6 @@ import Outputable
import Type
import SrcLoc
import Bag -- collect ev vars from pats
-import DynFlags( gopt, GeneralFlag(..) )
import Maybes
-- libraries:
import Data.Data hiding (TyCon,Fixity)
@@ -498,13 +498,13 @@ pprParendLPat p = pprParendPat p . unLoc
pprParendPat :: (OutputableBndrId p)
=> PprPrec -> Pat (GhcPass p) -> SDoc
-pprParendPat p pat = sdocWithDynFlags $ \ dflags ->
- if need_parens dflags pat
+pprParendPat p pat = sdocOption sdocPrintTypecheckerElaboration $ \print_tc_elab ->
+ if need_parens print_tc_elab pat
then parens (pprPat pat)
else pprPat pat
where
- need_parens dflags pat
- | CoPat {} <- pat = gopt Opt_PrintTypecheckerElaboration dflags
+ need_parens print_tc_elab pat
+ | CoPat {} <- pat = print_tc_elab
| otherwise = patNeedsParens p pat
-- For a CoPat we need parens if we are going to show it, which
-- we do if -fprint-typechecker-elaboration is on (c.f. pprHsWrapper)
@@ -551,16 +551,15 @@ pprPat (ConPatOut { pat_con = con
, pat_dicts = dicts
, pat_binds = binds
, pat_args = details })
- = sdocWithDynFlags $ \dflags ->
- -- Tiresome; in TcBinds.tcRhs we print out a
- -- typechecked Pat in an error message,
- -- and we want to make sure it prints nicely
- if gopt Opt_PrintTypecheckerElaboration dflags then
- ppr con
- <> braces (sep [ hsep (map pprPatBndr (tvs ++ dicts))
- , pprIfTc @p $ ppr binds ])
- <+> pprConArgs details
- else pprUserCon (unLoc con) details
+ = sdocOption sdocPrintTypecheckerElaboration $ \case
+ False -> pprUserCon (unLoc con) details
+ True -> -- Tiresome; in TcBinds.tcRhs we print out a
+ -- typechecked Pat in an error message,
+ -- and we want to make sure it prints nicely
+ ppr con
+ <> braces (sep [ hsep (map pprPatBndr (tvs ++ dicts))
+ , pprIfTc @p $ ppr binds ])
+ <+> pprConArgs details
pprPat (XPat n) = noExtCon n